View Single Post
  #2  
Old 09-15-2004, 11:44 AM
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