Class NavigationProcessor

java.lang.Object
org.web3d.vrml.renderer.ogl.input.NavigationProcessor
All Implemented Interfaces:
org.j3d.aviatrix3d.NodeUpdateListener, OGLTransformNodeType

public class NavigationProcessor extends Object implements org.j3d.aviatrix3d.NodeUpdateListener, OGLTransformNodeType
A listener and handler responsible for executing all navigation commands from mice and keyboards to move a viewpoint around a scene.

This class does not contain any direct event handling. Instead it assumes that another class with either derive from it or delegate to it to do the actual movement processing. This allows it to be used as a standard AWT event listener. The class works like a standard VRML browser type navigation system. Press the mouse button and drag to get the viewpoint moving. The more you drag the button away from the start point, the faster the movement. The handler does not recognize the use of the Shift key as a modifier to produce an accelerated movement. This class will not change the cursor on the canvas in response to the current mouse and navigation state. It will only notify the state change listener. It is the responsibility of the listener to do this work. Separate states are allowed to be set for each button. Once one button is pressed, all the other button presses are ignored. By default, all the buttons start with no state set. The user will have to explicitly set the state for each button to get them to work.

Terrain Following

When doing terrain following, the handler will project a ray from the current viewpoint position to the ground position. It will then offset the current position by the new position that we should be going to. If the distance in the overall Y axis is less than the step height, the translation will be allowed to proceed and the height adjusted to the new value. If it is greater, then it will set the Z component to zero, allowing no forward movement. Thus, if the next translation also has a sideways component, it will simply shift sideways and not move forward. If there is no terrain under the current eye position, or the next eye position, it will not change the Y axis value at all. If you do not wish to have terrain following for all modes, then pass a null value for the terrain parameter to setWorldInfo().

Collision Detection

Collision detection is based on using a fixed point representation of the avatar - we do not have a volumetric body for it. A ray is cast in the direction that we are looking that is the length of the avatarSize plus the amount that we are due to move this next frame. If you do not wish to have collision detection for all modes, then pass a null value for the collidables parameter to setWorldInfo().

Navigation Modes NONE

All navigation is disabled. We ignore any requests from mouse or keyboard to move the viewpoint.

EXAMINE

The viewpoint is moved around the center of rotation provided by the user. There is no collision detection or terrain following in this mode. For movement input, direction is treated as the direction in the local coordinates on the surface of a sphere formed around the rotation origin. The scale represents the movement along the vector and then each component defines the proportion used to move in that direction. [0] is left/right, [1] is up/down, [2] is zoom in out where +Z is zoom out.

FLY

The user moves through the scene that moves the eyepoint in forward, reverse and side to side movements. There is collision detection, but no terrain following. For movement input the direction controls the scale of the input to translate and rotate about. [0] controls left/right rotation, [1] controls pitch and [2] controls the amount of forward movement.

WALK

The user moves through the scene with left/right options and forward reverse, but they are bound to the terrain and have collision detection. For movement input, the direction controls only two of the axes as gravity is used to constrain in the local Y axis. [0] is the amount of rotation left/right to perform each frame and [2] controls the forward/reverse movement.

PAN

The camera moves in a sliding fashion along the given axis - the local X or Z axis. There is not collision detection or terrain following. Move the viewpoint left/right/up/down while maintaining the current viewing direction. [0] is used for left/right and [1] is used for up/down. [2] is not used.

TILT

The camera rotates around the local axis in an up/down, left/right fashion. It stays anchored in the one place and does not have terrain following or collision detection. Movement input controls how the tilt is performed and is an absolute value that controls total tilt. [0] controls rotation of the camera in the X-Z plane, [1] controls rotation in the Y-Z plane.

TODO

The collision vector does not move according to the direction that we are traveling rather than the direction we are facing. Allows us to walk backwards through objects when we shouldn't. Implement Examine mode handling

This code is a direct copy and modified version of the code in the j3d.org library of the same name.
Version:
$Revision: 1.45 $
Author:
Justin Couch