Vizard 8 » Reference » Viewpoints & Windows » Viewpoints » vizcam
8.1

vizcam

Camera handlers determine the navigation style used in Vizard (when the viewpoint is not linked to a sensor) . The vizcam library includes a number of handlers you can use in additional to the default mouse handler.

 

vizcam.PivotNavigate: Creates a pivot point that the view can rotate around using the mouse. This allows for viewing whatever is located at the pivot point from all angles.

 

vizcam.PanoramaNavigate: Creates an anchor point that the view can rotate around using the mouse. This keeps the viewer in one place and allows for a 360 degree view of the scene.

 

vizcam.FlyNavigate: Uses the mouse for orientation and keyboard for position.

 

vizcam.WalkNavigate: Uses the mouse for orientation and keyboard for position. The viewpoint height is fixed.

 

vizcam.KeyboardCamera:Uses the keyboard for 6DOF navigation.

 

vizcam.KeyboardPosCamera: Uses the keyboard for 3DOF positional movement.

 

vizcam.KeyboardOriCamera: Uses the keyboard for 3DOF rotational movement.

 

vizcam.DefaultNavigate: Uses standard mouse navigation described in the Mouse Control Navigation page.

Setting a vizcam handler

All the commands described in the sections below will return a camera handler object and automatically set it to be the current handler. If you don't want your handler to be automatically registered set the vizcam.AUTO_REGISTER variable to 0. Then when you're ready to register the handler use the viz.cam.setHandler command:

import vizcam
vizcam.AUTO_REGISTER = 0

flyNav = vizcam.FlyNavigate()
.
.
.
viz.cam.setHandler(flyNav)

PivotNavigate

The command below creates a PivotNavigate camera handler. To rotate the view around the center point, drag with the left mouse button. To pan the view and change the center, drag with the right mouse button:

Command

Description

vizcam.PivotNavigate(center=[0,0,0],

                             distance=2,

                             sensitivity=[1.0,1.0])

Creates a camera handler that rotates the view around a pivot point.

 

center: Sets the initial pivot point.

distance: The viewpoint's distance from the center.

sensitivity: Sets the rotate and pan movement scales.

import viz
import vizcam

viz.go()

court = viz.addChild('piazza.osgb')
avatar = viz.addAvatar('vcc_male.cfg')

pivotNav = vizcam.PivotNavigate(center=[0,1,0])

PanoramaNavigate

The following command creates a PanoramaNavigate camera handler. Drag with the left mouse button to get a panoramic view of the scene:

Command

Description

vizcam.PanoramaNavigate(sensitivity=1.0)

Creates a camera handler that gives a 360 degree view of the scene.

 

sensitivity: Sets the panning scale of the camera.

import viz
import vizcam

viz.go()

gallery = viz.addChild('gallery.osgb')

panoramaNav = vizcam.PanoramaNavigate()

FlyNavigate

The following command creates a FlyNavigate camera handler. Use the mouse for orientation and keyboard for position:

Command

Description

vizcam.FlyNavigate(forward=viz.KEY_UP,

                           backward=viz.KEY_DOWN,

                           left=viz.KEY_LEFT,

                           right=viz.KEY_RIGHT,

                           up=viz.KEY_PAGE_UP,

                           down=viz.KEY_PAGE_DOWN)

Creates a camera handler with mouse and keyboard controls. By default, the arrow and Page Up/Down keys are used for position.

import viz
import vizcam

viz.go()

gallery = viz.addChild('gallery.osgb')

flyNav = vizcam.FlyNavigate()

WalkNavigate

The following command creates a WalkNavigate camera handler. Use the mouse for orientation and keyboard for position. This functions like the FlyNavigate handler with a fixed viewpoint height.

Command

Description

vizcam.WalkNavigate(forward='w',

                             backward='s',

                             left='a',

                             right='d',

                             moveScale=1.0,

                             turnScale=1.0)

Creates a camera handler with mouse and keyboard controls.

import viz
import vizcam

viz.go()

gallery = viz.addChild('gallery.osgb')

walkNav = vizcam.WalkNavigate()

KeyboardCamera

The following command creates a KeyboardCamera handler:

Command

Description

vizcam.KeyboardCamera(forward='w',

                                 backward='s',

                                 left='q',

                                 right='e',

                                 up='r',

                                 down='f',

                                 turnRight='d',

                                 turnLeft='a',

                                 pitchDown='h',

                                 pitchUp='y',

                                 rollRight='j',

                                 rollLeft='g',

                                 moveMode=viz.REL_LOCAL,

                                 moveScale=1.0,

                                 turnScale=1.0)

Creates a camera handler that uses the keyboard for 6DOF navigation. Movement can be constrained by passing in a value of None for one or more key arguments (e.g. passing in backward = None will prevent backward movement).  

 

moveMode: Specifies the coordinate system to move in relation to. Possible options are  viz.REL_LOCAL and viz.REL_GLOBAL. When using the local coordinate system the view orientation determines the direction of the movement.

moveScale: Sets the movement scale.

turnScale: Sets the turn scale.

import viz
import vizcam

viz.go()

court = viz.addChild('piazza.osgb')

keyCam = vizcam.KeyboardCamera()

KeyboardPosCamera

The following command creates a KeyboardPosCamera handler:

Command

Description

vizcam.KeyboardPosCamera(forward='w',

                                      backward='s',

                                      left='a',

                                      right='d',

                                      up='r',

                                      down='f',

                                      moveScale=1.0)

Creates a camera handler that uses the keyboard for 3DOF positional movement. Movement can be constrained by passing in a value of None for one or more key arguments (e.g. passing in backward = None will prevent backward movement).  

 

moveScale: Sets the movement scale.

import viz
import vizcam

viz.go()

court = viz.addChild('piazza.osgb')

posCam = vizcam.KeyboardPosCamera()

KeyboardOriCamera

The following command creates a KeyboardOriCamera handler:

Command

Description

vizcam.KeyboardOriCamera(turnLeft='a',

                                     turnRight='d',

                                     pitchDown='s',

                                     pitchUp='w',

                                     rollRight='e',

                                     rollLeft='q',

                                     turnScale=1.0)

Creates a camera handler that uses the keyboard for 3DOF orientation movement. Movement can be constrained by passing in a value of None for one or more key arguments (e.g. passing in pitchUp= None will prevent pitching upward).  

 

turnScale: Sets the turn scale.

import viz
import vizcam

viz.go()

court = viz.addChild('piazza.osgb')

oriCam = vizcam.KeyboardOriCamera()

DefaultNavigate

To revert to standard mouse navigation either set the camera handler to None:

viz.cam.setHandler(None)

 or to DefaultNavigate:

defaultNav = vizcam.DefaultNavigate()
viz.cam.setHandler(defaultNav)