Package com.jme3.cinematic
Class MotionPath
java.lang.Object
com.jme3.cinematic.MotionPath
- All Implemented Interfaces:
Savable
Motion path is used to create a path between way points.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(MotionPathListener listener) Adds a motion pathListener to the pathvoid
addWayPoint
(Vector3f wayPoint) Add a waypoint to the pathvoid
checkWayPoint
(MotionEvent control, float tpf) void
void
disable the display of the path and the waypointsvoid
enableDebugShape
(AssetManager manager, Node rootNode) enable the display of the path and the waypointsfloat
Returns the curve tensionfloat
Return the length of the path in world unitsint
return the number of waypoints of this pathreturn the type of spline used for the path interpolation for this pathgetWayPoint
(int i) returns the waypoint at the given indexgetWayPointIndexForDistance
(float distance, Vector2f store) compute the index of the waypoint and the interpolation value according to a distance returns a vector 2 containing the index in the x field and the interpolation value in the y fieldfloat
interpolatePath
(float time, MotionEvent control, float tpf) interpolate the path giving the time since the beginning and the motionControl this methods sets the new localTranslation to the spatial of the MotionEvent control.boolean
isCycle()
returns true if the path is a cycleiterator()
returns an iterator on the waypoints collectionvoid
read
(JmeImporter im) void
removeListener
(MotionPathListener listener) remove the given listenervoid
removeWayPoint
(int i) remove the waypoint at the given index from the pathvoid
removeWayPoint
(Vector3f wayPoint) remove the waypoint from the pathvoid
setCurveTension
(float curveTension) sets the tension of the curve (only for catmull rom) 0.0 will give a linear curve, 1.0 a round curvevoid
setCycle
(boolean cycle) Sets the path to be a cyclevoid
setPathSplineType
(Spline.SplineType pathSplineType) sets the type of spline used for the path interpolation for this pathvoid
triggerWayPointReach
(int wayPointIndex, MotionEvent control) void
write
(JmeExporter ex)
-
Constructor Details
-
MotionPath
public MotionPath()Create a motion Path
-
-
Method Details
-
interpolatePath
interpolate the path giving the time since the beginning and the motionControl this methods sets the new localTranslation to the spatial of the MotionEvent control.- Parameters:
time
- the time since the animation startedcontrol
- the control over the moving spatialtpf
- time per frame (in seconds)- Returns:
- the distance travelled (in world units)
-
checkWayPoint
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getWayPointIndexForDistance
compute the index of the waypoint and the interpolation value according to a distance returns a vector 2 containing the index in the x field and the interpolation value in the y field- Parameters:
distance
- the distance traveled on this pathstore
- storage for the result (not null, modified)- Returns:
- the waypoint index and the interpolation value in a vector2
-
addWayPoint
Add a waypoint to the path- Parameters:
wayPoint
- a position in world space
-
getLength
public float getLength()Return the length of the path in world units- Returns:
- the length
-
getWayPoint
returns the waypoint at the given index- Parameters:
i
- the index- Returns:
- returns the waypoint position
-
removeWayPoint
remove the waypoint from the path- Parameters:
wayPoint
- the waypoint to remove
-
removeWayPoint
public void removeWayPoint(int i) remove the waypoint at the given index from the path- Parameters:
i
- the index of the waypoint to remove
-
iterator
returns an iterator on the waypoints collection- Returns:
- an iterator
-
getPathSplineType
return the type of spline used for the path interpolation for this path- Returns:
- the path interpolation spline type
-
setPathSplineType
sets the type of spline used for the path interpolation for this path- Parameters:
pathSplineType
- the desired type
-
disableDebugShape
public void disableDebugShape()disable the display of the path and the waypoints -
enableDebugShape
enable the display of the path and the waypoints- Parameters:
manager
- the assetManagerrootNode
- the node where the debug shapes must be attached
-
addListener
Adds a motion pathListener to the path- Parameters:
listener
- the MotionPathListener to attach
-
removeListener
remove the given listener- Parameters:
listener
- the listener to remove
-
getNbWayPoints
public int getNbWayPoints()return the number of waypoints of this path- Returns:
- the count (≥0)
-
triggerWayPointReach
-
getCurveTension
public float getCurveTension()Returns the curve tension- Returns:
- the curve tension
-
setCurveTension
public void setCurveTension(float curveTension) sets the tension of the curve (only for catmull rom) 0.0 will give a linear curve, 1.0 a round curve- Parameters:
curveTension
- the desired value
-
clearWayPoints
public void clearWayPoints() -
setCycle
public void setCycle(boolean cycle) Sets the path to be a cycle- Parameters:
cycle
- true for a cycle, false for a non-cycle
-
isCycle
public boolean isCycle()returns true if the path is a cycle- Returns:
- true if the path is a cycle
-
getSpline
-