Vizard 6 » Tutorials & Examples » Example scripts » Tracking » Manual
6.3

Manual head tracking

\examples\tracking\manual.py

This script demonstrates how perform grab the raw data from the head tracker plugin.   

 

"""
This script demonstrates how to perform manual head tracking.
It will retrieve data from the tracker and only rotate the yaw.
By default this script will connect to an intersense.
Press the 'r' key to reset the tracker
"""
import viz
import vizact

viz.setMultiSample(4)
viz.fov(60)
viz.go()

import vizinfo
vizinfo.InfoPanel()

#Add environment
viz.addChild('gallery.osgb')

#Add the intersense tracker
isense = viz.add('intersense.dle')
tracker = isense.addTracker()

# This function will grab the tracker data and update the viewpoint
def UpdateView():

    #Get tracker euler rotation
    yaw,pitch,roll = tracker.getEuler()

    #Only rotate the yaw of the body orientation
    viz.MainView.setEuler([yaw,0,0],viz.BODY_ORI)

#Call UpdateView function every frame
vizact.ontimer(0,UpdateView)

#Rest tracker when 'r' key is pressed
vizact.onkeydown('r',tracker.reset)