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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassBranch information.static interfaceInstances which want to be notified of updates to this behavior should implement this interface by providing the viewChanged method implementation.(package private) class(package private) class(package private) class(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WildMagic.LibGraphics.Rendering.Cameraprivate int(package private) longcurrent and previous key press time.private WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3fstatic final inton a viewChanged event change both the view position and direction vectorstatic final inton a viewChanged event change the fly path branchstatic final inton a viewChanged event change just the view positionstatic final inton a viewChanged event change just the view directionstatic final inton a viewChanged event change just the view orientation(package private) boolean[](package private) WildMagic.LibFoundation.Mathematics.Vector3fprivate booleanprivate booleanprivate booleanprivate booleanprivate NavigationBehavior.BranchState[]private NavigationBehavior.BranchState[]private booleanprivate booleanfloatfloatprivate intprotected intPicking support:protected intPicking support:private NavigationBehavior.BranchStateprivate NavigationBehavior.CallbackInstance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.private FlyPathGraphCurveprivate WildMagic.LibFoundation.Mathematics.Vector3fCurrent view direction along the path.private WildMagic.LibFoundation.Mathematics.Vector3fCurrent view position along the path.(package private) WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3fCurrent view up vector.private WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3fprivate NavigationPickerprivate VolumeTriPlanarRenderParent frame references.private boolean(package private) longcurrent and previous key press time.(package private) WildMagic.LibFoundation.Mathematics.Vector3f(package private) WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3fprivate WildMagic.LibFoundation.Mathematics.Vector3f -
Constructor Summary
ConstructorsConstructorDescriptionNavigationBehavior(VolumeTriPlanarRender _parentScene, WildMagic.LibGraphics.Rendering.Camera _m_spkCamera) -
Method Summary
Modifier and TypeMethodDescriptionvoidautoRun()private static voidbeep()Sound a beep.private floatclampNormalizedPathDistance(float fDistance) voidprivate 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.Curve3fAccess the curve in the path graph currently positioned along.floatAccess the normalized distance traveled from the end of the current branch path.floatAccess the normalized distance traveled from the beginning of the current branch path.intAccess the index of the curve in the path graph currrently positioned along.Get the current state of traversing.floatGet the normalized distance along the current path.floatGet the current distance along the path.floatfloatGet the current distance increment for moving along the path.WildMagic.LibFoundation.Mathematics.Vector3freturn the tracking point locationWildMagic.LibFoundation.Mathematics.Vector3fReturns the view direction vector at the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3fReturns the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3fWildMagic.LibFoundation.Mathematics.Vector3fReturns the view up vector at the current position on the path.booleanGet indication of whether the movement along the current path is in the forward or reverse direction.voidkeyPressed(KeyEvent event) Handle the key pressed event from the text field.voidkeyReleased(KeyEvent event) voidprivate voidmakeMove(WildMagic.LibFoundation.Mathematics.Vector3f _currentLocation) voidvoidvoidvoidvoidvoidvoidvoidvoidCall 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 voidReset 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 Details
-
EVENT_CHANGE_ALL
public static final int EVENT_CHANGE_ALLon a viewChanged event change both the view position and direction vector- See Also:
-
EVENT_CHANGE_POSITION
public static final int EVENT_CHANGE_POSITIONon a viewChanged event change just the view position- See Also:
-
EVENT_CHANGE_VIEW
public static final int EVENT_CHANGE_VIEWon a viewChanged event change just the view direction- See Also:
-
EVENT_RESET_ORIENTATION
public static final int EVENT_RESET_ORIENTATIONon a viewChanged event change just the view orientation- See Also:
-
EVENT_CHANGE_BRANCH
public static final int EVENT_CHANGE_BRANCHon a viewChanged event change the fly path branch- See Also:
-
currEventTime
long currEventTimecurrent and previous key press time. -
prevEventTime
long prevEventTimecurrent and previous key press time. -
m_kCallback
Instance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes. -
parentScene
Parent frame references. -
m_kViewPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewPointCurrent view position along the path. -
m_kViewDirection
private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewDirectionCurrent view direction along the path. -
m_kViewUp
private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewUpCurrent view up vector. -
m_bMoveForward
private boolean m_bMoveForward -
camera
private WildMagic.LibGraphics.Rendering.Camera camera -
m_iXPick
protected int m_iXPickPicking support: -
m_iYPick
protected int m_iYPickPicking 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
-
isMouseFlythru
private boolean isMouseFlythru -
isPathFlythru
private boolean isPathFlythru -
m_kFlyPathGraph
-
m_akBranchState
-
m_fGazeDist
public float m_fGazeDist -
m_fPathStep
public float m_fPathStep -
m_kBranchState
-
m_kViewup1
private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup1 -
m_kViewup2
private WildMagic.LibFoundation.Mathematics.Vector3f m_kViewup2 -
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
-
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
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) -
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) -
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
Handle the key pressed event from the text field.- Specified by:
keyPressedin interfaceKeyListener- Parameters:
event- key event to handle
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
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
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
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
- Specified by:
keyReleasedin interfaceKeyListener
-
keyTyped
- Specified by:
keyTypedin interfaceKeyListener
-
move
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.
-
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.
-