2
\$\begingroup\$

How can I create a wrap around unlimited 3D terrain: To make it clear: If I step out of terrain in (1) or (A) I want to get to (2) resp. (B)

 |B V +----------+ 2 -->| |--> 1 | | | | +----------+ |A V 

I do not know how to wrap around the terrain and all the items which are on the terrain(NPCs etc) I thought of portals, but then I have problems on the corners of the terrain. In 2D it is quite simple(even trivial), but on 3D I cannot find a solution.. Any advice or tutorial ailable?

\$\endgroup\$
4
  • 3
    \$\begingroup\$ What makes it harder in 3D compared to 2D? \$\endgroup\$ Commented May 3, 2013 at 8:42
  • \$\begingroup\$ in 2D I render a 2D screen and can easily use modulo to check if I need to draw an item. In 3D I usually need to use frustum culling. I do not know how to wrap the frustrum around the terrains edges \$\endgroup\$ Commented May 3, 2013 at 9:13
  • \$\begingroup\$ Your comment implies you're actually asking how to draw the terrain and your question seems to be asking about movement. \$\endgroup\$ Commented May 3, 2013 at 12:43
  • \$\begingroup\$ I am asking about drawing or better retrieving the list of items to draw(especially when I am near the edges of the wrap around) \$\endgroup\$ Commented May 3, 2013 at 15:38

1 Answer 1

4
\$\begingroup\$

Have a matrix of chunks that make up the visible area around the camera. The chunks will use modulo, just like in 2D, to determine which chunk of your wrapped 3D world they should contain.

enter image description here

Each dimension is like a conveyor belt, loading and unloading chunks as the camera moves along its axis.

Now, when it comes to drawing, you just reference the chunks loaded around your camera. If the wrap of the world was small, there would be duplicate chunks referenced in the chunk matrix. The view frustum doesn't need to know anything about where the world wraps, it just looks at the loaded chunks.

\$\endgroup\$
3
  • \$\begingroup\$ Aha.. thats interesting approach! I do not like the idea of moving all items through the chunks on moving forward(as this will not scale very good). But It is a first approach(I would like to have a geometrical approach, but thanks anyway!) \$\endgroup\$ Commented May 3, 2013 at 15:41
  • 1
    \$\begingroup\$ A point of interest: Make certain that terrain at the edges matches up. This can be quite tricky due to the corners. \$\endgroup\$ Commented May 3, 2013 at 17:48
  • \$\begingroup\$ You don't have to copy data around to move through chunks. You'd have the non-wrapped 3D data loaded elsewhere, and simply put references in the 3D matrix for drawing. Moving a reference around is pretty inexpensive. You wouldn't want copies of the data in multiple places anyway. \$\endgroup\$ Commented May 3, 2013 at 20:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.