3d terrain Catacombs -- 3D

Recommended Posts

(Installment one is embodied at https://jounce.space/zoom (infinite field of polyhedra).)

This is installment two towards infinite 3D Terrain.

"Exterior" shot:

Interior shot:

This is not yet "infinite". For now it's a limited 3D lattice.

Go to https://www.babylonjs-playground.com/#USDWIJ#4 and make your way to an exit for an over-all view.

For all the effort I've put into this, I'm now at a loss over what to do with it. Suggestions?

A technique looking for an idea!

Happy Holidays! 🌲 🎅

Share on other sites

It lag a lot. I can not use it. (10 FPS)

Share on other sites

Oops! Here it is with much smaller lattice: https://www.babylonjs-playground.com/#USDWIJ#4

My newly acquired refurbished computer has a bit more oomph than I thought!

Edit: I think I'm seeing a mistake -- when viewing the labyrinth from outside, I think I'm seeing two interlaced but unconnected labyrinths. This would also apply to the PG in the OP.

Hopefully not apply to the PGs in my later posts, since they use a different method to generate the lattice.       😐

Edit 2: Fixed it by replacing lattice generator with recursive version.

Share on other sites

excellent !

I like this geometry too

Share on other sites

To INFINITY and  b e  y   o   n    d !
Now the lattice develops as you approach, adding chambers ahead of you using chambers that you've left behind.
Your processors only have to manage 16 total chambers instead of XxYxZ chambers for an XxYxZ sized lattice.
So better frame rate and an infinity of chambers!
PG:-------------- 👉   https://www.babylonjs-playground.com/#USDWIJ#5 👈

For challenge, try to make your way to an exit -- exits are at grid coordinates that are divisible by four: [4, 4, 4], [40,-12,8], etc.
Another challenge: try exit a chamber and return through a different tunnel.

The Code:
My goal was to make a regular labyrinth: uniform sized and spaced chambers with tunnels connected to each nearest neighbor. To avoid sight-lines that extend beyond neighboring chambers, I based the chambers on the tetrahedron. The tetrahedron has four faces, none of which are parallel. Actually, I used the truncated tetrahedron which has hexagon instead of triangle faces. I extended the hexagons to form the tunnels.

[Some of the code is kinda complicated and the commenting is rather sparse: I need to develop vocabulary.]
The following may help.

Some interesting characteristics of this tetrahedral lattice:

The absolute values of the components of a vector between neighboring chambers are equal (opposite corners of a cube).

So with a grid increment gi, a chamber located at [a,b,c], its four neighbors would be at:
[a-gi, b+gi, c+gi],
[a+gi, b+gi, c-gi],
[a-gi, b-gi, c-gi],
and    [a+gi, b-gi, c+gi].

Since neighboring chambers are mirrored, the signs of gi must be reversed for alternate chambers. (PG lines 166 - 178)

If the grid increment gi = 1, as it is in the PG, the chamber grid coordinates will all be even or all be odd:
[even, even, even] or [odd, odd, odd].

See nearestLatticePoint()  (PG lines 200- 230)

__________________________________________________________________________

Share on other sites

Q: Are the [even, even, even], [odd, odd, odd] lattice node positions required?
A: No, the lattice can be started (seeded) anywhere. The [even, even, even], [odd, odd, odd] pattern is convenient.

Q: Are all [even, even, even] and [odd, odd, odd] positions occupied?
A: No. A node (eg. [3,5,7]) has four neighbors, but there are eight neighboring [even, even, even] positions:
[2, 4, 6],
[2, 4, 8],
[2, 6, 6],
[2, 6, 8],
[4, 4, 6],
[4, 4, 8],
[4, 6, 6],
[4, 6, 8].

Q: So exits at positions with coordinates divisible by ten might not exist?
A: Possibly, 50% chance since I chose div by 10 arbitrarily.

Q: How can I choose periodic exit locations that do exist?
A: Don't know. Working on it. Help? (https://www.babylonjs-playground.com/#USDWIJ#2   lines 191  - 194).
💡

------------------------------------------------------------------------------------------------------------------

Postscript: The lattice repeats every 4 along cardinal axis, so here I've put exits at positions with coordinates all divisible by four: https://www.babylonjs-playground.com/#USDWIJ#5

and changed other references to PG with non-existing exits.

Share on other sites

I'm pretty sure that the first two PGs in this topic are generating two interleaved lattices (not my intention).

https://www.babylonjs-playground.com/#USDWIJ  and  https://www.babylonjs-playground.com/#USDWIJ#1
The lattices are produced in this triple nested for loop:

``````for (var i = -count; i < count; i++) {// make lattice
for (var j = -count; j < count; j++) {
for (var k = -count; k < count; k++) {
var newInstance = polygon.createInstance("i" + i);
newInstance.checkCollisions = true;
newInstance.position.set(i*24,i*24+j*24,i*24+k*24)
chamberLabel(newInstance.position.clone())
newInstance = mpolygon.createInstance("ii" + i);
newInstance.checkCollisions = true;
newInstance.position.set(i*24+12,i*24+j*24+12,i*24+k*24+12)
chamberLabel(newInstance.position.clone())
}}}
``````

[sorry 'bout not giving literal 24 a var name]

Anyone care to try fixing this gnarly inscrutable lattice generator?
😕  ⁉️

----------------------------------------------------------------------------------------------------------------------

Edit: Fixed it by replacing the triple nested for loop with a recursive version  https://www.babylonjs-playground.com/#USDWIJ#4

``````///////////  recursive lattice builder
var occupied = {}
var count = 4
if (n >= count) return // done, go home
}
if (n >= count) return // done, go home
}

var name = gx+","+gy+","+gz
if (occupied[name]) return
occupied[name] = true
var newInstance = mpolygon.createInstance("i" + n);
newInstance.checkCollisions = true;
chamberLabel(newInstance.position.clone())
}
var name = gx+","+gy+","+gz
if (occupied[name]) return
occupied[name] = true
var newInstance = polygon.createInstance("i" + n);
newInstance.checkCollisions = true;
chamberLabel(newInstance.position.clone())
}

addRR(0, 0,0,0) // start recursive lattice builder
/////////// end of recursive lattice builder
``````

👍

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.