WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 12:18 AM.


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