Head positionAfter adding one or more sensors to the environment, the command to activate automatic observer tracking is tracker(). This command will scan through the list of trackers that have been added and use the data in a hopefully intelligent manner. If more than one sensor has been added to the environment, then it is important that not more than one sensor has as its default type the same parameters (eg., if two added sensors are both "Head position" devices then a parameter collision error will result). In the event that you want to add another sensor to the environment but do not want it used by the automatic tracking mode, then you simply add the additional sensors after the tracker() command in the script.
Head orientation
Body orientation
It is worth remembering that almost all sensors have a default method called reset() which will do the appropriate resetting or zero'ing of the device. For a position tracker, it will offset the data so that it now appears as though the observer is standing at the origin. For an orientation tracker, it will point the orientation to virtual North (yaw = 0), and depending on the device may or may not reset pitch and roll also to zero.
ADVANCED USERS: There is an experiment command that can allow
you to change the sensor type. For instance, if you have a sensor
that has been created as a HEAD_POS and HEAD_ORI device and you want to
substitute another device in for orientation tracking, you can override
the default type using the sensor type() command. This example shows
how to use the "shootingstar" tracker (which by default provides HEAD_POS
and HEAD_ORI) with an "intersense" tracker that only provides HEAD_ORI.
tracker1 = vrut.addsensor('shootingstar')
tracker1.type(vrut.HEAD_ORI)tracker2 = vrut.addsensor('intersense')
vrut.tracker()
Object positionTo attach a sensor to an object, you simple issue the sensor() child method and pass it the sensor object you want to use. For instance, to use a "shootingstar" tracker to control the position and orientation of an object, you might try something like the following:
Object orientation
hand = vrut.addchild('disembodied_hand.wrl')
tracker = vrut.addsensor('shootingstar')hand.sensor(tracker)
import vrutThe same method can be used to control the orientation of the observer. Likewise, the same method can be used to control the position and orientation of objects in the environment.
vrut.go()vrut.addchild('tut_ground.wrl')
tracker = vrut.sensor('shootingstar')def mytimer(num):
data = tracker.get()
x = data[0]
y = data[1]
z = data[2]
vrut.translate(vrut.HEAD_POS, x, y, z)
vrut.starttimer(0)vrut.callback(vrut.TIMER_EVENT, 'mytimer')
vrut.starttimer(0, .5)