Game Development Reference
In-Depth Information
is based on Radu Gruian's C++ Overhauser code (
http://www.codeproject.com/
KB/recipes/Overhauser.aspx
—the Code Project website may require you to
register before it allows you to view the article. Registration is free. ).
public class Spline
{
List
<
Vector
>
_points
¼
new List
<
Vector
>
();
double _segmentSize
¼
0;
public void AddPoint(Vector point)
{
_points.Add(point);
_segmentSize
¼
1 / (double)_points.Count;
}
private int LimitPoints(int point)
{
if(point
<
0)
{
return 0;
}
else if (point
>
_points.Count - 1)
{
return _points.Count - 1;
}
else
{
return point;
}
}
// t ranges from 0 - 1
public Vector GetPositionOnLine(double t)
{
if (_points.Count
<
=1)
{
return new Vector(0,0,0);
}
// Get the segment of the line we're dealing with.
int interval
¼
(int)(t / _segmentSize);
// Get the points around the segment
int p0
¼
LimitPoints(interval - 1);
Search WWH ::
Custom Search