Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
3  
What makes it harder in 3D compared to 2D? –  msell May 3 '13 at 8:42
    
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 –  Peter Parker May 3 '13 at 9:13
    
Your comment implies you're actually asking how to draw the terrain and your question seems to be asking about movement. –  Byte56 May 3 '13 at 12:43
    
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) –  Peter Parker May 3 '13 at 15:38

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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!) –  Peter Parker May 3 '13 at 15:41
    
A point of interest: Make certain that terrain at the edges matches up. This can be quite tricky due to the corners. –  zeel May 3 '13 at 17:48
    
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. –  Byte56 May 3 '13 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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