Class MotionPath

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

public class MotionPath extends Object implements Savable
Motion path is used to create a path between way points.
  • Constructor Details

    • MotionPath

      public MotionPath()
      Create a motion Path
  • Method Details

    • interpolatePath

      public float 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.
      Parameters:
      time - the time since the animation started
      control - the control over the moving spatial
      tpf - time per frame (in seconds)
      Returns:
      the distance travelled (in world units)
    • checkWayPoint

      public void checkWayPoint(MotionEvent control, float tpf)
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • getWayPointIndexForDistance

      public Vector2f getWayPointIndexForDistance(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 field
      Parameters:
      distance - the distance traveled on this path
      store - storage for the result (not null, modified)
      Returns:
      the waypoint index and the interpolation value in a vector2
    • addWayPoint

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

      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 Iterator<Vector3f> iterator()
      returns an iterator on the waypoints collection
      Returns:
      an iterator
    • 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 - the desired type
    • 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:
      the count (≥0)
    • triggerWayPointReach

      public void triggerWayPointReach(int wayPointIndex, MotionEvent control)
    • 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

      public Spline getSpline()