# Creating looping terrain

This topic is 4896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, Ok, so I've created a quadtree and have split up my terrain into chunks which are each then assigned to a unique leaf node in the quadtree. Each chunk is simply a unique set of indices that operate on the same full set of vertices. Now, I want to make the terrain "looping," so that if the player moves off the edge of the terrain, he will pop back to the other side. I can change his position accordingly, this is no problem. However, as the player approaches the edge of the terrain, they see the 'edge of the world' right up until they are popped back to the other side -- not a very convincing illusion. So, I need some way to detect that the viewing frustum is viewing off past the edge of the terrain, and render the appropriate amount of nodes from the other side of the terrain to fill it up. Maybe these pictures will clarify a little: In the image to the left, you can see that as the player approaches the left side of the terrain, most of his viewing frustum is seeing nothing -- the player sees the edge of the world. In the image to the right, nodes 3 and 4 are drawn again infront of the player to give the illusion of looping terrain. Once the player hits the edge of the "actual" nodes, they will seamlessly pop back to the other side. So, my problem: I'm unsure of a clean algorithm to do this, or if this is even the best way... Has anyone ever attempted something like this? Is there a good way to organize my quadtree-scene graph to set something like this up?

##### Share on other sites
What you need to have is your spatial structure displaying 8 fields around the field the player is in. So, an example would be:

P - Player location field

1 2 3
4 P 5
6 7 8

So, you require to have in cache the 8 fields that surround the player. At least. If your fields are small so that you can see end of the world after the fog, then you need to increase that by another 'circle'.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 34
• 16
• 11
• 12
• ### Forum Statistics

• Total Topics
634123
• Total Posts
3015649
×