View Single Post
  #2  
Old 01-28-2004, 12:36 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

There is no built-in functionality to control the viewpoint with the joystick, but it's still really easy to do. Here is some code that will use the joystick to move forward/backward and right/left. It will also use the twist of the joystick to rotate the viewpoint left and right. This example does not import any models, so you'll have to import your own model in order to navigate around.
Code:
import viz
import sid
import math

viz.go()

def mytimer(num):
	y = sid.get()[1]
	x = sid.get()[0]
	twist = (180.0 / math.pi) * (sid.aux()[3])
	if math.fabs(y) > 0.2:
		viz.move(0,0,-y*0.1)
	if math.fabs(x) > 0.2:
		viz.move(x*0.1,0,0)
	if math.fabs(twist) > 20:
		viz.rotate(viz.BODY_ORI,twist/50.0,0,0)
		
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.001,viz.FOREVER)
Hope this helps!
Reply With Quote