Package com.jme3.math

Class Spline

java.lang.Object
com.jme3.math.Spline
All Implemented Interfaces:
Savable

public class Spline extends Object implements Savable
  • Constructor Details

    • Spline

      public Spline()
    • Spline

      public Spline(Spline.SplineType splineType, Vector3f[] controlPoints, float curveTension, boolean cycle)
      Create a spline
      Parameters:
      splineType - the type of the spline @see {SplineType}
      controlPoints - an array of vector to use as control points of the spline If the type of the curve is Bézier curve the control points should be provided in the appropriate way. Each point 'p' describing control position in the scene should be surrounded by two handler points. This applies to every point except for the border points of the curve, who should have only one handle point. The pattern should be as follows: P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn n is the amount of 'P' - points.
      curveTension - the tension of the spline
      cycle - true if the spline cycle.
    • Spline

      public Spline(Spline.SplineType splineType, List<Vector3f> controlPoints, float curveTension, boolean cycle)
      Create a spline
      Parameters:
      splineType - the type of the spline @see {SplineType}
      controlPoints - a list of vector to use as control points of the spline If the curve is a Bézier curve, the control points should be provided in the appropriate way. Each point 'p' describing control position in the scene should be surrounded by two handler points. This applies to every point except for the border points of the curve, who should have only one handle point. The pattern should be as follows: P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn n is the amount of 'P' - points.
      curveTension - the tension of the spline
      cycle - true if the spline cycle.
    • Spline

      public Spline(List<Vector4f> controlPoints, List<Float> nurbKnots)
      Create a NURBS spline. A spline type is automatically set to SplineType.Nurb. The cycle is set to false by default.
      Parameters:
      controlPoints - a list of vector to use as control points of the spline
      nurbKnots - the nurb's spline knots
  • Method Details

    • addControlPoint

      public void addControlPoint(Vector3f controlPoint)
      Adds a controlPoint to the spline
      Parameters:
      controlPoint - a position in world space
    • removeControlPoint

      public void removeControlPoint(Vector3f controlPoint)
      remove the controlPoint from the spline
      Parameters:
      controlPoint - the controlPoint to remove
    • clearControlPoints

      public void clearControlPoints()
    • interpolate

      public Vector3f interpolate(float value, int currentControlPoint, Vector3f store)
      Interpolate a position on the spline
      Parameters:
      value - a value from 0 to 1 that represent the position between the current control point and the next one
      currentControlPoint - the current control point
      store - a vector to store the result (use null to create a new one that will be returned by the method)
      Returns:
      the position
    • getCurveTension

      public float getCurveTension()
      returns the curve tension
      Returns:
      the value of the tension parameter
    • setCurveTension

      public void setCurveTension(float curveTension)
      sets the curve tension
      Parameters:
      curveTension - the tension
    • isCycle

      public boolean isCycle()
      Returns:
      true if the spline cycles
    • setCycle

      public void setCycle(boolean cycle)
      set to true to make the spline cycle
      Parameters:
      cycle - true for cyclic, false for acyclic
    • getTotalLength

      public float getTotalLength()
      Returns:
      the total length of the spline
    • getType

      public Spline.SplineType getType()
      return the type of the spline
      Returns:
      the enum value
    • setType

      public void setType(Spline.SplineType type)
      Sets the type of the spline
      Parameters:
      type - Linear/CatmullRom/Bezier/Nurb
    • getControlPoints

      public List<Vector3f> getControlPoints()
      returns this spline control points
      Returns:
      the pre-existing list
    • getSegmentsLength

      public List<Float> getSegmentsLength()
      returns a list of float representing the segments length
      Returns:
      the pre-existing list
    • getMinNurbKnot

      public float getMinNurbKnot()
      This method returns the minimum nurb curve knot value. Check the nurb type before calling this method. If the curve is not of a Nurb type, an NPE will be thrown.
      Returns:
      the minimum nurb curve knot value
    • getMaxNurbKnot

      public float getMaxNurbKnot()
      This method returns the maximum nurb curve knot value. Check the nurb type before calling this method. If the curve is not of a Nurb type, an NPE will be thrown.
      Returns:
      the maximum nurb curve knot value
    • getKnots

      public List<Float> getKnots()
      This method returns NURBS' spline knots.
      Returns:
      NURBS' spline knots
    • getWeights

      public float[] getWeights()
      This method returns NURBS' spline weights.
      Returns:
      NURBS' spline weights
    • getBasisFunctionDegree

      public int getBasisFunctionDegree()
      This method returns NURBS' spline basis function degree.
      Returns:
      NURBS' spline basis function degree
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize this spline to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Parameters:
      ex - (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      De-serialize this spline from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Parameters:
      im - (not null)
      Throws:
      IOException - from the importer