j3d.org Code

org.j3d.renderer.java3d.navigation
Class MouseViewBehavior

java.lang.Object
  extended byjavax.media.j3d.SceneGraphObject
      extended byjavax.media.j3d.Node
          extended byjavax.media.j3d.Leaf
              extended byjavax.media.j3d.Behavior
                  extended byorg.j3d.renderer.java3d.navigation.MouseViewBehavior

public class MouseViewBehavior
extends javax.media.j3d.Behavior

A Java3D Behavior based interface to drive navigation.

The behavior looks for AWTEvents for mouse move and mouse motion. It will automatically register itself and the bounds are set to infinity so that it will always run.

To set the classes needed by the underlying navigation handler, you can either ask for the instance and set the values directly, or ask the convenience methods here. These are just pass though and do not add any extra functionality.

Version:
$Revision: 1.2 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
MouseViewBehavior()
          Create a new behavior with default settings and creates its own NavigationHandler.
MouseViewBehavior(NavigationHandler nav)
          Create a new behavior with default settings and uses the supplied NavigationHandler for dealing with the input.
 
Method Summary
 NavigationHandler getNavigationHandler()
          Get the NavigationHandler instance that this class is using.
 void initialize()
          Initialise the behavior to start running.
 void processStimulus(java.util.Enumeration why)
          Process the event that builds the current time.
 void setAvatarInfo(float height, float size, float stepHeight)
          Set the information about the avatar that is used for collisions and navigation information.
 void setButtonNavigation(int button, int state)
          Set the ability to use a given state within the handler for a specific mouse button (up to 3).
 void setCollisionListener(CollisionListener l)
          Set the listener for collision notifications.
 void setFrameUpdateListener(FrameUpdateListener l)
          Set the listener for frame update notifications.
 void setNavigationSpeed(float newSpeed)
          Set the navigation speed to the new value.
 void setNavigationStateListener(NavigationStateListener l)
          Set the listener for navigation state change notifications.
 void setViewInfo(javax.media.j3d.View view, javax.media.j3d.TransformGroup tg)
          Set the view and it's related transform group to use.
 void setWorldInfo(javax.media.j3d.BranchGroup terrainGroup, javax.media.j3d.BranchGroup worldGroup)
          Set the branchgroups to use for terrain and collision information.
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseViewBehavior

public MouseViewBehavior()
Create a new behavior with default settings and creates its own NavigationHandler.


MouseViewBehavior

public MouseViewBehavior(NavigationHandler nav)
Create a new behavior with default settings and uses the supplied NavigationHandler for dealing with the input. If the supplied reference is null it will create one itself.

Parameters:
nav - The handler for navigation to use
Method Detail

initialize

public void initialize()
Initialise the behavior to start running. This will register the first criteria. Don't wake until we have arrived in the activation area of the viewpoint and then run every frame.


processStimulus

public void processStimulus(java.util.Enumeration why)
Process the event that builds the current time.

Parameters:
why - The list of conditions why this was woken

getNavigationHandler

public NavigationHandler getNavigationHandler()
Get the NavigationHandler instance that this class is using.

Returns:
The navigation instance currently in use

setWorldInfo

public void setWorldInfo(javax.media.j3d.BranchGroup terrainGroup,
                         javax.media.j3d.BranchGroup worldGroup)
Set the branchgroups to use for terrain and collision information. The two are treated separately for the different processes. The caller may choose to make them the same reference, but the code internally treats them separately.

Note For picking purposes, the code currently assumes that both groups do not have any parent transforms. That is, their world origin is the same as the transform group presented in the view information.

Parameters:
terrainGroup - The geometry to use as terrain for following
worldGroup - The geometry to use for collisions

setAvatarInfo

public void setAvatarInfo(float height,
                          float size,
                          float stepHeight)
Set the information about the avatar that is used for collisions and navigation information.

Parameters:
height - The heigth of the avatar above the terrain
size - The distance between the avatar and collidable objects
stepHeight - The height that an avatar can step over

setNavigationSpeed

public void setNavigationSpeed(float newSpeed)
Set the navigation speed to the new value. The speed must be a non-negative number.

Parameters:
newSpeed - The new speed value to use
Throws:
java.lang.IllegalArgumentException - The value was negative

setButtonNavigation

public void setButtonNavigation(int button,
                                int state)
Set the ability to use a given state within the handler for a specific mouse button (up to 3). This allows the caller to control exactly what states are allowed to be used and with which buttons. Note that it is quite legal to set all three buttons to the same navigation state

Parameters:
button - The mouse button value from MouseEvent
state - The navigation state to use for that button

setViewInfo

public void setViewInfo(javax.media.j3d.View view,
                        javax.media.j3d.TransformGroup tg)
Set the view and it's related transform group to use. This view is what we navigation around the scene with.

Parameters:
view - is the View object that we're modifying.
tg - The transform group above the view object that should be used

setFrameUpdateListener

public void setFrameUpdateListener(FrameUpdateListener l)
Set the listener for frame update notifications. By setting a value of null it will clear the currently set instance

Parameters:
l - The listener to use for this transition

setCollisionListener

public void setCollisionListener(CollisionListener l)
Set the listener for collision notifications. By setting a value of null it will clear the currently set instance

Parameters:
l - The listener to use for updates

setNavigationStateListener

public void setNavigationStateListener(NavigationStateListener l)
Set the listener for navigation state change notifications. By setting a value of null it will clear the currently set instance

Parameters:
l - The listener to use for change updates

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org