Class Curve

java.lang.Object
com.ardor3d.spline.Curve

public class Curve extends Object
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 Details

  • Method Details

    • toRenderablePoint

      public Point toRenderablePoint(int steps)
      Creates a new Point from the control points making up this curve. It will have the name point, 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 be null.
    • toRenderablePoint

      public Point toRenderablePoint(int start, int end, int steps)
      Creates a new Point from the given control point indices. It will have the name point, 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 than end.
      end - The index of the control point to end with, must be less than controlPointCount minus one and greater than start.
      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 be null.
    • toRenderableLine

      public Line toRenderableLine(int steps)
      Creates a new Line from the control points making up this curve. It will have the name curve, 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 be null.
    • toRenderableLine

      public Line toRenderableLine(int start, int end, int steps)
      Creates a new Line from the given control point indices. It will have the name curve, 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 than end.
      end - The index of the control point to end with, must be less than controlPointCount minus one and greater than start.
      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 be null.
    • 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 the getApproximateLength(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 than end.
      end - The index of the control point to end with, must be less than controlPointCount minus one and greater than start.
      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

      public ReadOnlyVector3 interpolate(int start, int end, double t)
      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 point start while one will return end, a value in between will return an interpolated vector between the two.
      Returns:
      The interpolated vector.
    • interpolate

      public ReadOnlyVector3 interpolate(int start, int end, double t, Vector3 result)
      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 point start while one will return end, 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

      public void setControlPoints(List<ReadOnlyVector3> controlPoints)
      Parameters:
      controlPoints - The new control points, can not be null.
      See Also:
    • getControlPoints

      public List<ReadOnlyVector3> getControlPoints()
      Returns:
      The control points making up this curve, will not be null.
      See Also:
    • setSpline

      public void setSpline(Spline spline)
      Parameters:
      spline - The new spline, can not be null.
      See Also:
    • getSpline

      public Spline getSpline()
      The default is a CatmullRomSpline.
      Returns:
      The spline, will not be null.
      See Also: