View Single Post
  #14  
Old 10-25-2012, 06:20 AM
Kyman2008 Kyman2008 is offline
Member
 
Join Date: Jul 2012
Posts: 19
Ok so I have solved this problem, but the problem of walking around my world has now arised because If I use the link command to link the mainview with the tracker the mainview will automatically jump to a random point in my world corresponding to the millimeter position data it is getting from the optitrack position data. All I want to do is calculate if there is a difference in position data between a small amount of time (i.e. the person moved) and then output this same movement in Vizard. Here is my code currently for connecting my tracker and viz.MainView. (The function for updating euler works, the update position does not work, i.e. I can't walk around my world!!)

###Link Mainview to Sensor and Begin Scene###
def updateView_Euler():

yaw, pitch, roll = headtracker.getEuler()
pitch= pitch - 10
yaw= yaw + 30
viz.MainView.setEuler([-yaw,pitch,0],viz.BODY_ORI)

vizact.ontimer(0,updateView_Euler)

def updateView_Position():

x,y,z= headtracker.getPosition()
x = int(x)*1000
z = int(z)*1000

x2,y2,z2= headtracker.getPosition()
x2 = int(x2)*1000
z2 = int(z2)*1000

delta_x = x2 - x
delta_z = z2 - z

if delta_x > 3 :
viz.MainView.move(delta_x,0,0, viz.BODY_ORI)
if delta_z > 3:
viz.MainView.move(0,0,delta_z, viz.BODY_ORI)


vizact.ontimer(0,updateView_Position)
Reply With Quote