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 play a sound.
# 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 play a sound.
#
#=====================================================================
import viz
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 walls
viz.add('tankmaze.wrl')
#Turn on collision
viz.collision(viz.ON)
#This function is called when a collision occurs
def mycollision(info):
print
'Collision'
#Create a callback for a collision event
viz.callback(viz.COLLISION_EVENT, mycollision)