View Full Version : generate an infinite terrain

09-15-2004, 11:32 AM
I am trying to make a simple flight sim world, but this question applies to any "outdoors" VE.

How can I generate an "infinitely" expanding terrain?

I want the user to fly/move about the world and always have terrain in the distance. I don't care if the pattern repeats (i.e. tile a terrain) or if its unique (i.e. dynamic/random generation).

- adrian

09-15-2004, 11:44 AM

I've attached a sample script that simulates an infinite terrain. The basic idea is to modify the texture coordinates on a tiled texture to make it look like the ground is moving. Let me know if something isn't clear.import viz

SIZE = 1000.0

#Create a ground on the fly
ground = viz.add('tut_ground.wrl')

def ontimer(num):
#Keep the ground at the same xz position as the head
pos = viz.get(viz.HEAD_POS)

center = [ (pos[0] % SIZE) / SIZE, (pos[2] % SIZE) / SIZE ]

#Translate and scale texture coordinates
texmat = viz.Transform()



09-15-2004, 11:58 AM

and if I want to add a 3d dimension to the terrain (like hills or scattered objects), how can I do that?

It looks likes this code will only move the map over a varied terrain without actually moving the terrain. Do you think i could get the effect I want by moving a bump map in the same way?

09-15-2004, 12:13 PM
A good example for placing rendomly scattered objects in a large terrain can be found under the Vizard demo section:


Download the Vision Science Demos and have a look at the drive-sim demo.

Hope this helps, have fun!


09-15-2004, 01:09 PM
The basic idea for these approaches is to first create a "cyclical" world with at least 2 full cycles in each dimension. This can be either in terms of texture or geometry. For example, to create an infinite forest of geometric trees, first create a patch of trees that's roughly square and random looking. Then tile that pattern so that there are at least two copies in the X and Z direction. Then, at any point in time you can transate the user's eyepoint by exactly the width of the patch in either X or Z and there will be no apparent change in the scene. The only thing visible might be trees that are beyond the tile pattern visible in the next. You can alleviate this by either using fog to limit visibility or build a 3x3 or 4x4 tiling (instead of 2x2) and always keeping the user near the middle.