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)

2 -->|          |--> 1
     |          |
     |          |

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?

  • 3
    \$\begingroup\$ What makes it harder in 3D compared to 2D? \$\endgroup\$ – msell May 3 '13 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\$ – Peter Parker May 3 '13 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\$ – MichaelHouse May 3 '13 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\$ – Peter Parker May 3 '13 at 15:38

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.

|improve this answer|||||
  • \$\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\$ – Peter Parker May 3 '13 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\$ – zeel May 3 '13 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\$ – MichaelHouse May 3 '13 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.