Class DefaultUserInputHandler
java.lang.Object
org.web3d.vrml.renderer.ogl.input.DefaultUserInputHandler
- All Implemented Interfaces:
NavigationInfoChangeListener
,OGLUserInputHandler
,OriginListener
,UserInputHandler
public class DefaultUserInputHandler
extends Object
implements OGLUserInputHandler, NavigationInfoChangeListener
A complete handler for all user input information within a scene.
The handler takes care of all the handling needed for sensors, anchors, navigation and keyboard. However, it does not define a way of sourcing those events as it assumes that a user will either delegate or extend this class with more specific information such as an AWT listener or Java3D behavior.
The current key handling does not allow keyboard navigation of the world. It passes all key events directly through to the current key sensor if one is registered.
- Version:
- $Revision: 1.52 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of this class so that we can process events and send them into the VRML scene. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for navigation state changes.void
Add a listener for navigation state changes.void
clear()
Clear all the values, listeners etc, except for the clock.boolean
Get the currently set navigation state.void
getOrientation
(javax.vecmath.AxisAngle4f ori) Get the current user orientation.void
getPosition
(javax.vecmath.Vector3f pos) Get the current user position.void
notifyAvatarSizeChanged
(float[] size, int numValid) Notification that the avatar size has changed on the current NavigationInfo node.void
notifyHeadlightChanged
(boolean enable) Notification that headlight state has changed.void
notifyNavigationModesChanged
(String[] newModes, int numValid) Notification that the navigation modes allowed has changed on the current NavigationInfo node.void
notifyNavigationSpeedChanged
(float newSpeed) Notification that the navigation speed has changed on the current NavigationInfo node.void
notifyVisibilityLimitChanged
(float distance) Notification that the visibility limit has been changed.void
Notification that the origin has changed.void
Process any navigation velocity.void
Remove a navigation state listener.void
Remove a navigation state listener.void
The layer that contains this handler has just been made the active navigation layer, so send out to the navigation state listeners the current navigation state for this layer.void
setActivateSensors
(boolean val) Sets whether this tracker is eligible to active a sensor.void
setCenterOfRotation
(float[] center) Set the center of rotation explicitly to this place.void
Set the listener for collision notifications.void
setNavigationEnabled
(boolean state) Enable or disable navigation processing sub-section of the user input processing.void
Set the navigation info that is used for this scene.boolean
setNavigationMode
(String mode) Set the desired navigation mode.void
setOriginManager
(OriginManager manager) Set the manager for handling dynamic origin calculation.void
setPickableScene
(org.j3d.aviatrix3d.Group scene) Set the world group that we are doing the picking on.void
setTestPointingDevices
(boolean enabled) Should pointing devices be tested for.void
setViewInfo
(OGLViewpointNodeType vp, org.j3d.aviatrix3d.TransformGroup tg, org.j3d.aviatrix3d.SceneGraphPath path) Set the view and it's related transform group to use and the path to get there from the root of the scene.void
setVRMLClock
(VRMLClock clk) Set the clock we are going to operate from when generating events.void
setWorldScale
(float scale) Set the world scale applied.void
trackerButton
(int tracker, org.j3d.device.input.TrackerState state) Process the buttons on a tracker.void
trackerClicked
(int tracker, org.j3d.device.input.TrackerState state) Process a tracker click event.void
trackerDragged
(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event.boolean
Did the last tracker interaction intersect any active sensors.void
trackerMoved
(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker moved event.void
trackerOrientation
(int tracker, org.j3d.device.input.TrackerState state) Process tracker orientation events.void
trackerPressed
(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker press event.void
trackerReleased
(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event.void
trackerWheel
(int tracker, org.j3d.device.input.TrackerState state) Process a tracker wheel event.
-
Constructor Details
-
DefaultUserInputHandler
public DefaultUserInputHandler()Create a new instance of this class so that we can process events and send them into the VRML scene. The initial state is set to none.
-
-
Method Details
-
notifyAvatarSizeChanged
public void notifyAvatarSizeChanged(float[] size, int numValid) Notification that the avatar size has changed on the current NavigationInfo node.- Specified by:
notifyAvatarSizeChanged
in interfaceNavigationInfoChangeListener
- Parameters:
size
- The size parameters for the avatarnumValid
- number of valid modes in array
-
notifyVisibilityLimitChanged
public void notifyVisibilityLimitChanged(float distance) Notification that the visibility limit has been changed.- Specified by:
notifyVisibilityLimitChanged
in interfaceNavigationInfoChangeListener
- Parameters:
distance
- The new distance value to use
-
notifyHeadlightChanged
public void notifyHeadlightChanged(boolean enable) Notification that headlight state has changed.- Specified by:
notifyHeadlightChanged
in interfaceNavigationInfoChangeListener
- Parameters:
enable
- true if the headlight should now be on
-
setPickableScene
public void setPickableScene(org.j3d.aviatrix3d.Group scene) Set the world group that we are doing the picking on. This allows us to look for the picked items in the scene. A null value is used to clear the world and disable picking behaviours.- Specified by:
setPickableScene
in interfaceOGLUserInputHandler
- Parameters:
scene
- The scene to pick against
-
setViewInfo
public void setViewInfo(OGLViewpointNodeType vp, org.j3d.aviatrix3d.TransformGroup tg, org.j3d.aviatrix3d.SceneGraphPath path) throws IllegalArgumentException Set the view and it's related transform group to use and the path to get there from the root of the scene. The transform group must allow for reading the local to Vworld coordinates so that we can accurately implement terrain following. A null value for the path is permitted.This will also automatically set the center of rotation.
- Specified by:
setViewInfo
in interfaceOGLUserInputHandler
- Parameters:
vp
- The current viewpointtg
- The transform just about the viewpoint used to move it around in response to the UI device inputpath
- The path from the root to the transform to use- Throws:
IllegalArgumentException
- The terminal node is not a viewpoint
-
setCenterOfRotation
public void setCenterOfRotation(float[] center) Set the center of rotation explicitly to this place. Coordinates must be in the coordinate space of the current view transform group. The provided array must be of least length 3. Center of rotation is used in examine mode.- Specified by:
setCenterOfRotation
in interfaceUserInputHandler
- Parameters:
center
- The new center to use
-
setVRMLClock
Set the clock we are going to operate from when generating events. A null value will remove the clock.- Specified by:
setVRMLClock
in interfaceUserInputHandler
- Parameters:
clk
- The new clock to use
-
setCollisionListener
Set the listener for collision notifications. By setting a value of null it will clear the currently set instance- Specified by:
setCollisionListener
in interfaceOGLUserInputHandler
- Parameters:
l
- The listener to use for change updates
-
setTestPointingDevices
public void setTestPointingDevices(boolean enabled) Should pointing devices be tested for.- Specified by:
setTestPointingDevices
in interfaceUserInputHandler
- Parameters:
enabled
- Test for intersection when true
-
trackerButton
public void trackerButton(int tracker, org.j3d.device.input.TrackerState state) Process the buttons on a tracker. No other state will be read.- Specified by:
trackerButton
in interfaceUserInputHandler
- Parameters:
tracker
- The tracker generating the event.state
- The current state.
-
trackerPressed
public void trackerPressed(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker press event. This may be used to start a TouchSensor start of a drag sensor or navigation- Specified by:
trackerPressed
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker calling this handlerevt
- The event that caused the method to be called
-
trackerMoved
public void trackerMoved(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker moved event.- Specified by:
trackerMoved
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker calling this handlerevt
- The event that caused the method to be called
-
trackerIntersected
public boolean trackerIntersected()Did the last tracker interaction intersect any active sensors.- Specified by:
trackerIntersected
in interfaceUserInputHandler
- Returns:
- true if the tracker intersection an active sensor.
-
setActivateSensors
public void setActivateSensors(boolean val) Sets whether this tracker is eligible to active a sensor.- Specified by:
setActivateSensors
in interfaceUserInputHandler
- Parameters:
val
- Whether its eligible
-
trackerDragged
public void trackerDragged(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event. This may be used to start a touchtracker, start of a drag tracker or navigation- Specified by:
trackerDragged
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker that was releasedstate
- The state of the tracker right now
-
trackerWheel
public void trackerWheel(int tracker, org.j3d.device.input.TrackerState state) Process a tracker wheel event.- Specified by:
trackerWheel
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker calling this handlerstate
- The current state.
-
trackerReleased
public void trackerReleased(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event. This may be used to start a touchtracker, start of a drag tracker or navigation- Specified by:
trackerReleased
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker that was releasedstate
- The state of the tracker right now
-
trackerClicked
public void trackerClicked(int tracker, org.j3d.device.input.TrackerState state) Description copied from interface:UserInputHandler
Process a tracker click event. The click is used only on touch trackers and anchors. We treat it like a cross between a select and unselect.- Specified by:
trackerClicked
in interfaceUserInputHandler
- Parameters:
tracker
- The id of the tracker calling this handlerstate
- The event that caused the method to be called
-
trackerOrientation
public void trackerOrientation(int tracker, org.j3d.device.input.TrackerState state) Process tracker orientation events.- Specified by:
trackerOrientation
in interfaceUserInputHandler
- Parameters:
tracker
- Which tracker sourced the eventstate
- The current state
-
addSensorStatusListener
Add a listener for navigation state changes. A listener can only be added once. Duplicate requests are ignored.- Specified by:
addSensorStatusListener
in interfaceUserInputHandler
- Parameters:
l
- The listener to add
-
removeSensorStatusListener
Remove a navigation state listener. If the reference is null or not known, the request is silently ignored.- Specified by:
removeSensorStatusListener
in interfaceUserInputHandler
- Parameters:
l
- The listener to remove
-
getOrientation
public void getOrientation(javax.vecmath.AxisAngle4f ori) Get the current user orientation.- Specified by:
getOrientation
in interfaceUserInputHandler
- Parameters:
ori
- The orientation vector to fill in
-
getPosition
public void getPosition(javax.vecmath.Vector3f pos) Get the current user position.- Specified by:
getPosition
in interfaceUserInputHandler
- Parameters:
pos
- The position vector to fill in
-
setWorldScale
public void setWorldScale(float scale) Set the world scale applied. This will scale down navinfo parameters to fit into the world.- Specified by:
setWorldScale
in interfaceUserInputHandler
- Parameters:
scale
- The new world scale.
-
clear
public void clear()Clear all the values, listeners etc, except for the clock. Returns the input handler back to being empty, with no state set.- Specified by:
clear
in interfaceUserInputHandler
-
setOriginManager
Set the manager for handling dynamic origin calculation.- Specified by:
setOriginManager
in interfaceUserInputHandler
- Parameters:
manager
- Reference to the manager instance to use or null
-
originChanged
public void originChanged()Notification that the origin has changed.- Specified by:
originChanged
in interfaceOriginListener