com.jme3.math
Class Spline

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

public class Spline
extends java.lang.Object
implements Savable


Nested Class Summary
static class Spline.SplineType
           
 
Constructor Summary
Spline()
           
Spline(java.util.List<Vector4f> controlPoints, java.util.List<java.lang.Float> nurbKnots)
          Create a NURBS spline.
Spline(Spline.SplineType splineType, java.util.List<Vector3f> controlPoints, float curveTension, boolean cycle)
          Create a spline
Spline(Spline.SplineType splineType, Vector3f[] controlPoints, float curveTension, boolean cycle)
          Create a spline
 
Method Summary
 void addControlPoint(Vector3f controlPoint)
          Adds a controlPoint to the spline
 void clearControlPoints()
           
 int getBasisFunctionDegree()
          This method returns NURBS' spline basis function degree.
 java.util.List<Vector3f> getControlPoints()
          returns this spline control points
 float getCurveTension()
          returns the curve tension
 java.util.List<java.lang.Float> getKnots()
          This method returns NURBS' spline knots.
 float getMaxNurbKnot()
          This method returns the maximum nurb curve knot value.
 float getMinNurbKnot()
          This method returns the minimum nurb curve knot value.
 java.util.List<java.lang.Float> getSegmentsLength()
          returns a list of float representing the segments lenght
 float getTotalLength()
          return the total lenght of the spline
 Spline.SplineType getType()
          return the type of the spline
 float[] getWeights()
          This method returns NURBS' spline weights.
 Vector3f interpolate(float value, int currentControlPoint, Vector3f store)
          Iterpolate a position on the spline
 boolean isCycle()
          returns true if the spline cycle
 void read(JmeImporter im)
           
 void removeControlPoint(Vector3f controlPoint)
          remove the controlPoint from the spline
 void setCurveTension(float curveTension)
          sets the curve tension
 void setCycle(boolean cycle)
          set to true to make the spline cycle
 void setType(Spline.SplineType type)
          Sets the type of the spline
 void write(JmeExporter ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Bezier 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,
              java.util.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 type of the curve is Bezier 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(java.util.List<Vector4f> controlPoints,
              java.util.List<java.lang.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 Detail

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)
Iterpolate a position on the spline

Parameters:
value - a value from 0 to 1 that represent the postion between the curent 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


setCurveTension

public void setCurveTension(float curveTension)
sets the curve tension

Parameters:
curveTension - the tension

isCycle

public boolean isCycle()
returns true if the spline cycle


setCycle

public void setCycle(boolean cycle)
set to true to make the spline cycle

Parameters:
cycle -

getTotalLength

public float getTotalLength()
return the total lenght of the spline


getType

public Spline.SplineType getType()
return the type of the spline


setType

public void setType(Spline.SplineType type)
Sets the type of the spline

Parameters:
type -

getControlPoints

public java.util.List<Vector3f> getControlPoints()
returns this spline control points


getSegmentsLength

public java.util.List<java.lang.Float> getSegmentsLength()
returns a list of float representing the segments lenght


getMinNurbKnot

public float getMinNurbKnot()
This method returns the minimum nurb curve knot value. Check the nurb type before calling this method. It the curve is not of a Nurb type - 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. It the curve is not of a Nurb type - NPE will be thrown.

Returns:
the maximum nurb curve knot value

getKnots

public java.util.List<java.lang.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 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