collision.py
This script shows how to detect collisions between the viewer and objects
in the world.
# WorldViz Copyright 2002=============================================
#
# This script shows how to detect collisions between the
viewer and
# objects in the world. When a collision happens,
a function in our
# script is triggered where we print a message.
#
#=====================================================================
import viz
viz.setMultiSample(4)
viz.fov(60)
viz.go()
import vizinfo
vizinfo.add('This
script demonstrates how to use collision detection.\nVizard will automatically
handle collisions with the viewpoint.\nWhen the viewpoint collides with
an object, the script will print out "Collided"')
#Add the maze environment
maze = viz.addChild('maze.osgb')
#Turn on collision
viz.collision(viz.ON)
#This function is called when a collision occurs
def mycollision(info):
print 'Collided'
#Create a callback for a collision event
viz.callback(viz.COLLISION_EVENT, mycollision)