Vizard 7 » Reference » Input Devices » Gaming devices » 3DConnexion SpaceBall
7.6

3Dconnexion 3D mouse

This plug-in provides support for the 3Dconnexion 3D mouse line of products (SpaceNavigator, SpaceMouse, SpacePilot).

 

A full sample script can be found at \examples\devices\spaceNavigatorExample.py.

Initialization

The 3Dconnexion plug-in is implemented as a Vizard extension, with the following methods/constants:

Method Description
<connexion>.addDevice() Returns the 3Dconnextion device sensor
<connexion>.DOMINANT_TRANSLATE Dominant axis filter flag for filtering translations to axis with largest motion.
<connexion>.DOMINANT_ROTATE Dominant axis filter flag for filtering rotations to axis with largest motion.
<connexion>.DOMINANT_ALL Dominant axis filter flag for filtering translations and rotations to axis with largest motion.

The 3Dconnexion device object contains the following methods, in addition to the standard extension sensor methods:

Method Description
<device>.getRawTranslation() Get the raw instantaneous translation amount of the device [x,y,z].
<device>.getRawRotation() Get the raw instantaneous rotation amount of the device [rx,ry,rz], about each axis.
<device>.getFilteredTranslation() Get the filtered instantaneous translation amount of the device [x,y,z].
<device>.getFilteredRotation() Get the filtered instantaneous rotation amount of the device [rx,ry,rz], about each axis.

<device>.setTranslateScale(scale)

Set the [x,y,z] scale factor for translation movement. The default scale is 1.
<device>.getTranslateScale() Get the [x,y,z] scale factor for translation movement.
<device>.setRotateScale(scale) Set the [x,y,z] scale factor for rotation movement. The default scale is 1.
<device>.getRotateScale() Get the [x,y,z] scale factor for rotation movement.
<device>.setDominantAxisFilter(flags)

Set the dominant axis filter flags. Can be a combination of the following flags:

<connexion>.DOMINANT_TRANSLATE

<connexion>.DOMINANT_ROTATE

<connexion>.DOMINANT_ALL

<device>.getDominantAxisFilter() Get the dominant axis filter flags.
<device>.reset() Reset the accumulated position and orientation to zero.

The position and orientation of the 3Dconnexion device is automatically accumulated based on the raw movement and the specified translate/rotate scale factors. The device position and orientation can be manually set using the setPosition/setEuler commands.

Example

The following code shows how to use add a 3Dconnexion device and link the movement to the viewpoint:

# Add 3Dconnexion device
connexion = viz.add('3dconnexion.dle')
device = connexion.addDevice()

# Set initial device position
device.setPosition([0,2,0])

# Link device movement to viewpoint
viz.link(device, viz.MainView)

The following code shows how to limit the device rotation about the Y axis:

# Only rotate about the local Y axis
device.setRotateScale([0,1,0])

The following code shows how to use the raw translation/rotation values to manually move the viewpoint:

import vizact

MOVE_SCALE = 0.5
ROTATE_SCALE = 5.0

def UpdateMovement():
    elapsed = viz.getFrameElapsed()
    trans = device.getRawTranslation()
    rx,ry,rz = device.getRawRotation()
    viz.MainView.setAxisAngle([0,1,0,ry*elapsed*ROTATE_SCALE], viz.HEAD_ORI, viz.REL_LOCAL)
    viz.MainView.move(viz.Vector(trans)*elapsed*MOVE_SCALE)

vizact.onupdate(0, UpdateMovement)