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.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 Classes Modifier and Type Class Description class
NavigationBehavior.BranchState
Branch information.static interface
NavigationBehavior.Callback
Instances which want to be notified of updates to this behavior should implement this interface by providing the viewChanged method implementation.(package private) class
NavigationBehavior.KeyPressedEvent
(package private) class
NavigationBehavior.MouseWheelMouseControl
(package private) class
NavigationBehavior.MouseWheelPathPlanning
(package private) class
NavigationBehavior.RightMouse
-
Field Summary
Fields Modifier and Type Field Description private WildMagic.LibGraphics.Rendering.Camera
camera
private int
cameraViewRotationDegree
(package private) long
currEventTime
current and previous key press time.private WildMagic.LibFoundation.Mathematics.Vector3f
deltaBackward
private WildMagic.LibFoundation.Mathematics.Vector3f
deltaForward
static int
EVENT_CHANGE_ALL
on a viewChanged event change both the view position and direction vectorstatic int
EVENT_CHANGE_BRANCH
on a viewChanged event change the fly path branchstatic int
EVENT_CHANGE_POSITION
on a viewChanged event change just the view positionstatic int
EVENT_CHANGE_VIEW
on a viewChanged event change just the view directionstatic int
EVENT_RESET_ORIENTATION
on a viewChanged event change just the view orientation(package private) boolean[]
findPickingPoint
(package private) WildMagic.LibFoundation.Mathematics.Vector3f
firstPoint
private boolean
isDoPicking
private boolean
isMouseFlythru
private boolean
isPathFlythru
private boolean
keyPressdown
private NavigationBehavior.BranchState[]
m_akBranchChoice
private NavigationBehavior.BranchState[]
m_akBranchState
private boolean
m_bChooseBranch
private boolean
m_bMoveForward
float
m_fGazeDist
float
m_fPathStep
private int
m_iBranchChoiceIndex
protected int
m_iXPick
Picking support:protected int
m_iYPick
Picking support:private NavigationBehavior.BranchState
m_kBranchState
private NavigationBehavior.Callback
m_kCallback
Instance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.private FlyPathGraphCurve
m_kFlyPathGraph
private WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewDirection
Current view direction along the path.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewPoint
Current view position along the path.(package private) WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewRight
private WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewUp
Current view up vector.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewup1
private WildMagic.LibFoundation.Mathematics.Vector3f
m_kViewup2
private NavigationBehavior.MouseWheelMouseControl
mouseFlythru
private NavigationBehavior.MouseWheelPathPlanning
mousePathPlanning
private NavigationPicker
naviPicker
private VolumeTriPlanarRender
parentScene
Parent frame references.private boolean
pressed
(package private) long
prevEventTime
current and previous key press time.(package private) WildMagic.LibFoundation.Mathematics.Vector3f
resultPoint
(package private) WildMagic.LibFoundation.Mathematics.Vector3f
secondPoint
private WildMagic.LibFoundation.Mathematics.Vector3f
trackingBackward
private WildMagic.LibFoundation.Mathematics.Vector3f
trackingForward
private WildMagic.LibFoundation.Mathematics.Vector3f
trackingPointLocation
-
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 void
autoRun()
private static void
beep()
Sound a beep.private float
clampNormalizedPathDistance(float fDistance)
void
clearPath()
private void
doPathStep(int iNumSteps)
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)
WildMagic.LibFoundation.Curves.Curve3f
getBranchCurve()
Access the curve in the path graph currently positioned along.float
getBranchDistUnvisitedMax()
Access the normalized distance traveled from the end of the current branch path.float
getBranchDistUnvisitedMin()
Access the normalized distance traveled from the beginning of the current branch path.int
getBranchIndex()
Access the index of the curve in the path graph currrently positioned along.NavigationBehavior.BranchState
getBranchState()
Get the current state of traversing.float
getNormalizedPathDistance()
Get the normalized distance along the current path.float
getPathDistance()
Get the current distance along the path.float
getPathLength()
float
getPathStep()
Get the current distance increment for moving along the path.WildMagic.LibFoundation.Mathematics.Vector3f
getTrackingPoint()
return the tracking point locationWildMagic.LibFoundation.Mathematics.Vector3f
getViewDirection()
Returns the view direction vector at the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3f
getViewPoint()
Returns the current position on the path.WildMagic.LibFoundation.Mathematics.Vector3f
getViewRight()
WildMagic.LibFoundation.Mathematics.Vector3f
getViewUp()
Returns the view up vector at the current position on the path.boolean
isPathMoveForward()
Get indication of whether the movement along the current path is in the forward or reverse direction.void
keyPressed(java.awt.event.KeyEvent event)
Handle the key pressed event from the text field.void
keyReleased(java.awt.event.KeyEvent event)
void
keyTyped(java.awt.event.KeyEvent event)
private void
makeMove(WildMagic.LibFoundation.Mathematics.Vector3f _currentLocation)
void
mouseClicked(java.awt.event.MouseEvent e)
void
mouseDragged(java.awt.event.MouseEvent e)
void
mouseEntered(java.awt.event.MouseEvent e)
void
mouseExited(java.awt.event.MouseEvent e)
void
mouseMoved(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
void
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
void
move(java.lang.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)
private void
setBranch(NavigationBehavior.BranchState kBranchState)
void
setCamerViewRotationDegree(int degree)
void
setDirection(WildMagic.LibFoundation.Mathematics.Vector3f in)
private void
setIdentityViewOrientation()
Reset the view orientation transformation to the identity.void
setMouseFlythruMode(boolean _isMouseFlythru)
void
setNaviMode(boolean isNavigationEnabled)
private void
setPathDist(float fNormalizedDist)
Update the camera position along the path based on the specified distance from the beginning.void
setPathFlythruMode(boolean _isPathFlythru)
void
setRightVector(WildMagic.LibFoundation.Mathematics.Vector3f in)
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
setupCallback(NavigationBehavior.Callback kCallback)
Identify the instance which implements the Callback interface.void
setupPath(FlyPathGraphCurve kFlyPathGraph)
void
setUpVector(WildMagic.LibFoundation.Mathematics.Vector3f in)
private void
setView(WildMagic.LibFoundation.Mathematics.Vector3f kViewPoint, WildMagic.LibFoundation.Mathematics.Vector3f kViewdirVector)
????????????????????????????????????????????????????void
setViewPoint(WildMagic.LibFoundation.Mathematics.Vector3f in)
private void
updateSliceCenter(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:
keyPressed
in interfacejava.awt.event.KeyListener
- Parameters:
event
- key event to handle
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in 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:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
- Specified by:
mouseWheelMoved
in 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:
keyReleased
in interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent event)
- Specified by:
keyTyped
in 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.
-
-