com.jme3.cinematic
Class MotionPath

java.lang.Object
  extended by com.jme3.cinematic.MotionPath
All Implemented Interfaces:
Savable

public class MotionPath
extends java.lang.Object
implements Savable

Motion path is used to create a path between way points.


Constructor Summary
MotionPath()
          Create a motion Path
 
Method Summary
 void addListener(MotionPathListener listener)
          Adds a motion pathListener to the path
 void addWayPoint(Vector3f wayPoint)
          Addsa waypoint to the path
 void checkWayPoint(MotionTrack control, float tpf)
           
 void clearWayPoints()
           
 void disableDebugShape()
          disable the display of the path and the waypoints
 void enableDebugShape(AssetManager manager, Node rootNode)
          enable the display of the path and the waypoints
 float getCurveTension()
          Returns the curve tension
 float getLength()
          retruns the length of the path in world units
 int getNbWayPoints()
          return the number of waypoints of this path
 Spline.SplineType getPathSplineType()
          return the type of spline used for the path interpolation for this path
 Spline getSpline()
           
 Vector3f getWayPoint(int i)
          returns the waypoint at the given index
 Vector2f getWayPointIndexForDistance(float distance)
          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
 float interpolatePath(float time, MotionTrack control, float tpf)
          interpolate the path giving the time since the beginnin and the motionControl this methods sets the new localTranslation to the spatial of the motionTrack control.
 boolean isCycle()
          returns true if the path is a cycle
 java.util.Iterator<Vector3f> iterator()
          returns an iterator on the waypoints collection
 void read(JmeImporter im)
           
 void removeListener(MotionPathListener listener)
          remove the given listener
 void removeWayPoint(int i)
          remove the waypoint at the given index from the path
 void removeWayPoint(Vector3f wayPoint)
          remove the waypoint from the path
 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
 void setCycle(boolean cycle)
          Sets the path to be a cycle
 void setPathSplineType(Spline.SplineType pathSplineType)
          sets the type of spline used for the path interpolation for this path
 void triggerWayPointReach(int wayPointIndex, MotionTrack control)
           
 void write(JmeExporter ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MotionPath

public MotionPath()
Create a motion Path

Method Detail

interpolatePath

public float interpolatePath(float time,
                             MotionTrack control,
                             float tpf)
interpolate the path giving the time since the beginnin and the motionControl this methods sets the new localTranslation to the spatial of the motionTrack control.

Parameters:
time - the time since the animation started
control - the ocntrol over the moving spatial

checkWayPoint

public void checkWayPoint(MotionTrack control,
                          float tpf)

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getWayPointIndexForDistance

public Vector2f getWayPointIndexForDistance(float distance)
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 path
Returns:
the waypoint index and the interpolation value in a vector2

addWayPoint

public void addWayPoint(Vector3f wayPoint)
Addsa waypoint to the path

Parameters:
wayPoint - a position in world space

getLength

public float getLength()
retruns the length of the path in world units

Returns:
the length

getWayPoint

public Vector3f getWayPoint(int i)
returns the waypoint at the given index

Parameters:
i - the index
Returns:
returns the waypoint position

removeWayPoint

public void removeWayPoint(Vector3f wayPoint)
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

public java.util.Iterator<Vector3f> iterator()
returns an iterator on the waypoints collection

Returns:

getPathSplineType

public Spline.SplineType getPathSplineType()
return the type of spline used for the path interpolation for this path

Returns:
the path interpolation spline type

setPathSplineType

public void setPathSplineType(Spline.SplineType pathSplineType)
sets the type of spline used for the path interpolation for this path

Parameters:
pathSplineType -

disableDebugShape

public void disableDebugShape()
disable the display of the path and the waypoints


enableDebugShape

public void enableDebugShape(AssetManager manager,
                             Node rootNode)
enable the display of the path and the waypoints

Parameters:
manager - the assetManager
rootNode - the node where the debug shapes must be attached

addListener

public void addListener(MotionPathListener listener)
Adds a motion pathListener to the path

Parameters:
listener - the MotionPathListener to attach

removeListener

public void removeListener(MotionPathListener listener)
remove the given listener

Parameters:
listener - the listener to remove

getNbWayPoints

public int getNbWayPoints()
return the number of waypoints of this path

Returns:

triggerWayPointReach

public void triggerWayPointReach(int wayPointIndex,
                                 MotionTrack control)

getCurveTension

public float getCurveTension()
Returns the curve tension

Returns:

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 -

clearWayPoints

public void clearWayPoints()

setCycle

public void setCycle(boolean cycle)
Sets the path to be a cycle

Parameters:
cycle -

isCycle

public boolean isCycle()
returns true if the path is a cycle

Returns:

getSpline

public Spline getSpline()