edu.d.umn.behaviors
Class FlyBehavior

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.Node
          extended by javax.media.j3d.Leaf
              extended by javax.media.j3d.Behavior
                  extended by com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
                      extended by edu.d.umn.behaviors.FlyBehavior
Direct Known Subclasses:
DEMViewerFlyBehavior

public abstract class FlyBehavior
extends com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior

FlyBehavior.java Created on July 13, 2005, 11:37 AM Basically, this is the same type of behavior available with Sun's java3d demo. It is just condensed down into one file, rather than several inheritances. Movement is as follows. Left Click - move forward and backward, turn left and right Middle Click - look up and down, and roll Right Click - change elevation, and strafe left and right


Field Summary
protected  javax.media.j3d.WakeupOr awtCondition
          Mainly the mouse and keyboard conditions to wakeup on.
protected  javax.media.j3d.WakeupOr bothCondition
          Both awtCondition and frameElapsed conditions.
protected  java.awt.Rectangle canvasBounds
          The bounds of the canvas.
protected  java.awt.geom.Point2D.Float canvasCenter
          Center of the canvas.
protected  float deadXSize
          Size of the dead zone in the center of the canvas.
protected  float deadYSize
          Size of the dead zone in the center of the canvas.
protected  boolean ignoreMouseMotion
          Field indicating whether to ignore mouse motion or not.
protected  float MAX_ANGLE
          The maximum turning angle for movement.
protected  float maxVelocity
          the maximum velocity for movement.
protected  boolean motion
          Field indicating whether the behavior is in motion or not.
protected  float pitchAngle
          Current pitch angle.
protected  javax.media.j3d.Transform3D pitchTransform
          Transform3D that controls pitch.
protected  float rollAngle
          Current roll angle.
protected  javax.media.j3d.Transform3D rollTransform
          Transform3D that controls roll.
protected  javax.media.j3d.TransformGroup targetTG
          The TransformGroup this behavior acts on.
protected  javax.media.j3d.Transform3D targetTransform
          The Transform3D component of the targetTG.
protected  javax.vecmath.Vector3f velocity
          The velocity of the behavior.
protected  javax.media.j3d.Transform3D velocityTransform
          Transform3D that controls velocity.
protected  float yawAngle
          Current angle of yaw.
protected  javax.media.j3d.Transform3D yawTransform
          Transform3D that controls yaw.
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
homeTransform, vp
 
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_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
FlyBehavior()
          Constructs a new FlyBehavior
 
Method Summary
abstract  void aerialView()
          Should change the view orientation and position to view a the target from the air.
 javax.media.j3d.TransformGroup getTarget()
          Returns the TransformGroup this behavior works on.
protected  void init()
          Setup the initial wakeup conditions for this behavior.
 void initialize()
          Applies wake conditions via a wakeupOn() call.
protected  void integrateTransforms()
          Changes yaw, pitch, roll and velocity and sets the Transform3D of targetTG to account for all of these.
 void levelOff()
          Resets the roll and pitch angles to give you a flat view of the models.
 void processAWTEvents(java.awt.AWTEvent[] events)
          If processStimulus gets an AWT event, it is passed here for processing.
protected  void processKeyEvent(java.awt.event.KeyEvent evt)
           
protected  void processMouseEvent(java.awt.event.MouseEvent evt)
          If processAWTEvents gets a mouseEvent, this method is called to deal with it.
 void processStimulus(java.util.Enumeration e)
          Process a stimulus meant for this behavior.
 void setMaxSpeed(float n)
          sets the maximum speed.
 void setTarget(javax.media.j3d.TransformGroup targetTG)
          Sets the TransformGroup that this behavior acts on.
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getHomeTransform, getViewingPlatform, goHome, setHomeTransform, setViewingPlatform
 
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, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

targetTG

protected javax.media.j3d.TransformGroup targetTG
The TransformGroup this behavior acts on.


awtCondition

protected javax.media.j3d.WakeupOr awtCondition
Mainly the mouse and keyboard conditions to wakeup on.


