Movement Limitation
The Movement Limitation script can be found in ExampleScripts and shows how to place a proximity sensor inside of a large space that uses the head position as a target in order to not allow a user past a certain point. When the user enters the sensor they are automatically pushed back by one meter.
import sightlab_utils.sightlab as sl
from sightlab_utils.settings import *
sightlab = sl.SightLab(gui=False)
env = vizfx.addChild("sightlab_resources/example_resources/lab_collision.osgb")
env.collidePlane()
sightlab.setEnvironment(env)
transportNode = vizconnect.getTransport('main_transport').getNode3d()
import vizproximity
manager = vizproximity.Manager()
# Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)
collideBox = env.getChild('collideBox')
hallwaySensor = vizproximity.addBoundingBoxSensor(collideBox)
manager.addSensor(hallwaySensor)
manager.setDebug(viz.ON)
def pushBack(e):
print('pushed back')
newPosition = [0, 0.0, -1]
transportNode.setPosition(newPosition)
manager.onEnter(hallwaySensor,pushBack)
def sightLabExperiment():
while True:
yield viztask.waitKeyDown(' ')
yield sightlab.startTrial()
yield viztask.waitKeyDown(' ')
yield sightlab.endTrial()
viztask.schedule(sightlab.runExperiment)
viztask.schedule(sightLabExperiment)
viz.callback(viz.getEventID('ResetPosition'), sightlab.resetViewPoint)