Mouse navigation is the default in Vizard worlds, but you can also define your own methods of to move the main viewpoint. Vizard camera handlers provide a framework for controlling the navigational interface and behavior.
Camera handlers work by creating a class that inherits from CameraHandler. This new class will override Vizard's standard CameraHandler callback methods (such as _camKeyDown ( self, e ), _camMouseMove( self, e ), and _camUpdate( self, e ). To kick you camera handler class into gear, call viz.cam.setHandler(<your class>).
#Create custom camera handler
class MyCameraHandler( viz.CameraHandler ):
def
_camMouseDown( self, e ):
if e.button == viz.MOUSEBUTTON_LEFT:
#move
view down
e.view.move( 0, -1, 0 )
elif e.button == viz.MOUSEBUTTON_RIGHT:
#move
view up
e.view.move( 0, 1, 0 )
#Set camera handler
viz.cam.setHandler( MyCameraHandler() )
#Remove camera handler on spacebar (will revert to built-in
camera handler)
vizact.onkeydown( ' ', viz.cam.setHandler, None )
Moving and rotating a viewpoint
Viewpoint collision and gravity