Main Index : Reference :

SplineObject


Description

A spline object class.

Definition

class SplineObject : PointObject
{
public:
  SplineObject();

  [int] GetSegmentCount();
  [array] GetSegments();
  [bool] SetSegments([array] s);
  
  [array] GetTangents();
  [bool] SetTangents([array] t);

  [vector] GetSplinePoint([float] x, [int] segment);
  [vector] GetSplineTangent([float] x, [int] segment);

  [bool] InitLength([int] segment);
  [bool] FreeLength();

  [float] GetLength();
  [float] UniformToNatural([float] x);
}

Explanation

This is the class used for spline object. The spline settings are stored in the object's container. These are the valid container values:

Container ID Type/Range Explanation
SPLINEOBJECT_TYPE [int] Type (see dialog)
SPLINEOBJECT_INTERPOLATION [int] Interpolation type (see dialog)
SPLINEOBJECT_CLOSED [bool] Close spline
SPLINEOBJECT_SUB [int] Number of subdivision
SPLINEOBJECT_ANGLE [float] Angle

Members

GetSegmentCount()

[int] GetSegmentCount();

Returns the number of segements.

GetSegments()

[array] GetSegments();

Returns the segments as an array. Each element corresponds to a segment and tells how many points that segment has. The sum of all elements equals the total number of spline points.

SetSegments( s )

[bool] SetSegments([array] s);

Sets the segment array to s. Each element in the segment array should tell how many points that segment has. The sum of all elements should equal the total number of spline points. Returns TRUE if successful.


GetTangents()

[array] GetTangents();

Returns an array of all spline point tangents. The array is formatted like a hermite tag.

SetTangents( t )

[bool] SetTangents([array] t);

Sets all spline point tangents at the same time using the array t. The array should be formatted like a hermite tag. Returns TRUE if successful.


GetSplinePoint( x, segment )

[vector] GetSplinePoint([float] x, [int] segment);

Returns the position at the position x (0.0<=x<=1.0) along the specified segment. The positioning is natural, i.e. x=0.5 isn't necessarily at half the length. Use UniformToNatural() if you want to get a uniform distribution.

GetSplineTangent( x, segment )

[vector] GetSplineTangent([float] x, [int] segment);

Returns the tangent of the curve at the position x (0.0<=x<=1.0) along the specified segment. The positioning is natural, i.e. x=0.5 isn't necessarily at half the length. Use UniformToNatural() if you want to get a uniform distribution.


InitLength( segment )

[bool] InitLength([int] segment);

Must be called before using GetLength() and UniformToNatural(). The parameter decides what spline segment the calculations in those two functions will be performed on. Returns TRUE if successful.

Remember: InitLength() cannot be used on spline primitives. Use GetSplineObject() to get a real spline first.

FreeLength()

[bool] FreeLength();

Frees the memory used by the InitLength() function.


GetLength()

[float] GetLength();

Returns the length of the spline. Before using this function one must have called InitLength().

UniformToNatural( x )

[float] UniformToNatural([float] x);

Returns the natural position along the spline, to be used in GetSplinePoint() and GetSplineTangent(), from the uniform position x. The uniform position is with respect to the actual length of the spline, whereas the natural position only cares about the interpolation of the curve parameter. Before using this function one must have called InitLength().