Game Development Reference
In-Depth Information
Figure 8.11 Catmull-Rom spline with the minimum four points.
Given this set of four control points, it is then possible to compute the position on
the spline at any t value between 0 and 1 using the following equation:
Note that this equation only works if there is uniform spacing between the control
points.Inanyevent,withthisequationinhand,asimpleCatmull-Rom splineclass
that supports an arbitrary number of points could be implemented as follows:
Click here to view code image
class CRSpline
// Vector (dynamic array) of Vector3s
Vector controlPoints
// First parameter is the control point that
corresponds to t=0
// Second parameter is the t value
function Compute( int start , float t )
// Check that start - 1, start, start + 1,
and start + 2
// all exist
Search WWH ::




Custom Search