View Single Post
Old 06-11-2010, 04:36 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,465
If you are using the keyboard to update the projections and the joystick to drive the CAVE around you can do something like this.

#Create tracker object using the keyboard (WASD keys control the viewpoint, the user's eye location)
#Make the starting location for the user's eye the exact center of the CAVE
viewtracker = viztracker.KeyboardPos()
viewtracker.setPosition (W/2.0,H/2.0,D/2.0)

#Pass the viewpoint tracker into the cave object so it can be automatically updated

#Create CaveView object for manipulating the entire cave environment
#The caveorigin is a node that can be adjusted to move the entire cave around the virtual environment
caveorigin = vizcave.CaveView(viewtracker)

#update caveorigin with joystick

MOVE_SPEED = 5 # meters/sec

def joyMove():
	#Use y position of joystick to drive CAVE forward
	forwardMovement = viz.elapsed() * MOVE_SPEED * -joyPOS[1]
	#Use x position of joystick to drive CAVE side to side
	sideMovement = viz.elapsed() * MOVE_SPEED * joyPOS[0]
vizact.ontimer(0, joyMove)
When using the vizcave module the viewpoint should not be updated with:
The viewpoint will update properly if you set a tracker for the CAVE and use the CaveOrigin object to drive the CAVE around.
Reply With Quote