edu.d.umn.behaviors
Class FlyingPlatform

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 com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
                          extended by edu.d.umn.behaviors.FlyingPlatform
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

public class FlyingPlatform
extends com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
implements java.awt.event.ItemListener, java.awt.event.ActionListener

This class is a specialization of ViewPlatformAWTBehavior. Its purpose is to provide control to the ViewPlatform using three mechanisms, keyboard, mouse, and popupmenu with control dialog.


Field Summary
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
canvases, frameWakeup, KEY_LISTENER, motion, MOUSE_LISTENER, MOUSE_MOTION_LISTENER, MOUSE_WHEEL_LISTENER, POST_ID, postWakeup, targetTransform
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
homeTransform, targetTG, 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
FlyingPlatform(javax.media.j3d.Canvas3D aCanvas, ElevationModelInterface aModel)
          Create the flying platform
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          process popup menu input
 void aerialView()
          Moves the viewplatform to give an aerial view of the terrain and turns off terrain following.
 float getRotateAmount()
          returns the rotation amount
 float getStepSize()
          returns the setsize
 void goHome()
          Moves the viewplatform to the default home position and turns off terrain following.
 void increaseXRotate(float amt)
          Increase the X axis rotation.
 void increaseY(float amt)
          Increase the Y location.
 void increaseYRotate(float amt)
          Increase the Y axis rotation.
 void increaseZRotate(float amt)
          Increase the Z axis rotation.
protected  void integrateTransforms()
          reset the viewplatform transformation based on the x,y,z rotation and location information.
 void itemStateChanged(java.awt.event.ItemEvent e)
          processes the terrain following checkmenu item.
 void keyPressed(java.awt.event.KeyEvent e)
          process keyboard input up arrow - move forward down arrow - move backward left arrow - turn left right arrow - turn right U, u - increase altitude D, d - decrease altitude
 void levelOff()
          Cause the viewplatform to return to level flight, x, z angles all set to 0
 void mouseClicked(java.awt.event.MouseEvent e)
          process mouse clicked event, check if it is the right button, if so, bring up the popup menu.
 void mouseDragged(java.awt.event.MouseEvent e)
          process mouseDragged event.
 void mouseMoved(java.awt.event.MouseEvent e)
          process mouse moved event, just reset old mouse locations
 void moveForward(float amt)
          move the viewplatform forward by desired number of meters forward implies in the direction that it is currently pointed.
protected  void processAWTEvents(java.awt.AWTEvent[] events)
          If processStimulus gets an AWT event, it is passed here for processing.
 void setRotateAmt(float amt)
          updates the amount of rotation (in degrees) that the platform is rotated with each mouse move/arrow key event
 void setStepSize(float amt)
          updates the amount of space (in meters) that the platform is advanced with each mouse move/arrow key event
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
initialize, keyReleased, keyTyped, mouseEntered, mouseExited, mousePressed, mouseReleased, mouseWheelMoved, processStimulus, queueAWTEvent, setEnable, setListenerFlags, setViewingPlatform
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getHomeTransform, getViewingPlatform, setHomeTransform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, 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
 

Constructor Detail

FlyingPlatform

public FlyingPlatform(javax.media.j3d.Canvas3D aCanvas,
                      ElevationModelInterface aModel)
Create the flying platform

Parameters:
aModel - ElevationModel this platform flies over.
aCanvas - Canvas3D object that is used to display the world
Method Detail

integrateTransforms

protected void integrateTransforms()
reset the viewplatform transformation based on the x,y,z rotation and location information.

Specified by:
integrateTransforms in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
process popup menu input

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent object

levelOff

public void levelOff()
Cause the viewplatform to return to level flight, x, z angles all set to 0


goHome

public void goHome()
Moves the viewplatform to the default home position and turns off terrain following.

Overrides:
goHome in class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior

aerialView

public void aerialView()
Moves the viewplatform to give an aerial view of the terrain and turns off terrain following.


itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
processes the terrain following checkmenu item. Turns on/off terrain following. When terrain following is turned on, the platform is set to level flight and altitude set to a default elevation above the scene

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
e - The ItemEvent to process.

setStepSize

public void setStepSize(float amt)
updates the amount of space (in meters) that the platform is advanced with each mouse move/arrow key event

Parameters:
amt - number of meters to move with each operation

getStepSize

public float getStepSize()
returns the setsize

Returns:
moveAmt in meters

setRotateAmt

public void setRotateAmt(float amt)
updates the amount of rotation (in degrees) that the platform is rotated with each mouse move/arrow key event

Parameters:
amt - number of degrees to rotate with each operation

getRotateAmount

public float getRotateAmount()
returns the rotation amount

Returns:
turnAmt

processAWTEvents

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

Specified by:
processAWTEvents in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
Parameters:
events - Array of events that processStimulus received.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
process keyboard input up arrow - move forward down arrow - move backward left arrow - turn left right arrow - turn right U, u - increase altitude D, d - decrease altitude

Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
Parameters:
e - keyboard event

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
process mouse clicked event, check if it is the right button, if so, bring up the popup menu.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
Parameters:
e - mouse event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
process mouse moved event, just reset old mouse locations

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
Parameters:
e - mouse event

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
process mouseDragged event. determine which buttons are down and move the view platform accordingly. left button down, mouse moved up - go forward left button down, mouse moved down - go backward left button down, mouse moved right - turn right left button down, mouse moved left - turn left right button down, mouse moved up - increase altitude right button down, mouse moved down - decrease altitude right button down, mouse moved left - bank left right button down, mouse moved right - bank right both buttons down, move up - climb both buttons down, move down - dive

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
Parameters:
e - The event to process.

moveForward

public void moveForward(float amt)
move the viewplatform forward by desired number of meters forward implies in the direction that it is currently pointed. if terrain following is enabled, then keep the altitude a steady amount above the ground.

Parameters:
amt - number of meters to move forward

increaseYRotate

public void increaseYRotate(float amt)
Increase the Y axis rotation. This effects the heading of the platform value is clamped to 0-359.

Parameters:
amt - number of degrees to change the heading

increaseXRotate

public void increaseXRotate(float amt)
Increase the X axis rotation. This effects the pitch (nose up/down) of the platform value is clamped to -360 to 360.

Parameters:
amt - number of degrees to change the pitch

increaseZRotate

public void increaseZRotate(float amt)
Increase the Z axis rotation. This effects the bank/roll of the platform value is clamped to -360-360.

Parameters:
amt - number of degrees to change the bank

increaseY

public void increaseY(float amt)
Increase the Y location. This effects the altitude of the platform.

Parameters:
amt - number of degrees to change the altitude