WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 09-15-2004, 12:32 PM
vadrian vadrian is offline
Member
 
Join Date: Sep 2004
Posts: 32
Question 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
Reply With Quote
  #2  
Old 09-15-2004, 12:44 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #3  
Old 09-15-2004, 12:58 PM
vadrian vadrian is offline
Member
 
Join Date: Sep 2004
Posts: 32
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?
Reply With Quote
  #4  
Old 09-15-2004, 01:13 PM
mspusch mspusch is offline
WorldViz Team Member
 
Join Date: Feb 2003
Posts: 223
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
Reply With Quote
  #5  
Old 09-15-2004, 02:09 PM
tobin tobin is offline
WorldViz Team Member
 
Join Date: Feb 2003
Posts: 251
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.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:38 PM.


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