Package com.jme3.math
Class Spline
java.lang.Object
com.jme3.math.Spline
- All Implemented Interfaces:
Savable
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionSpline()
Spline
(Spline.SplineType splineType, Vector3f[] controlPoints, float curveTension, boolean cycle) Create a splineSpline
(Spline.SplineType splineType, List<Vector3f> controlPoints, float curveTension, boolean cycle) Create a splineCreate a NURBS spline. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addControlPoint
(Vector3f controlPoint) Adds a controlPoint to the splinevoid
int
This method returns NURBS' spline basis function degree.returns this spline control pointsfloat
returns the curve tensiongetKnots()
This method returns NURBS' spline knots.float
This method returns the maximum nurb curve knot value.float
This method returns the minimum nurb curve knot value.returns a list of float representing the segments lengthfloat
getType()
return the type of the splinefloat[]
This method returns NURBS' spline weights.interpolate
(float value, int currentControlPoint, Vector3f store) Interpolate a position on the splineboolean
isCycle()
void
read
(JmeImporter im) De-serialize this spline from the specified importer, for example when loading from a J3O file.void
removeControlPoint
(Vector3f controlPoint) remove the controlPoint from the splinevoid
setCurveTension
(float curveTension) sets the curve tensionvoid
setCycle
(boolean cycle) set to true to make the spline cyclevoid
setType
(Spline.SplineType type) Sets the type of the splinevoid
write
(JmeExporter ex) Serialize this spline to the specified exporter, for example when saving to a J3O file.
-
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 splinecycle
- 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 splinecycle
- true if the spline cycle.
-
Spline
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 splinenurbKnots
- the nurb's spline knots
-
-
Method Details
-
addControlPoint
Adds a controlPoint to the spline- Parameters:
controlPoint
- a position in world space
-
removeControlPoint
remove the controlPoint from the spline- Parameters:
controlPoint
- the controlPoint to remove
-
clearControlPoints
public void clearControlPoints() -
interpolate
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 onecurrentControlPoint
- the current control pointstore
- 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
return the type of the spline- Returns:
- the enum value
-
setType
Sets the type of the spline- Parameters:
type
- Linear/CatmullRom/Bezier/Nurb
-
getControlPoints
returns this spline control points- Returns:
- the pre-existing list
-
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
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
Serialize this spline to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Parameters:
ex
- (not null)- Throws:
IOException
- from the exporter
-
read
De-serialize this spline from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Parameters:
im
- (not null)- Throws:
IOException
- from the importer
-