Class FlyingPlatform

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Leaf
                    |
                    +--javax.media.j3d.Behavior
                          |
                          +--com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
                                |
                                +--com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
                                      |
                                      +--FlyingPlatform
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

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.

Author:
Mark Pendergast

Nested Class Summary
(package private)  class FlyingPlatform.SettingsDialog
          Inner class, popup dialog used to allow settings to be controlled and navigation to be done with buttons
 
Field Summary
private  java.awt.MenuItem aerialViewMenu
           
private  javax.media.j3d.Canvas3D canvas
           
private  boolean followTerrain
           
private  float HOME_X
          home X location
private static int HOME_XANGLE
          base XAxis attitude determines whether you are climbing or diving
private  float HOME_Y
          home Y location
private static int HOME_YANGLE
          base YAxis attitude determines whether you are flying east/west/north/south
private  float HOME_Z
          home Z location
private static int HOME_ZANGLE
          base ZAxis attitude determines whether you are banking left or right
private  java.awt.MenuItem homeBaseMenu
           
private static float INITIAL_TERRAIN_FOLLOW_ALTITUDE
           
private  java.awt.MenuItem levelOffMenu
           
private static float MINIMUM_ALTITUDE
           
private  ElevationModelInterface model
           
private  float moveAmt
          amount to move (in meters) on each operation
private  int oldx
           
private  int oldy
           
private  javax.vecmath.Vector3f platformVect
          holds view platform location
private  java.awt.PopupMenu popupMenu
           
private static int sensitivity
           
private  FlyingPlatform.SettingsDialog settingsDialog
           
private  java.awt.MenuItem settingsMenu
           
private  float terrainFollowAltitude
           
private  java.awt.CheckboxMenuItem terrainFollowMenu
           
private  float turnAmt
          amount to turn(in degrees) on each operation
private  float xAngle
          holds current X axis attitude
private  float yAngle
          holds current Y axis attitude
private  float zAngle
          holds current Z axis attitude
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
frameWakeup, KEY_LISTENER, motion, MOUSE_LISTENER, MOUSE_MOTION_LISTENER, POST_ID, postWakeup, targetTransform
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
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_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Fields inherited from class javax.media.j3d.SceneGraphObject
 
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)
           
 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, processStimulus, queueAWTEvent, setEnable, setViewingPlatform
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getViewingPlatform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getSchedulingBoundingLeaf, getSchedulingBounds, getView, postId, setSchedulingBoundingLeaf, setSchedulingBounds, 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, duplicateSceneGraphObject, getCapability, getUserData, isCompiled, isLive, setCapability, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOME_XANGLE

private static final int HOME_XANGLE
base XAxis attitude determines whether you are climbing or diving

See Also:
Constant Field Values

HOME_YANGLE

private static final int HOME_YANGLE
base YAxis attitude determines whether you are flying east/west/north/south

See Also:
Constant Field Values

HOME_ZANGLE

private static final int HOME_ZANGLE
base ZAxis attitude determines whether you are banking left or right

See Also:
Constant Field Values

HOME_X

private float HOME_X
home X location


HOME_Y

private float HOME_Y
home Y location


HOME_Z

private float HOME_Z
home Z location


platformVect

private javax.vecmath.Vector3f platformVect
holds view platform location


xAngle

private float xAngle
holds current X axis attitude


yAngle

private float yAngle
holds current Y axis attitude


zAngle

private float zAngle
holds current Z axis attitude


oldx

private int oldx

oldy

private int oldy

sensitivity

private static int sensitivity

moveAmt

private float moveAmt
amount to move (in meters) on each operation


turnAmt

private float turnAmt
amount to turn(in degrees) on each operation


INITIAL_TERRAIN_FOLLOW_ALTITUDE

private static float INITIAL_TERRAIN_FOLLOW_ALTITUDE

MINIMUM_ALTITUDE

private static float MINIMUM_ALTITUDE

followTerrain

private boolean followTerrain

terrainFollowAltitude

private float terrainFollowAltitude

popupMenu

private java.awt.PopupMenu popupMenu

terrainFollowMenu

private java.awt.CheckboxMenuItem terrainFollowMenu

settingsMenu

private java.awt.MenuItem settingsMenu

homeBaseMenu

private java.awt.MenuItem homeBaseMenu

levelOffMenu

private java.awt.MenuItem levelOffMenu

aerialViewMenu

private java.awt.MenuItem aerialViewMenu

model

private ElevationModelInterface model

canvas

private javax.media.j3d.Canvas3D canvas

settingsDialog

private FlyingPlatform.SettingsDialog settingsDialog
Constructor Detail

FlyingPlatform

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

Parameters:
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.


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

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)
Specified by:
processAWTEvents in class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior

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

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