RenderWare V2.1

Previous Page Index Next Page

RwReal

RwSplineTransform(RwSpline *spline, RwSplinePath path, RwReal where, RwV3d *up, RwMatrix4d *matrix);

Description

Calculates a Frenet transform matrix at a specified parameter position on a spline and returns a measure of the path’s anti-clockwise curvature at this point. This matrix will transform a clump to the specified parameter position on the path with its "Look At" direction pointing tangent to the path, "Look Up" pointing according to ‘up’ and "Look At" pointing toward or away from the center of curvature.

Arguments

spline The spline curve.

path The type of spline path.

where The parameter position.

up An "up" vector. If up is NULL, RwSplineTransform() will produce a transform which aligns a clumps "Look Up" Y vector with the local Y vector of a Frenet frame. If up is non-NULL, RwSplineTransform() will produce a transform which aligns a clumps "Look Up" Y vector so as to remain upfacing with respect to this vector, in that its ‘Look Right’ vector will be normal to the ‘up’ vector..

matrix Pointer to the matrix the will receive the Frenet transform matrix.

Return Value

The curvature at the specified point if successful, and NULL otherwise.

Comments

If up is NULL, the returned matrix will always transform a clump’s "Look Right" vector to point toward the center of curvature - as though the clump were being swung on a rod extending this direction from this point. Since the clump’s "Look At" vector always transforms to a forward tangent along the spline, when the center of curvature lies to the right this can result in the clump’s "Look Up" vector rolling upside down since handedness is conserved. This behavior is not always desirable. Such rolling can be suppressed by specifying an appropriate up vector. RwSplineTransform() will suppress any roll relative to a specified up vector. For example, when modeling the motion of a car over a hilly road circuit, an up vector of [CREAL(0.0), CREAL(1.0), CREAL(0.0)] would give a transform in which the car turns around corners and "tilts" over hills but does not roll - the wheels stay on the ground. When specifying a non-NULL up vector, some restricted rolling or banking may be reintroduced by pre-concatenating a local Z rotation whose angle is driven by the anti-clockwise curvature value returned by RwSplineTransform(). When large and positive, this indicates a sharp anti-clockwise turn in the plane normal to the up vector; when zero this indicates no turn in the plane; when large and negative this indicates a sharp clockwise turn in the plane. An appropriate bank angle may be found with a function such as atan(curvature).

See Also

RwCreateSpline()

RwDestroySpline()

RwDuplicateSpline()

RwSplinePoint()

RwGetSplineData()

RwGetSplineNumPoints()

RwGetSplinePoint()

RwSetSplineData()

RwSetSplinePoint()