Class NavigationBehavior
- java.lang.Object
-
- gov.nih.mipav.view.renderer.WildMagic.Navigation.NavigationBehavior
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener,java.util.EventListener
public class NavigationBehavior extends java.lang.Object implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListenerBehavior 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classNavigationBehavior.BranchStateBranch information.static interfaceNavigationBehavior.CallbackInstances which want to be notified of updates to this behavior should implement this interface by providing the viewChanged method implementation.(package private) classNavigationBehavior.KeyPressedEvent(package private) classNavigationBehavior.MouseWheelMouseControl(package private) classNavigationBehavior.MouseWheelPathPlanning(package private) classNavigationBehavior.RightMouse
-
Field Summary
Fields Modifier and Type Field Description private WildMagic.LibGraphics.Rendering.Cameracameraprivate intcameraViewRotationDegree(package private) longcurrEventTimecurrent and previous key press time.private WildMagic.LibFoundation.Mathematics.Vector3fdeltaBackwardprivate WildMagic.LibFoundation.Mathematics.Vector3fdeltaForwardstatic intEVENT_CHANGE_ALLon a viewChanged event change both the view position and direction vectorstatic intEVENT_CHANGE_BRANCHon a viewChanged event change the fly path branchstatic intEVENT_CHANGE_POSITIONon a viewChanged event change just the view positionstatic intEVENT_CHANGE_VIEWon a viewChanged event change just the view directionstatic intEVENT_RESET_ORIENTATIONon a viewChanged event change just the view orientation(package private) boolean[]findPickingPoint(package private) WildMagic.LibFoundation.Mathematics.Vector3ffirstPointprivate booleanisDoPickingprivate booleanisMouseFlythruprivate booleanisPathFlythruprivate booleankeyPressdownprivate NavigationBehavior.BranchState[]m_akBranchChoiceprivate NavigationBehavior.BranchState[]m_akBranchStateprivate booleanm_bChooseBranchprivate booleanm_bMoveForwardfloatm_fGazeDistfloatm_fPathStepprivate intm_iBranchChoiceIndexprotected intm_iXPickPicking support:protected intm_iYPickPicking support:private NavigationBehavior.BranchStatem_kBranchStateprivate NavigationBehavior.Callbackm_kCallbackInstance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.private FlyPathGraphCurvem_kFlyPathGraphprivate WildMagic.LibFoundation.Mathematics.Vector3fm_kViewDirectionCurrent view direction along the path.private WildMagic.LibFoundation.Mathematics.Vector3fm_kViewPointCurrent view position along the path.(package private) WildMagic.LibFoundation.Mathematics.Vector3fm_kViewRightprivate WildMagic.LibFoundation.Mathematics.Vector3fm_kViewUpCurrent view up vector.private WildMagic.LibFoundation.Mathematics.Vector3fm_kViewup1private WildMagic.LibFoundation.Mathematics.Vector3fm_kViewup2private NavigationBehavior.MouseWheelMouseControlmouseFlythruprivate NavigationBehavior.MouseWheelPathPlanningmousePathPlanningprivate NavigationPickernaviPickerprivate VolumeTriPlanarRenderparentSceneParent frame references.private booleanpressed(package private) longprevEventTimecurrent and previous key press time.(package private) WildMagic.LibFoundation.Mathematics.Vector3fresultPoint(package private) WildMagic.LibFoundation.Mathematics.Vector3fsecondPointprivate WildMagic.LibFoundation.Mathematics.Vector3ftrackingBackwardprivate WildMagic.LibFoundation.Mathematics.Vector3ftrackingForwardprivate WildMagic.LibFoundation.Mathematics.Vector3ftrackingPointLocation
-
Constructor Summary
Constructors Constructor Description NavigationBehavior(VolumeTriPlanarRender _parentScene, WildMagic.LibGraphics.Rendering.Camera _m_spkCamera)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidautoRun()private static voidbeep()Sound a beep.private floatclampNormalizedPathDistance(float fDistance)voidclearPath()private voiddoPathStep(int iNumSteps)voiddoPick(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)WildMagic.LibFoundation.Curves.Curve3fgetBranchCurve()Access the curve in the path graph currently positioned along.floatgetBranchDistUnvisitedMax()Access the normalized distance traveled from the end of the current branch path.floatgetBranchDistUnvisitedMin()Access the normalized distance traveled from the beginning of the current branch path.intgetBranchIndex()Access the index of the curve in the path graph currrently positioned along.NavigationBehavior.BranchStategetBranchState()Get the current state of traversing.floatgetNormalizedPathDistance()Get the normalized distance along the current path.floatgetPathDistance()Get the current distance along the path.floatgetPathLength()floatgetPathStep()Get the current distance increment for moving along the path.WildMagic.LibFoundation.Mathematics.Vector3fgetTrackingPoint()return the tracking point locationWildMagic.LibFoundation.Mathematics.Vector3fgetViewDirection()Returns the view direction vector at the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3fgetViewPoint()Returns the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3fgetViewRight()WildMagic.LibFoundation.Mathematics.Vector3fgetViewUp()Returns the view up vector at the current position on the path.booleanisPathMoveForward()Get indication of whether the movement along the current path is in the forward or reverse direction.voidkeyPressed(java.awt.event.KeyEvent event)Handle the key pressed event from the text field.voidkeyReleased(java.awt.event.KeyEvent event)voidkeyTyped(java.awt.event.KeyEvent event)private voidmakeMove(WildMagic.LibFoundation.Mathematics.Vector3f _currentLocation)voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidmouseWheelMoved(java.awt.event.MouseWheelEvent e)voidmove(java.lang.String command)Call from the JPanelFlythruMove.voidmoveAlongPath(int _step)Move along the path step width.private voidnotifyCallback(int iEvent)Call the implementation of the callback's notification method, if a callback instance has been defined.private voidsetBranch(int iBranch)private voidsetBranch(NavigationBehavior.BranchState kBranchState)voidsetCamerViewRotationDegree(int degree)voidsetDirection(WildMagic.LibFoundation.Mathematics.Vector3f in)private voidsetIdentityViewOrientation()Reset the view orientation transformation to the identity.voidsetMouseFlythruMode(boolean _isMouseFlythru)voidsetNaviMode(boolean isNavigationEnabled)private voidsetPathDist(float fNormalizedDist)Update the camera position along the path based on the specified distance from the beginning.voidsetPathFlythruMode(boolean _isPathFlythru)voidsetRightVector(WildMagic.LibFoundation.Mathematics.Vector3f in)private voidsetupBranchChoices(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.voidsetupCallback(NavigationBehavior.Callback kCallback)Identify the instance which implements the Callback interface.voidsetupPath(FlyPathGraphCurve kFlyPathGraph)voidsetUpVector(WildMagic.LibFoundation.Mathematics.Vector3f in)private voidsetView(WildMagic.LibFoundation.Mathematics.Vector3f kViewPoint, WildMagic.LibFoundation.Mathematics.Vector3f kViewdirVector)????????????????????????????????????????????????????voidsetViewPoint(WildMagic.LibFoundation.Mathematics.Vector3f in)private voidupdateSliceCenter(WildMagic.LibFoundation.Mathematics.Vector3f location)
-
-
-
Field Detail
-
EVENT_CHANGE_ALL
public static final int EVENT_CHANGE_ALL
on a viewChanged event change both the view position and direction vector- See Also:
- Constant Field Values
-
EVENT_CHANGE_POSITION
public static final int EVENT_CHANGE_POSITION
on a viewChanged event change just the view position- See Also:
- Constant Field Values
-
EVENT_CHANGE_VIEW
public static final int EVENT_CHANGE_VIEW
on a viewChanged event change just the view direction- See Also:
- Constant Field Values
-
EVENT_RESET_ORIENTATION
public static final int EVENT_RESET_ORIENTATION
on a viewChanged event change just the view orientation- See Also:
- Constant Field Values
-
EVENT_CHANGE_BRANCH
public static final int EVENT_CHANGE_BRANCH
on a viewChanged event change the fly path branch- See Also:
- Constant Field Values
-
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
-
naviPicker
private NavigationPicker naviPicker
-
trackingPointLocation
private WildMagic.LibFoundation.Mathematics.Vector3f trackingPointLocation
-
isDoPicking
private boolean isDoPicking
-
keyPressdown
private boolean keyPressdown
-
cameraViewRotationDegree
private int cameraViewRotationDegree
-
mouseFlythru
private NavigationBehavior.MouseWheelMouseControl 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 Detail
-
NavigationBehavior
public NavigationBehavior(VolumeTriPlanarRender _parentScene, WildMagic.LibGraphics.Rendering.Camera _m_spkCamera)
-
-
Method Detail
-
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(java.awt.event.KeyEvent event)
Handle the key pressed event from the text field.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener- Parameters:
event- key event to handle
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.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(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
- Specified by:
mouseWheelMovedin interfacejava.awt.event.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(java.awt.event.KeyEvent event)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent event)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
move
public void move(java.lang.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.
-
-