bothCondition

protected javax.media.j3d.WakeupOr bothCondition
Both awtCondition and frameElapsed conditions.


canvasBounds

protected java.awt.Rectangle canvasBounds
The bounds of the canvas. Used in calculating speed.


canvasCenter

protected java.awt.geom.Point2D.Float canvasCenter
Center of the canvas. The farther the mouse is away from this, the higher the speed.


targetTransform

protected javax.media.j3d.Transform3D targetTransform
The Transform3D component of the targetTG.


MAX_ANGLE

protected final float MAX_ANGLE
The maximum turning angle for movement.


maxVelocity

protected float maxVelocity
the maximum velocity for movement.


motion

protected boolean motion
Field indicating whether the behavior is in motion or not.


ignoreMouseMotion

protected boolean ignoreMouseMotion
Field indicating whether to ignore mouse motion or not.


deadXSize

protected float deadXSize
Size of the dead zone in the center of the canvas.


deadYSize

protected float deadYSize
Size of the dead zone in the center of the canvas.


velocityTransform

protected javax.media.j3d.Transform3D velocityTransform
Transform3D that controls velocity.


yawTransform

protected javax.media.j3d.Transform3D yawTransform
Transform3D that controls yaw.


rollTransform

protected javax.media.j3d.Transform3D rollTransform
Transform3D that controls roll.


pitchTransform

protected javax.media.j3d.Transform3D pitchTransform
Transform3D that controls pitch.


velocity

protected javax.vecmath.Vector3f velocity
The velocity of the behavior.


yawAngle

protected float yawAngle
Current angle of yaw. Initially zero.


pitchAngle

protected float pitchAngle
Current pitch angle. Initially zero.


rollAngle

protected float rollAngle
Current roll angle. Initially zero.

Constructor Detail

FlyBehavior

public FlyBehavior()
Constructs a new FlyBehavior

Method Detail

setTarget

public void setTarget(javax.media.j3d.TransformGroup targetTG)
Sets the TransformGroup that this behavior acts on.

Parameters:
targetTG - New TransformGroup to use.

getTarget

public javax.media.j3d.TransformGroup getTarget()
Returns the TransformGroup this behavior works on.

Returns:
The TransformGroup this behavior works on

init

protected void init()
Setup the initial wakeup conditions for this behavior. These include mouse events, key events and frame elapsed events. These conditions are not applied via a wakeupOn() call yet.


initialize

public void initialize()
Applies wake conditions via a wakeupOn() call. Initializes rollTransform, pitchTransform, yawTransform, targetTransform and velocityTransform to new Transform3D s

Specified by:
initialize in class javax.media.j3d.Behavior

processStimulus

public void processStimulus(java.util.Enumeration e)
Process a stimulus meant for this behavior. This method is invoked if the Behavior's wakeup criteria are satisfied and an active ViewPlatform's activation volume intersects with the Behavior's scheduling region. Classes that extend Behavior must provide their own processStimulus method. NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

Specified by:
processStimulus in class javax.media.j3d.Behavior
Parameters:
e - an enumeration of triggered wakeup criteria for this behavior

processAWTEvents

public void processAWTEvents(java.awt.AWTEvent[] events)
If processStimulus gets an AWT event, it is passed here for processing.

Parameters:
events - Array of events that processStimulus received.

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent evt)

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent evt)
If processAWTEvents gets a mouseEvent, this method is called to deal with it. Deals with drags, presses, and releases.

Parameters:
evt - The MouseEvent to process.

integrateTransforms

protected void integrateTransforms()
Changes yaw, pitch, roll and velocity and sets the Transform3D of targetTG to account for all of these.


levelOff

public void levelOff()
Resets the roll and pitch angles to give you a flat view of the models.


setMaxSpeed

public void setMaxSpeed(float n)
sets the maximum speed. useful to set to low quantities when dealing with smaller models.

Parameters:
n - new maximum speed. Must be greater than zero.

aerialView

public abstract void aerialView()
Should change the view orientation and position to view a the target from the air.