WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   generate an infinite terrain (https://forum.worldviz.com/showthread.php?t=197)

vadrian 09-15-2004 11:32 AM

generate an infinite terrain
 
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

farshizzo 09-15-2004 11:44 AM

Hi,

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.
Code:

import viz
viz.go()

SIZE = 1000.0

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

def ontimer(num):
        #Keep the ground at the same xz position as the head
        pos = viz.get(viz.HEAD_POS)
        ground.translate(pos[0],0,pos[2])
       
        center = [ (pos[0] % SIZE) / SIZE, (pos[2] % SIZE) / SIZE ]

        #Translate and scale texture coordinates
        texmat = viz.Transform()
        texmat.setTrans(center[0],center[1],0)
        texmat.setScale(0.5,0.5,1)
        ground.texmat(texmat)

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0.01,viz.FOREVER)

viz.translate(viz.HEAD_POS,0,50,0)
viz.sensitivity(10,1)


vadrian 09-15-2004 11:58 AM

thanks!

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?

mspusch 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:

http://www.worldviz.com/products/vizard/index.html

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

Hope this helps, have fun!

Matthias

tobin 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.


All times are GMT -7. The time now is 09:52 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC