4-dimensional renderer

A 4-dimensional object system that allows for the rendering (and positioning / rotation) of any 4-dimensional meshes. The position / orientation system behaves exactly how CFrames behave (but in 4-dimensions) and the rendering system can display objects as both cross-sections and projections.

For example, here are the cross-sections of three (of six) 4-dimensional platonic solids (the 16-cell, 8-cell (tesseract), and 5-cell). Rotations are defined by

CFrame4.fromAngles(-angle, angle, angle, -angle, -angle, -angle)
-- xy, xz, xw, yz, yw, zw rotation planes
-- note that 4d rotations occur in 6 planes and don't correspond to axes, as opposed to 3d rotation which occurs in 3 planes and does correspond to axes

Here are the stereographic projections of the same platonic solids. You may have seen a rotating tesseract (middle) before. Rotations are defined by

CFrame4.fromAngles(0, 0, angle, -angle, 0, 0)
-- xy, xz, xw, yz, yw, zw rotation planes

Thanks to the module design, the code for the above (cross-sectional) video is as simple as

local CFrame4 = require(script.Shape4.CFrame4)
local Vector4 = require(script.Shape4.Vector4)
local Shape4 = require(script.Shape4)

local position = Vector4.new(10, 10, 50, 1)
local polytopes = {
	Shape4.new("16-cell", 8, CFrame4.identity()),
	Shape4.new("8-cell", 6, CFrame4.identity()),
	Shape4.new("5-cell", 12, CFrame4.identity())
}

game:GetService("RunService").Heartbeat:ConnectParallel(function()
	local angle = os.clock()
	for i, solid in polytopes do
		local frame = CFrame4.fromAngles(-angle, angle, angle, -angle, -angle, -angle) + position
		solid:setCFrame(frame + Vector4.new(i * 15, 0, 0, 0))
		solid:getRenderData()
	end
	task.synchronize()
	for i, solid in polytopes do solid:renderFromData() end
end)
45 Likes

This is crazy impressive. I don’t even know where to start. This is amazing!

13 Likes

This is very cool! Even though my 3-dimensional mind cannot comprehend these shapes and I have no idea how this would be used in games, I still believe this is pretty cool, so good job!

10 Likes

This man is gonna invent the next quantum computer, damn this is impressive!

I would love to see you (or someone else) do a take on non-euclidean geometry and space where triangles can have 3x 90-degree angles and where you can fit 5 rooms in a 2x2 square grid. :slight_smile:

8 Likes

I like it! Way too brain-destroying and complex for me to attempt to use right now

8 Likes

Like this?

The rooms themselves are euclidean, but the environment as a whole isn’t (note the number of turns).

15 Likes

This is wild, amazing job, I didn’t even think about something like this.

8 Likes

That’s super cool stuff! I wonder what else there is, this has much potential for fun puzzle and exploration games.

7 Likes

Wow, this is nice! Good job on this!

4 Likes

too complicated for me to give any criticism, very cool!

4 Likes

Wow this is not bad at all. Though it would be fun if you can make non-euclidean games? Can we? Say like super liminal? I think that would be super cool seeing a game like Super Liminal (I think its called) on Roblox. Also may I ask how you were able to achieve this?

6 Likes

yeah whats even going on? i didnt think you could change the roblox rendering pipeline like that…???

5 Likes

The “rendering” part is just drawing triangles using EditableMesh instances. The difficult/cool part is the math behind it!

7 Likes

Each 4d mesh is stored as a collection (table) of points (Vector4), edges, and tetrahedrons. The tetrahedrons define the “hyper-surface” of the meshes the same way triangles define the surface of a 3-dimensional mesh.

CFrame4’s work the same way normal cframes do (except in 4-dimensions) and are 5x5 matrices with a 4x4 rotational component and a 4x1 positional component. Vector4’s are also just vectors but with 4 coordinates (x, y, z, w).

Drawing the cross-section is the same as drawing the cross-section of every tetrahedron, and that is done by calculating intersection points (with our 3d world) and then drawing either nothing, triangles, or quadrilaterals from the resulting “slice”.

I’ve attached a full(er) explanation here
4D renderer.pdf (33.4 KB)
and here

6 Likes

in 4d is it a Quinernion rather than a Quaternion??? but yeah v cool.
Tho i would say im not sure how fun 4d games are, defintly could fall into the confusing no fun category…if your thinking games you probs want to keep it very simple. maybe a point and click type game in a small environment so people dont get lost or maybe a rail shooter, so the player doesnt have to manually move through the dimensions??
Either way awesome work… be cool to see what it turns into

3 Likes

I use matrices rather than quaternions (iirc you need two quaternions to encode 4d orientation). Quaternions themselves are 4-dimensional, but are better for representing 3-dimensional rotations. They only have equivalents in dimensions which are powers of 2 (1, 2, 4, 8, etc) so quinernions don’t exist. If you are interested, you can look into hypercomplex numbers and multivectors which are similar concepts and do extend to arbitrary dimensions. I did consider using those (hypercomplex/multivectors) because of their intuitive nature when it comes to angular velocity but decided against it.

2 Likes

lol i did say that as a joke, but i learned alot thanks

3 Likes

This is so cool!! Are you planning to open source the module :sob:

I am sure not as it would not be just for us to just take their creation for free while they worked so hard on making a 4d engine. 4d calculations are certainly not easy.

recently we made 4d game 4D OBBY [âť—NEWâť—] - Roblox

3 Likes