Package com.sun.j3d.utils.behaviors.vp
Class WandViewBehavior.RotationListener2D
- java.lang.Object
-
- com.sun.j3d.utils.behaviors.sensor.SensorInputAdaptor
-
- com.sun.j3d.utils.behaviors.vp.WandViewBehavior.ListenerBase
-
- com.sun.j3d.utils.behaviors.vp.WandViewBehavior.RotationListener2D
-
- All Implemented Interfaces:
SensorButtonListener
,SensorReadListener
- Enclosing class:
- WandViewBehavior
public class WandViewBehavior.RotationListener2D extends WandViewBehavior.ListenerBase
Implements a 2D valuator listener that rotates the view platform. The X and Y values from the valuator should have a continuous range from -1.0 to +1.0, although the rotation speed can be scaled to compensate for a different range. The X and Y values are found in the sensor's read matrix at the indices specified bysetMatrixIndices2D
, with defaults of 3 and 7 respectively.The rotation direction is controlled by the direction the 2D valuator is pushed, and the rotation speed is scaled by the magnitude of the 2D valuator read values.
This listener will work in conjunction with a 6DOF sensor if supplied in the constructor. If a 6DOF sensor is provided and
setRotationCoords
has been called with the valueSENSOR
, then the rotation is applied in the 6DOF sensor's coordinate system; otherwise the rotation is applied either in head coordinates or in view platform coordinates. If a 6DOF sensor is provided andsetTransformCenterSource
has been called with the valueHOTSPOT
, then rotation is about the 6DOF sensor's hotspot; otherwise, the rotation center is the value set bysetTransformCenter
.- See Also:
WandViewBehavior.setReadAction2D(int)
,WandViewBehavior.setButtonAction2D(int, int)
,WandViewBehavior.setRotationCoords(int)
,WandViewBehavior.setTransformCenterSource(int)
,WandViewBehavior.setTransformCenter(javax.vecmath.Point3d)
,WandViewBehavior.setRotationSpeed(double, int, int)
,WandViewBehavior.setThreshold2D(double)
,WandViewBehavior.setMatrixIndices2D(int, int)
-
-
Field Summary
-
Fields inherited from class com.sun.j3d.utils.behaviors.vp.WandViewBehavior.ListenerBase
sensorToTracker, sensorToVworld, trackerToVworld, viewPlatformToVworld
-
-
Constructor Summary
Constructors Constructor Description RotationListener2D(Sensor sensor2D, Sensor sensor6D)
Construct an instance of this class with the specified sensors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dragged(SensorEvent e)
This method is called with each invocation of thedispatchEvents
method ofSensorEventAgent
if any button bound to the listener is down and has not changed state since the last invocation.protected void
endAction(Sensor s)
Ends the action.protected void
initAction(Sensor s)
Initializes the listener action.void
pressed(SensorEvent e)
This method is called when a sensor's button is pressed.void
read(SensorEvent e)
This method is called each time thedispatchEvents
method ofSensorEventAgent
is called and none of a sensor's buttons have been handled by a button listener.void
released(SensorEvent e)
This method is called when a sensor's button is released.-
Methods inherited from class com.sun.j3d.utils.behaviors.vp.WandViewBehavior.ListenerBase
conditionViewScale, getPhysicalToViewPlatformScale, getPhysicalToVirtualScale, isActive, transformAboutCenter, translateTransform
-
Methods inherited from class com.sun.j3d.utils.behaviors.sensor.SensorInputAdaptor
clicked
-
-
-
-
Constructor Detail
-
RotationListener2D
public RotationListener2D(Sensor sensor2D, Sensor sensor6D)
Construct an instance of this class with the specified sensors.- Parameters:
sensor2D
- the 2D valuator whose X and Y values drive the rotationsensor6D
- the 6DOF sensor to use if the rotation coordinate system is set toSENSOR
or the rotation center source isHOTSPOT
; may benull
-
-
Method Detail
-
initAction
protected void initAction(Sensor s)
Description copied from class:WandViewBehavior.ListenerBase
Initializes the listener action. Subclasses must call this before starting the action, either frompressed
or when a 2D valuator exits the deadzone threshold.- Overrides:
initAction
in classWandViewBehavior.ListenerBase
- Parameters:
s
- reference to a 6DOF sensor if used by the listener; may benull
-
endAction
protected void endAction(Sensor s)
Description copied from class:WandViewBehavior.ListenerBase
Ends the action. Subclasses must be call this fromreleased
or when a 2D valuator enters the deadzone threshold.- Overrides:
endAction
in classWandViewBehavior.ListenerBase
- Parameters:
s
- reference to a 6DOF sensor if used by the listener; may benull
-
read
public void read(SensorEvent e)
Description copied from interface:SensorReadListener
This method is called each time thedispatchEvents
method ofSensorEventAgent
is called and none of a sensor's buttons have been handled by a button listener. The sensor read value has not necessarily changed since the last read event.- Specified by:
read
in interfaceSensorReadListener
- Overrides:
read
in classSensorInputAdaptor
- Parameters:
e
- the sensor event
-
pressed
public void pressed(SensorEvent e)
Description copied from interface:SensorButtonListener
This method is called when a sensor's button is pressed.- Specified by:
pressed
in interfaceSensorButtonListener
- Overrides:
pressed
in classWandViewBehavior.ListenerBase
- Parameters:
e
- the sensor event
-
released
public void released(SensorEvent e)
Description copied from interface:SensorButtonListener
This method is called when a sensor's button is released.- Specified by:
released
in interfaceSensorButtonListener
- Overrides:
released
in classWandViewBehavior.ListenerBase
- Parameters:
e
- the sensor event
-
dragged
public void dragged(SensorEvent e)
Description copied from interface:SensorButtonListener
This method is called with each invocation of thedispatchEvents
method ofSensorEventAgent
if any button bound to the listener is down and has not changed state since the last invocation. The sensor value has not necessarily changed from the last drag event.- Specified by:
dragged
in interfaceSensorButtonListener
- Overrides:
dragged
in classSensorInputAdaptor
- Parameters:
e
- the sensor event
-
-