Class NavigationBehavior

java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Navigation.NavigationBehavior
All Implemented Interfaces:
KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class NavigationBehavior extends Object implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener
Behavior which allows for flying down a specified path and looking around. Adding a few conventions for the path planning fly-thru. 1) Shift + Left mouse press to stop at the current location to fly-thru. At the path two ends, also need to use Shift + Left mouse to switch flying direction. Apply Shift+Left Mouse press once, the mouse wheel to control the auto fly-thru direction. Wheel one move forward to fly into the screen. Wheel one move backward to fly out of the screen direction. 2) In path-planning fly-thru mode, doesn't allow to change the camera view. If so, it introduces weird bug that distort the bottom three planner cross-hair location. 3) When switch to mouse control mode, users can change the camera view location. When switch back to path planning fly-thru mode, the view is directed to the first starting point of plan planning annotated path. This way to avoid the cross-hair location distortion.
Author:
Ruida Cheng
  • 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_kCallback

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

      private VolumeTriPlanarRender 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.
    • m_bMoveForward

      private boolean m_bMoveForward
    • camera

      private WildMagic.LibGraphics.Rendering.Camera camera
    • m_iXPick

      protected int m_iXPick
      Picking support:
    • m_iYPick

      protected int m_iYPick
      Picking support:
    • pressed

      private volatile boolean pressed
    • deltaForward

      private WildMagic.LibFoundation.Mathematics.Vector3f deltaForward
    • deltaBackward

      private WildMagic.LibFoundation.Mathematics.Vector3f deltaBackward
    • trackingForward

      private WildMagic.LibFoundation.Mathematics.Vector3f trackingForward
    • trackingBackward

      private WildMagic.LibFoundation.Mathematics.Vector3f trackingBackward
    • firstPoint

      WildMagic.LibFoundation.Mathematics.Vector3f firstPoint
    • secondPoint

      WildMagic.LibFoundation.Mathematics.Vector3f secondPoint
    • resultPoint

      WildMagic.LibFoundation.Mathematics.Vector3f resultPoint
    • findPickingPoint

      boolean[] findPickingPoint
    • m_kViewRight

      WildMagic.LibFoundation.Mathematics.Vector3f m_kViewRight
    • trackingPointLocation

      private WildMagic.LibFoundation.Mathematics.Vector3f trackingPointLocation
    • isDoPicking

      private boolean isDoPicking
    • keyPressdown

      private boolean keyPressdown
    • cameraViewRotationDegree

      private int cameraViewRotationDegree
    • mouseFlythru

    • mousePathPlanning

      private NavigationBehavior.MouseWheelPathPlanning mousePathPlanning
    • isMouseFlythru

      private boolean isMouseFlythru
    • isPathFlythru

      private boolean isPathFlythru
    • m_kFlyPathGraph

      private FlyPathGraphCurve m_kFlyPathGraph
    • m_akBranchState

      private NavigationBehavior.BranchState[] m_akBranchState
    • m_fGazeDist

      public float m_fGazeDist
    • m_fPathStep

      public float m_fPathStep
    • m_kBranchState

      private NavigationBehavior.BranchState m_kBranchState
    • m_kViewup1

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup1
    • m_kViewup2

      private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup2
    • m_akBranchChoice

      private NavigationBehavior.BranchState[] m_akBranchChoice
    • m_bChooseBranch

      private boolean m_bChooseBranch
    • m_iBranchChoiceIndex

      private int m_iBranchChoiceIndex
  • Constructor Details

    • NavigationBehavior

      public NavigationBehavior(VolumeTriPlanarRender _parentScene, WildMagic.LibGraphics.Rendering.Camera _m_spkCamera)
  • Method Details

    • beep

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

      public void setupPath(FlyPathGraphCurve kFlyPathGraph)
    • clearPath

      public void clearPath()
    • autoRun

      public void autoRun()
    • moveAlongPath

      public void moveAlongPath(int _step)
      Move along the path step width.
      Parameters:
      _step - step size.
    • 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 NavigationBehavior.BranchState getBranchState()
      Get the current state of traversing.
      Returns:
      BranchState
    • getPathDistance

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

      public float getNormalizedPathDistance()
      Get the normalized distance along the current path.
      Returns:
      float Value in the range [0,1].
    • 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.
    • setBranch

      private void setBranch(int iBranch)
    • setBranch

      private void setBranch(NavigationBehavior.BranchState kBranchState)
    • 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
    • setView

      private void setView(WildMagic.LibFoundation.Mathematics.Vector3f kViewPoint, WildMagic.LibFoundation.Mathematics.Vector3f kViewdirVector)
      ???????????????????????????????????????????????????? ************** How to do with it !!!!!!!!!!!!!!!!!!
      Parameters:
      kViewPoint -
      kViewdirVector -
    • clampNormalizedPathDistance

      private float clampNormalizedPathDistance(float fDistance)
    • getPathLength

      public float getPathLength()
    • setViewPoint

      public void setViewPoint(WildMagic.LibFoundation.Mathematics.Vector3f in)
    • setDirection

      public void setDirection(WildMagic.LibFoundation.Mathematics.Vector3f in)
    • setUpVector

      public void setUpVector(WildMagic.LibFoundation.Mathematics.Vector3f in)
    • setRightVector

      public void setRightVector(WildMagic.LibFoundation.Mathematics.Vector3f in)
    • setNaviMode

      public void setNaviMode(boolean isNavigationEnabled)
    • setMouseFlythruMode

      public void setMouseFlythruMode(boolean _isMouseFlythru)
    • setPathFlythruMode

      public void setPathFlythruMode(boolean _isPathFlythru)
    • 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.
    • getTrackingPoint

      public WildMagic.LibFoundation.Mathematics.Vector3f getTrackingPoint()
      return the tracking point location
      Returns:
      tracking point location
    • getViewRight

      public WildMagic.LibFoundation.Mathematics.Vector3f getViewRight()
    • 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
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • doPick

      public void doPick(int x, int y, WildMagic.LibFoundation.Mathematics.Vector3f kPos, WildMagic.LibFoundation.Mathematics.Vector3f kDir, WildMagic.LibFoundation.Mathematics.Vector3f first, WildMagic.LibFoundation.Mathematics.Vector3f second, WildMagic.LibFoundation.Mathematics.Vector3f detectPoint, boolean[] findPickingPoint)
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseWheelMoved

      public void mouseWheelMoved(MouseWheelEvent e)
      Specified by:
      mouseWheelMoved in interface MouseWheelListener
    • setCamerViewRotationDegree

      public void setCamerViewRotationDegree(int degree)
    • makeMove

      private void makeMove(WildMagic.LibFoundation.Mathematics.Vector3f _currentLocation)
    • updateSliceCenter

      private void updateSliceCenter(WildMagic.LibFoundation.Mathematics.Vector3f location)
    • 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.
    • doPathStep

      private void doPathStep(int iNumSteps)
    • 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.
    • setupCallback

      public void setupCallback(NavigationBehavior.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
    • 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.
    • setIdentityViewOrientation

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