Vizard 8 » Reference » Viewpoints & Windows » Viewpoints » Camera handlers
8.0

Camera handlers

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.

Note: If you're using a position or orientation sensor for navigation,  link the viewpoint to the sensor to handle viewpoint navigation.

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 )

See also

In this section:

Viewpoint basics

Moving and rotating a viewpoint

Viewpoint collision and gravity

Viewpoint command table

Other sections:

Linking basics

Viewpoint and Window basics

Stereo basics

Animation path basics

Action basics

Tutorial: Viewpoint control

Tutorial: Windows & views

Example scripts:

Viewpoint camera control

Viewpoint animation