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 TypeMethodDescriptionvoidAdd a listener for navigation state changes.voidAdd a listener for navigation state changes.voidclear()Clear all the values, listeners etc, except for the clock.booleanGet the currently set navigation state.voidgetOrientation(javax.vecmath.AxisAngle4f ori) Get the current user orientation.voidgetPosition(javax.vecmath.Vector3f pos) Get the current user position.voidnotifyAvatarSizeChanged(float[] size, int numValid) Notification that the avatar size has changed on the current NavigationInfo node.voidnotifyHeadlightChanged(boolean enable) Notification that headlight state has changed.voidnotifyNavigationModesChanged(String[] newModes, int numValid) Notification that the navigation modes allowed has changed on the current NavigationInfo node.voidnotifyNavigationSpeedChanged(float newSpeed) Notification that the navigation speed has changed on the current NavigationInfo node.voidnotifyVisibilityLimitChanged(float distance) Notification that the visibility limit has been changed.voidNotification that the origin has changed.voidProcess any navigation velocity.voidRemove a navigation state listener.voidRemove a navigation state listener.voidThe 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.voidsetActivateSensors(boolean val) Sets whether this tracker is eligible to active a sensor.voidsetCenterOfRotation(float[] center) Set the center of rotation explicitly to this place.voidSet the listener for collision notifications.voidsetNavigationEnabled(boolean state) Enable or disable navigation processing sub-section of the user input processing.voidSet the navigation info that is used for this scene.booleansetNavigationMode(String mode) Set the desired navigation mode.voidsetOriginManager(OriginManager manager) Set the manager for handling dynamic origin calculation.voidsetPickableScene(org.j3d.aviatrix3d.Group scene) Set the world group that we are doing the picking on.voidsetTestPointingDevices(boolean enabled) Should pointing devices be tested for.voidsetViewInfo(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.voidsetVRMLClock(VRMLClock clk) Set the clock we are going to operate from when generating events.voidsetWorldScale(float scale) Set the world scale applied.voidtrackerButton(int tracker, org.j3d.device.input.TrackerState state) Process the buttons on a tracker.voidtrackerClicked(int tracker, org.j3d.device.input.TrackerState state) Process a tracker click event.voidtrackerDragged(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event.booleanDid the last tracker interaction intersect any active sensors.voidtrackerMoved(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker moved event.voidtrackerOrientation(int tracker, org.j3d.device.input.TrackerState state) Process tracker orientation events.voidtrackerPressed(int tracker, org.j3d.device.input.TrackerState evt) Process a tracker press event.voidtrackerReleased(int tracker, org.j3d.device.input.TrackerState state) Process a tracker press event.voidtrackerWheel(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:
notifyAvatarSizeChangedin 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:
notifyVisibilityLimitChangedin interfaceNavigationInfoChangeListener- Parameters:
distance- The new distance value to use
-
notifyHeadlightChanged
public void notifyHeadlightChanged(boolean enable) Notification that headlight state has changed.- Specified by:
notifyHeadlightChangedin 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:
setPickableScenein 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:
setViewInfoin 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:
setCenterOfRotationin 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:
setVRMLClockin 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:
setCollisionListenerin interfaceOGLUserInputHandler- Parameters:
l- The listener to use for change updates
-
setTestPointingDevices
public void setTestPointingDevices(boolean enabled) Should pointing devices be tested for.- Specified by:
setTestPointingDevicesin 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:
trackerButtonin 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:
trackerPressedin 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:
trackerMovedin 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:
trackerIntersectedin 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:
setActivateSensorsin 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:
trackerDraggedin 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:
trackerWheelin 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:
trackerReleasedin 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:UserInputHandlerProcess 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:
trackerClickedin 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:
trackerOrientationin 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:
addSensorStatusListenerin 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:
removeSensorStatusListenerin interfaceUserInputHandler- Parameters:
l- The listener to remove
-
getOrientation
public void getOrientation(javax.vecmath.AxisAngle4f ori) Get the current user orientation.- Specified by:
getOrientationin interfaceUserInputHandler- Parameters:
ori- The orientation vector to fill in
-
getPosition
public void getPosition(javax.vecmath.Vector3f pos) Get the current user position.- Specified by:
getPositionin 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:
setWorldScalein 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:
clearin interfaceUserInputHandler
-
setOriginManager
Set the manager for handling dynamic origin calculation.- Specified by:
setOriginManagerin interfaceUserInputHandler- Parameters:
manager- Reference to the manager instance to use or null
-
originChanged
public void originChanged()Notification that the origin has changed.- Specified by:
originChangedin interfaceOriginListener