Class FlyPathBehavior_WM

java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.flythroughview.FlyPathBehavior_WM
All Implemented Interfaces:
KeyListener, EventListener

public class FlyPathBehavior_WM extends Object implements KeyListener
Behavior which allows for flying down a specified path and looking around.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Branch information.
    static interface 
    Instances which want to be notified of updates to this behavior should implement this interface by providing the viewChanged method implementation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) long
    current and previous key press time.
    static final int
    on a viewChanged event change both the view position and direction vector
    static final int
    on a viewChanged event change the fly path branch
    static final int
    on a viewChanged event change just the view position
    static final int
    on a viewChanged event change just the view direction
    static final int
    on a viewChanged event change just the view orientation
    When a branch point along the current branch is reached, this array is filled with the possible BranchState instances that the user can select from for following.
    Identifies the current state of traversing the current branch.
    private boolean
    When a branch point along the current branch is reached, this flag is set until the user selects a branch to follow.
    float
    How far ahead down the path should the view be aimed.
    float
    What is the increment in distance along the path that each step takes.
    private int
    Current annotation in the list.
    private int
    Index of the closest branch at a fork in the path.
    Keep reference to instance which describes the annotation points.
    Current branch state of traversing the fly path.
    Instance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.
    Keep reference to instance which describes the path.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Current view direction along the path.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Current view position along the path.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Current view up vector.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    The desired view up vector is a normalized average of these two orthogonal axes vectors.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    For calculating the view up vector.
    Parent frame references.
    (package private) long
    current and previous key press time.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FlyPathBehavior_WM(FlyPathGraphCurve kFlyPathGraph, FlyPathAnnotateList_WM kAnnotateList, FlyThroughRender _parentScene)
    Setup to fly along the specified path and look around.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    One round trip path walk through.
    private static void
    Sound a beep.
    private float
    clampNormalizedPathDistance(float fDistance)
    Clamp the input normalized path distance to the range [0,1].
    private void
    doPathStep(int iNumSteps)
    Take the specified number of steps along the current path using the current path step size.
    WildMagic.LibFoundation.Curves.Curve3f
    Access the curve in the path graph currently positioned along.
    float
    Access the normalized distance traveled from the end of the current branch path.
    float
    Access the normalized distance traveled from the beginning of the current branch path.
    int
    Access the index of the curve in the path graph currrently positioned along.
    Get the current state of traversing.
    float
    Get the current distance ahead for looking down the path.
    float
    Get the normalized distance along the current path.
    float
    Get the current position distance along the path.
    float
    Get the current distance along the path.
    float
    Get the total length of the current path.
    float
    Get the current distance increment for moving along the path.
    int
    Access the index of the currently selected branch at a branch point.
    WildMagic.LibFoundation.Mathematics.Vector3f
    Returns the view direction vector at the current position on the path.
    WildMagic.LibFoundation.Mathematics.Vector3f
    Returns the current position on the path.
    WildMagic.LibFoundation.Mathematics.Vector3f
    Returns the view up vector at the current position on the path.
    boolean
    Get indication of whether the movement along the current path is in the forward or reverse direction.
    void
    Handle the key pressed event from the text field.
    void
     
    void
     
    void
    move(String command)
    Call from the JPanelFlythruMove.
    void
    moveAlongPath(int _step)
    Move along the path step width.
    private void
    notifyCallback(int iEvent)
    Call the implementation of the callback's notification method, if a callback instance has been defined.
    private void
    setBranch(int iBranch)
    Make the specified branch be the current state for following.
    private void
    Make the specified branch be the current state for following.
    void
    setBranch(Object _kBranchState)
    Make the specified branch be the current state for following.
    private void
    Loop through all of the possible branch choices and select the one that is the closest to the current view direction vector.
    private void
    Set the annotation point along the path.
    private void
    Reset the view orientation transformation to the identity.
    private void
    setPathDist(float fNormalizedDist)
    Update the camera position along the path based on the specified distance from the beginning.
    private void
    setupBranchChoices(int iBranchParent, int iBranchPoint)
    Create the array of branch choices and set the mode which forces the user to select from among the branch choices.
    void
    Identify the instance which implements the Callback interface.
    private void
    setView(WildMagic.LibFoundation.Mathematics.Vector3f kViewPoint, WildMagic.LibFoundation.Mathematics.Vector3f kViewdirVector)
    Set the camera to the specified be located at the specified view point and looking in the specified direction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EVENT_CHANGE_ALL

      public static final int EVENT_CHANGE_ALL
      on a viewChanged event change both the view position and direction vector
      See Also:
    • EVENT_CHANGE_POSITION

      public static final int EVENT_CHANGE_POSITION
      on a viewChanged event change just the view position
      See Also:
    • EVENT_CHANGE_VIEW

      public static final int EVENT_CHANGE_VIEW
      on a viewChanged event change just the view direction
      See Also:
    • EVENT_RESET_ORIENTATION

      public static final int EVENT_RESET_ORIENTATION
      on a viewChanged event change just the view orientation
      See Also:
    • EVENT_CHANGE_BRANCH

      public static final int EVENT_CHANGE_BRANCH
      on a viewChanged event change the fly path branch
      See Also:
    • currEventTime

      long currEventTime
      current and previous key press time.
    • prevEventTime

      long prevEventTime
      current and previous key press time.
    • m_fGazeDist

      public float m_fGazeDist
      How far ahead down the path should the view be aimed. If zero, then the view direction is the tangent to the curve. If positive, the the view direction is to look at that point along the path.
    • m_fPathStep

      public float m_fPathStep
      What is the increment in distance along the path that each step takes. Increment may be negative indicating that the path is being followed in the opposite direction.
    • m_akBranchChoice

      private FlyPathBehavior_WM.BranchState[] m_akBranchChoice
      When a branch point along the current branch is reached, this array is filled with the possible BranchState instances that the user can select from for following. Once movement is made along one of those selected from the list, then this list is cleared. An index is maintained to indicate which branch in the list is currently selected.
    • m_akBranchState

      private FlyPathBehavior_WM.BranchState[] m_akBranchState
      Identifies the current state of traversing the current branch.
    • m_bChooseBranch

      private boolean m_bChooseBranch
      When a branch point along the current branch is reached, this flag is set until the user selects a branch to follow.
    • m_iAnnotateListItemSelected

      private int m_iAnnotateListItemSelected
      Current annotation in the list.
    • m_iBranchChoiceIndex

      private int m_iBranchChoiceIndex
      Index of the closest branch at a fork in the path.
    • m_kAnnotateList

      private FlyPathAnnotateList_WM m_kAnnotateList
      Keep reference to instance which describes the annotation points.
    • m_kBranchState

      private FlyPathBehavior_WM.BranchState m_kBranchState
      Current branch state of traversing the fly path.
    • m_kCallback

      private FlyPathBehavior_WM.Callback m_kCallback
      Instance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.
    • m_kFlyPathGraph

      private FlyPathGraphCurve m_kFlyPathGraph
      Keep reference to instance which describes the path.
    • m_kViewup1

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup1
      The desired view up vector is a normalized average of these two orthogonal axes vectors. The problem is that if just one desired view up vector is chosen, then when the view direction vector is "aligned" with that vector, some other view up vector would have to be chosen and some rule would have to be defined for that.
    • m_kViewup2

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup2
      For calculating the view up vector.
    • parentScene

      private FlyThroughRender parentScene
      Parent frame references.
    • m_kViewPoint

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewPoint
      Current view position along the path.
    • m_kViewDirection

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewDirection
      Current view direction along the path.
    • m_kViewUp

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewUp
      Current view up vector.
  • Constructor Details

    • FlyPathBehavior_WM

      public FlyPathBehavior_WM(FlyPathGraphCurve kFlyPathGraph, FlyPathAnnotateList_WM kAnnotateList, FlyThroughRender _parentScene)
      Setup to fly along the specified path and look around.
      Parameters:
      kFlyPathGraph - FlyPathGraphCurve contains the information regarding the graph representation of 3D path segments represented by Curve3 instances
      kAnnotateList - FlyPathAnnotateList contains the list of annotation points.
      _parentScene - the parent frame which hold Canvas3D.
      kTransformPosition - TransformGroup contains the Transform3D for the current viewing position.
      kTransformDirection - TransformGroup contains the Transform3D for the current viewing direction.
      kTransformOrientation - TransformGroup contains the Transform3D for the current viewing orientation.
  • Method Details

    • beep

      private static void beep()
      Sound a beep.
    • autoRun

      public void autoRun()
      One round trip path walk through.
    • getBranchCurve

      public WildMagic.LibFoundation.Curves.Curve3f getBranchCurve()
      Access the curve in the path graph currently positioned along.
      Returns:
      Curve3 Reference to Curve3 instance in path graph.
    • getBranchDistUnvisitedMax

      public float getBranchDistUnvisitedMax()
      Access the normalized distance traveled from the end of the current branch path. Also represents the maximum of the range that has been unvisited.
      Returns:
      float Normalized distance along the current branch path that is maximum of the unvisited range.
    • getBranchDistUnvisitedMin

      public float getBranchDistUnvisitedMin()
      Access the normalized distance traveled from the beginning of the current branch path. Also represents the minimum of the range that has been unvisited.
      Returns:
      float Normalized distance along the current branch path that is minimum of the unvisited range.
    • getBranchIndex

      public int getBranchIndex()
      Access the index of the curve in the path graph currrently positioned along.
      Returns:
      int Index of Curve3 instance in path graph.
    • getBranchState

      public FlyPathBehavior_WM.BranchState getBranchState()
      Get the current state of traversing.
      Returns:
      BranchState
    • getGazeDistance

      public float getGazeDistance()
      Get the current distance ahead for looking down the path. If this distance is zero, then the view direction is the tangent to the path curve at the current position.
      Returns:
      float Distance ahead for looking down the path.
    • getNormalizedPathDistance

      public float getNormalizedPathDistance()
      Get the normalized distance along the current path.
      Returns:
      float Value in the range [0,1].
    • getPathDist

      public float getPathDist()
      Get the current position distance along the path.
      Returns:
      float path distance.
    • getPathDistance

      public float getPathDistance()
      Get the current distance along the path.
      Returns:
      distance along the path.
    • getPathLength

      public float getPathLength()
      Get the total length of the current path.
      Returns:
      float Length of the path.
    • getPathStep

      public float getPathStep()
      Get the current distance increment for moving along the path.
      Returns:
      distance increment for moving along path. Always positive regardless of which direction moving along the path.
    • getSelectedBranchIndex

      public int getSelectedBranchIndex()
      Access the index of the currently selected branch at a branch point.
      Returns:
      int Index of currently selected branch; -1 if not currently at a branch point.
    • getViewDirection

      public WildMagic.LibFoundation.Mathematics.Vector3f getViewDirection()
      Returns the view direction vector at the current position on the path.
      Returns:
      view direction vector at the current position on the path.
    • getViewPoint

      public WildMagic.LibFoundation.Mathematics.Vector3f getViewPoint()
      Returns the current position on the path.
      Returns:
      current position on the path.
    • getViewUp

      public WildMagic.LibFoundation.Mathematics.Vector3f getViewUp()
      Returns the view up vector at the current position on the path.
      Returns:
      view up vector at the current position on the path.
    • isPathMoveForward

      public boolean isPathMoveForward()
      Get indication of whether the movement along the current path is in the forward or reverse direction.
      Returns:
      boolean True if the movement is along the forward direction along the path.
    • keyPressed

      public void keyPressed(KeyEvent event)
      Handle the key pressed event from the text field.
      Specified by:
      keyPressed in interface KeyListener
      Parameters:
      event - key event to handle
    • keyReleased

      public void keyReleased(KeyEvent event)
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent event)
      Specified by:
      keyTyped in interface KeyListener
    • move

      public void move(String command)
      Call from the JPanelFlythruMove.
      Parameters:
      command - move command.
    • moveAlongPath

      public void moveAlongPath(int _step)
      Move along the path step width.
      Parameters:
      _step - step size.
    • setBranch

      public void setBranch(Object _kBranchState)
      Make the specified branch be the current state for following.
      Parameters:
      _kBranchState - BranchState Instance which describes the state of the branch.
    • setupCallback

      public void setupCallback(FlyPathBehavior_WM.Callback kCallback)
      Identify the instance which implements the Callback interface. The viewChanged method of the Callback interface will be called whenever anything about this behavior changes.
      Parameters:
      kCallback - reference to instance implementing the Callback interface; may pass null reference to disable the callback
    • clampNormalizedPathDistance

      private float clampNormalizedPathDistance(float fDistance)
      Clamp the input normalized path distance to the range [0,1]. If the value is outside that range, then sound a beep.
      Parameters:
      fDistance - float Input normalized path distance.
      Returns:
      float Input distance clamped to the range [0,1].
    • doPathStep

      private void doPathStep(int iNumSteps)
      Take the specified number of steps along the current path using the current path step size. If the number of steps is negative, then the steps are taken in reverse.
      Parameters:
      iNumSteps - int Number of steps to take along the current path.
    • notifyCallback

      private void notifyCallback(int iEvent)
      Call the implementation of the callback's notification method, if a callback instance has been defined.
      Parameters:
      iEvent - Bitmask identifies the event(s) which caused the view to change. Bitmask created from OR of EVENT_* defintions.
    • setBranch

      private void setBranch(FlyPathBehavior_WM.BranchState kBranchState)
      Make the specified branch be the current state for following.
      Parameters:
      kBranchState - BranchState Instance which describes the state of the branch.
    • setBranch

      private void setBranch(int iBranch)
      Make the specified branch be the current state for following.
      Parameters:
      iBranch - int Index of the branch path to follow.
    • setClosestChoiceBranch

      private void setClosestChoiceBranch()
      Loop through all of the possible branch choices and select the one that is the closest to the current view direction vector. Take a vector from the current view point to a point along each choice branch. Compute the dot-product between the current view direction vector and each of these branch direction vectors and take the one with the largest positive value, i.e., most in alignment.
    • setCurvePathAnnotateItem

      private void setCurvePathAnnotateItem(int iItem)
      Set the annotation point along the path.
      Parameters:
      iItem - int
    • setIdentityViewOrientation

      private void setIdentityViewOrientation()
      Reset the view orientation transformation to the identity. That is, remove all yaw/pitch/roll.
    • setPathDist

      private void setPathDist(float fNormalizedDist)
      Update the camera position along the path based on the specified distance from the beginning.
      Parameters:
      fNormalizedDist - normalized distance from the beginning of the path for the location of the camera for viewing
    • setupBranchChoices

      private void setupBranchChoices(int iBranchParent, int iBranchPoint)
      Create the array of branch choices and set the mode which forces the user to select from among the branch choices.
      Parameters:
      iBranchParent - int Index which identifies the parent branch.
      iBranchPoint - int Index which identifies the point along the branch path where the branching occurs for the choices.
    • setView

      private void setView(WildMagic.LibFoundation.Mathematics.Vector3f kViewPoint, WildMagic.LibFoundation.Mathematics.Vector3f kViewdirVector)
      Set the camera to the specified be located at the specified view point and looking in the specified direction.
      Parameters:
      kViewPoint - coordinates of the camera view point
      kViewdirVector - coordinates of the camera view direction vector. This vector must be normalized.