WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 07-25-2005, 01:15 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I've modified your script a little to do what I believe you want it to do. I've commented the parts of the code that modify the viewpoint. Let me know if this isn't exactly what you are looking for.
Code:
import viz
viz.go()

viz.mouse(viz.OFF)

viz.add('tut_ground.wrl')
Wheelbarrow = viz.add('wheelbarrow.ive')

#Get handle to main viewpoint
view = viz.get(viz.MAIN_VIEWPOINT)

Wheelbarrow.translate(0,0,6)

MOVE_SPEED = 10
TURN_SPEED = 360

def mytimer(num1):
	#Move wheelbarrow using arrow keys
	if viz.iskeydown(viz.KEY_UP):
		Wheelbarrow.translate(0,0,MOVE_SPEED*viz.elapsed(),viz.RELATIVE_LOCAL)
	elif viz.iskeydown(viz.KEY_DOWN):
		Wheelbarrow.translate(0,0,-MOVE_SPEED*viz.elapsed(),viz.RELATIVE_LOCAL)
	if viz.iskeydown(viz.KEY_RIGHT):
		Wheelbarrow.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.RELATIVE_LOCAL)
	elif viz.iskeydown(viz.KEY_LEFT):
		Wheelbarrow.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.RELATIVE_LOCAL)

	#Create transform from wheelbarrow
	xform = viz.Transform(Wheelbarrow.get(viz.MATRIX))
	#Move position up 1 meter and back 5 meters
	xform.preTrans(0,1,-5)
	#Apply position of transform to viewpoint
	view.translate(xform.getTrans())
	#Have viewpoint look at wheelbarrow
	view.lookat(Wheelbarrow.get(viz.POSITION))
	
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(1,0,viz.PERPETUAL)
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 02:09 AM.


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