Package com.ardor3d.spline
Class Curve
java.lang.Object
com.ardor3d.spline.Curve
Curve class contains a list of control points and a spline. It also contains method for visualising itself as a
renderable series of points or a line.
-
Constructor Summary
ConstructorDescriptionCurve
(List<ReadOnlyVector3> controlPoints, Spline spline) Creates a new instance ofCurve
. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getApproximateLength
(int steps) Calculates the length of this curve.double
getApproximateLength
(int start, int end, int steps) Calculates the length between the given control point indices.int
The default is aCatmullRomSpline
.interpolate
(int start, int end, double t) Interpolates between the control points at the given indices.interpolate
(int start, int end, double t, Vector3 result) Interpolates between the control points at the given indices.void
setControlPoints
(List<ReadOnlyVector3> controlPoints) void
toRenderableLine
(int steps) Creates a newLine
from the control points making up this curve.toRenderableLine
(int start, int end, int steps) Creates a newLine
from the given control point indices.toRenderablePoint
(int steps) Creates a newPoint
from the control points making up this curve.toRenderablePoint
(int start, int end, int steps) Creates a newPoint
from the given control point indices.
-
Constructor Details
-
Curve
Creates a new instance ofCurve
.- Parameters:
controlPoints
- seesetControlPoints(List)
spline
- seesetSpline(Spline)
-
-
Method Details
-
toRenderablePoint
Creates a newPoint
from the control points making up this curve. It will have the namepoint
, no normals, colour or texture, these can be added to the returned point if needed.- Parameters:
steps
- The number of iterations to perform between control points, the higher this number the more points will be shown, but it will also contain more vertices, must be greater than one. Use two to just show the actual control points set for the curve.- Returns:
- A
Point
containing all the curve points, will not benull
.
-
toRenderablePoint
Creates a newPoint
from the given control point indices. It will have the namepoint
, no normals, colour or texture, these can be added to the returned point if needed.- Parameters:
start
- The index of the control point to start from, must be greater than or equal to one and less thanend
.end
- The index of the control point to end with, must be less thancontrolPointCount
minus one and greater thanstart
.steps
- The number of iterations to perform between control points, the higher this number the more points will be shown, but it will also contain more vertices, must be greater than one.- Returns:
- A
Point
containing all the curve points, will not benull
.
-
toRenderableLine
Creates a newLine
from the control points making up this curve. It will have the namecurve
, no normals, colour or texture, these can be added to the returned line if needed.- Parameters:
steps
- The number of iterations to perform between control points, the higher this number the smoother the returned line will be, but it will also contain more vertices, must be greater than one.- Returns:
- A
Line
representing this curve, will not benull
.
-
toRenderableLine
Creates a newLine
from the given control point indices. It will have the namecurve
, no normals, colour or texture, these can be added to the returned line if needed.- Parameters:
start
- The index of the control point to start from, must be greater than or equal to one and less thanend
.end
- The index of the control point to end with, must be less thancontrolPointCount
minus one and greater thanstart
.steps
- The number of iterations to perform between control points, the higher this number the smoother the returned line will be, but it will also contain more vertices, must be greater than one.- Returns:
- A
Line
representing this curve, will not benull
.
-
getApproximateLength
public double getApproximateLength(int steps) Calculates the length of this curve.Important note:
To calculate the length of a curve it must be interpolated (hence the steps parameter), this method will do this EVERY time it's called (creating a lot of garbage vectors in the process). This has been done for the sake of keeping this class simple and the code as readable as possible. Therefore the length should be manually cached somewhere in your code if it is going to be used repeatedly.- Parameters:
steps
- The number of iterations to perform between control points, the higher this number the more accurate the returned result will be.- Returns:
- The length of this curve.
- See Also:
-
getApproximateLength
public double getApproximateLength(int start, int end, int steps) Calculates the length between the given control point indices.Important note:
See the Javadoc for thegetApproximateLength(int)
method for important information.- Parameters:
start
- The index of the control point to start from, must be greater than or equal to one and less thanend
.end
- The index of the control point to end with, must be less thancontrolPointCount
minus one and greater thanstart
.steps
- The number of iterations to perform between control points, the higher this number the more accurate the returned result will be.- Returns:
- The length between the given control points.
- See Also:
-
interpolate
Interpolates between the control points at the given indices.- Parameters:
start
- The index of the control point to start from.end
- The index of the control point to end at.t
- Should be between zero and one. Zero will return pointstart
while one will returnend
, a value in between will return an interpolated vector between the two.- Returns:
- The interpolated vector.
-
interpolate
Interpolates between the control points at the given indices.- Parameters:
start
- The index of the control point to start from.end
- The index of the control point to end at.t
- Should be between zero and one. Zero will return pointstart
while one will returnend
, a value in between will return an interpolated vector between the two.result
- The result of the interpolation will be stored in this vector.- Returns:
- The result vector as a convenience.
-
getControlPointCount
public int getControlPointCount()- Returns:
- The number of control points in this curve.
-
setControlPoints
- Parameters:
controlPoints
- The new control points, can not benull
.- See Also:
-
getControlPoints
- Returns:
- The control points making up this curve, will not be
null
. - See Also:
-
setSpline
- Parameters:
spline
- The new spline, can not benull
.- See Also:
-
getSpline
The default is aCatmullRomSpline
.- Returns:
- The spline, will not be
null
. - See Also:
-