Class FlyPathBehavior
java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.Node
javax.media.j3d.Leaf
javax.media.j3d.Behavior
gov.nih.mipav.view.renderer.J3D.surfaceview.flythruview.FlyPathBehavior
- All Implemented Interfaces:
KeyListener,EventListener
Behavior which allows for flying down a specified path and looking around.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classDOCUMENT ME!static interfaceInstances which want to be notified of updates to this behavior should implement this interface by providing the viewChanged method implementation.(package private) classClass used to send Standard key events to the canvas. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) longcurrent and previous key press time.static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private FlyPathBehavior.BranchState[]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.private FlyPathBehavior.BranchState[]Identifies the current state of traversing the current branch.private booleanWhen a branch point along the current branch is reached, this flag is set until the user selects a branch to follow.floatHow far ahead down the path should the view be aimed.floatWhat is the increment in distance along the path that each step takes.private intDOCUMENT ME!private intDOCUMENT ME!private FlyPathAnnotateListKeep reference to instance which describes the annotation points.private FlyPathBehavior.BranchStateDOCUMENT ME!private FlyPathBehavior.CallbackInstance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes.private FlyPathGraphCurveKeep reference to instance which describes the path.private javax.media.j3d.Transform3DTransform created for multiple use to avoid new'ing it each time.private javax.media.j3d.TransformGroupView direction component for this view transform.private javax.media.j3d.TransformGroupOrientation (yaw/pitch) component for this view transform.private javax.media.j3d.TransformGroupPosition-only component for this view transform.private javax.media.j3d.Transform3DDOCUMENT ME!private javax.vecmath.Vector3dThe desired view up vector is a normalized average of these two orthogonal axes vectors.private javax.vecmath.Vector3dDOCUMENT ME!private final javax.media.j3d.WakeupConditionConditions which contain the events we want to "wakeup" on.private FlythruRenderParent frame references.private booleanIf any of the mouse move button pressed.(package private) longcurrent and previous key press time.Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING -
Constructor Summary
ConstructorsConstructorDescriptionFlyPathBehavior(FlyPathGraphCurve kFlyPathGraph, FlyPathAnnotateList kAnnotateList, javax.media.j3d.TransformGroup kTransformPosition, javax.media.j3d.TransformGroup kTransformDirection, javax.media.j3d.TransformGroup kTransformOrientation, FlythruRender _parentScene) Setup to fly along the specified path and look around. -
Method Summary
Modifier and TypeMethodDescriptionvoidautoRun()One round trip path walk through.private static voidbeep()Sound a beep.private floatclampNormalizedPathDistance(float fDistance) Clamp the input normalized path distance to the range [0,1].private voiddoPathStep(int iNumSteps) Take the specified number of steps along the current path using the current path step size.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 current distance ahead for looking down the path.floatGet the normalized distance along the current path.floatGet the current position distance along the path.floatGet the current distance along the path.floatGet the total length of the current path.javax.vecmath.Point3fGet the location of the current position along the path.floatGet the current distance increment for moving along the path.intAccess the index of the currently selected branch at a branch point.javax.vecmath.Vector3fRetrieve the current base direction vector for viewing.javax.vecmath.Matrix3fRetrieve the current relative orientation transform matrix for viewing which is relative to the current base direction transform for viewing.voidImplementation of the Behavior abstract method.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) Handle the key released event from the text field.voidDoes nothing.voidCall 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.voidprocessStimulus(Enumeration kCriteria) Implementation of the Behavior abstract method.private voidsetBranch(int iBranch) Make the specified branch be the current state for following.private voidsetBranch(FlyPathBehavior.BranchState kBranchState) Make the specified branch be the current state for following.voidMake the specified branch be the current state for following.private voidLoop through all of the possible branch choices and select the one that is the closest to the current view direction vector.private voidsetCurvePathAnnotateItem(int iItem) Set the annotation point along the path.private voidReset the view orientation transformation to the identity.private voidsetPathDist(float fNormalizedDist) Update the camera position along the path based on the specified distance from the beginning.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(FlyPathBehavior.Callback kCallback) Identify the instance which implements the Callback interface.private voidsetView(javax.vecmath.Point3d kViewPoint, javax.vecmath.Vector3d kViewdirVector) Set the camera to the specified be located at the specified view point and looking in the specified direction.Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOnMethods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickableMethods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
-
Field Details
-
EVENT_CHANGE_ALL
public static final int EVENT_CHANGE_ALLDOCUMENT ME!- See Also:
-
EVENT_CHANGE_POSITION
public static final int EVENT_CHANGE_POSITIONDOCUMENT ME!- See Also:
-
EVENT_CHANGE_ORIENTATION
public static final int EVENT_CHANGE_ORIENTATIONDOCUMENT ME!- See Also:
-
EVENT_CHANGE_BRANCH
public static final int EVENT_CHANGE_BRANCHDOCUMENT ME!- See Also:
-
m_fGazeDist
public float m_fGazeDistHow 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_fPathStepWhat 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. -
currEventTime
long currEventTimecurrent and previous key press time. -
prevEventTime
long prevEventTimecurrent and previous key press time. -
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
Identifies the current state of traversing the current branch. -
m_bChooseBranch
private boolean m_bChooseBranchWhen 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_iAnnotateListItemSelectedDOCUMENT ME! -
m_iBranchChoiceIndex
private int m_iBranchChoiceIndexDOCUMENT ME! -
m_kAnnotateList
Keep reference to instance which describes the annotation points. -
m_kBranchState
DOCUMENT ME! -
m_kCallback
Instance which implements the Callback interface whose viewChanged method is to be called whenever anything about this behavior changes. -
m_kFlyPathGraph
Keep reference to instance which describes the path. -
m_kTransform
private javax.media.j3d.Transform3D m_kTransformTransform created for multiple use to avoid new'ing it each time. -
m_kTransformDirection
private javax.media.j3d.TransformGroup m_kTransformDirectionView direction component for this view transform. This assumes a viewup vector (see m_kVectorViewup member). This transform causes the view to look down the path when the yaw=pitch=roll=0. -
m_kTransformOrientation
private javax.media.j3d.TransformGroup m_kTransformOrientationOrientation (yaw/pitch) component for this view transform. -
m_kTransformPosition
private javax.media.j3d.TransformGroup m_kTransformPositionPosition-only component for this view transform. -
m_kTransformRot
private javax.media.j3d.Transform3D m_kTransformRotDOCUMENT ME! -
m_kViewup1
private javax.vecmath.Vector3d m_kViewup1The 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 javax.vecmath.Vector3d m_kViewup2DOCUMENT ME! -
m_kWakeupCondition
private final javax.media.j3d.WakeupCondition m_kWakeupConditionConditions which contain the events we want to "wakeup" on. -
parentScene
Parent frame references. -
pressed
private boolean pressedIf any of the mouse move button pressed.
-
-
Constructor Details
-
FlyPathBehavior
public FlyPathBehavior(FlyPathGraphCurve kFlyPathGraph, FlyPathAnnotateList kAnnotateList, javax.media.j3d.TransformGroup kTransformPosition, javax.media.j3d.TransformGroup kTransformDirection, javax.media.j3d.TransformGroup kTransformOrientation, FlythruRender _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 instanceskAnnotateList- FlyPathAnnotateList contains the list of annotation points.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._parentScene- the parent frame which hold Canvas3D.
-
-
Method Details
-
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
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.
-
getPathPosition
public javax.vecmath.Point3f getPathPosition()Get the location of the current position along the path.- Returns:
- location of current position
-
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 javax.vecmath.Vector3f getViewDirection()Retrieve the current base direction vector for viewing.- Returns:
- normalized direction vector
-
getViewOrientation
public javax.vecmath.Matrix3f getViewOrientation()Retrieve the current relative orientation transform matrix for viewing which is relative to the current base direction transform for viewing.- Returns:
- 3x3 matrix containing orientation transform
-
initialize
public void initialize()Implementation of the Behavior abstract method.- Specified by:
initializein classjavax.media.j3d.Behavior
-
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
-
keyReleased
Handle the key released event from the text field.- Specified by:
keyReleasedin interfaceKeyListener- Parameters:
event- key event to handle
-
keyTyped
Does nothing.- Specified by:
keyTypedin interfaceKeyListener- Parameters:
event- key event to handle
-
move
Call from the JPanelFlythruMove.- Parameters:
command- move command.
-
moveAlongPath
public void moveAlongPath(int _step) Move along the path step width.- Parameters:
_step- step size.
-
processStimulus
Implementation of the Behavior abstract method. Process events in the criteria which are the ones we setup for.- Specified by:
processStimulusin classjavax.media.j3d.Behavior- Parameters:
kCriteria- collection of WakeupCriterion to which this Behavior is responding to events.
-
setBranch
Make the specified branch be the current state for following.- Parameters:
_kBranchState- BranchState Instance which describes the state of the branch.
-
setupCallback
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
-
beep
private static void beep()Sound a beep. -
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(int iBranch) Make the specified branch be the current state for following.- Parameters:
iBranch- int Index of the branch path to follow.
-
setBranch
Make the specified branch be the current state for following.- Parameters:
kBranchState- BranchState Instance which describes the state of the branch.
-
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(javax.vecmath.Point3d kViewPoint, javax.vecmath.Vector3d 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 pointkViewdirVector- coordinates of the camera view direction vector. This vector must be normalized.
-