Thanks for your help! Here's the program:
#Trial 08 - 2-1B
import sid
import viz
import math
viz.go()
a = 0
b = 0
c = 0
#Add the intersense tracker
tracker = viz.addsensor('intersense')
viz.tracker()
tracker.reset()
#Turn off the mouse cursor
viz.cursor(0)
#Add the objects
viz.add('08hw21b.wrl')
viz.sensitivity(10.0,0.5) #For Participants
#viz.sensitivity(100.0,0.5) #For Development
viz.collision(viz.ON)
viz.gravity(0.0)
#Make the headlight omnidirectional
headlight = viz.get(viz.HEAD_LIGHT)
headlight.position(0,0,0,1)
#Triple the intensity of the headlight
headlight.intensity(3)
#Add the crosshair
crosshair = viz.add(viz.TEXQUAD,viz.SCREEN)
crosshair.texture(viz.add('crosshair.tif'))
crosshair.translate(0.5,0.5)
#Add joystick navigation
def joysticktimer(num):
data = sid.get()[2]
y = sid.get()[1]
if math.fabs(y) > 0.2:
viz.move(0,0,-y*0.9)
#Get the head position
pos = viz.get(viz.HEAD_POS)
#Get the yaw of the viewer
yaw = viz.get(viz.VIEW_YAW)
#Snap back to the home position on S key press
def snapback(key):
if key == 's':
viz.reset(viz.HEAD_ORI|viz.BODY_ORI|viz.HEAD_POS)
viz.translate(viz.HEAD_POS,0.875,1.82,569.5) #Home Position 1
viz.callback(viz.KEYBOARD_EVENT,snapback)
#Print data on trigger pull
buttons = sid.buttons()
if buttons & 1:
print yaw,pos
#Print yaw and positional information constantly in terminal window
#print yaw,pos
viz.eyeheight(1.82)
viz.callback(viz.TIMER_EVENT,joysticktimer)
viz.starttimer(0,0.001,viz.FOREVER)
|