00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_PATH_H__
00020 #define __CS_PATH_H__
00021
00028 #include "csgeom/spline.h"
00029
00036 class csPath : public csCatmullRomSpline
00037 {
00038 private:
00039 void SetVectorAsDimensionValues (int dim, csVector3* v)
00040 {
00041 int i;
00042 float* x, * y, * z;
00043 x = new float [GetPointCount ()];
00044 y = new float [GetPointCount ()];
00045 z = new float [GetPointCount ()];
00046 for (i = 0 ; i < GetPointCount () ; i++)
00047 {
00048 x[i] = v[i].x;
00049 y[i] = v[i].y;
00050 z[i] = v[i].z;
00051 }
00052 SetDimensionValues (dim+0, x);
00053 SetDimensionValues (dim+1, y);
00054 SetDimensionValues (dim+2, z);
00055 delete[] x;
00056 delete[] y;
00057 delete[] z;
00058 }
00059
00060 public:
00062 csPath (int p) : csCatmullRomSpline (9, p) { }
00063
00065 virtual ~csPath () { }
00066
00068 void SetPositionVectors (csVector3* v)
00069 {
00070 SetVectorAsDimensionValues (0, v);
00071 }
00073 void SetUpVectors (csVector3* v)
00074 {
00075 SetVectorAsDimensionValues (3, v);
00076 }
00078 void SetForwardVectors (csVector3* v)
00079 {
00080 SetVectorAsDimensionValues (6, v);
00081 }
00083 void SetPositionVector (int idx, const csVector3& v)
00084 {
00085 SetDimensionValue (0, idx, v.x);
00086 SetDimensionValue (1, idx, v.y);
00087 SetDimensionValue (2, idx, v.z);
00088 }
00090 void SetUpVector (int idx, const csVector3& v)
00091 {
00092 SetDimensionValue (3, idx, v.x);
00093 SetDimensionValue (4, idx, v.y);
00094 SetDimensionValue (5, idx, v.z);
00095 }
00097 void SetForwardVector (int idx, const csVector3& v)
00098 {
00099 SetDimensionValue (6, idx, v.x);
00100 SetDimensionValue (7, idx, v.y);
00101 SetDimensionValue (8, idx, v.z);
00102 }
00104 void GetPositionVector (int idx, csVector3& v)
00105 {
00106 v.x = GetDimensionValue (0, idx);
00107 v.y = GetDimensionValue (1, idx);
00108 v.z = GetDimensionValue (2, idx);
00109 }
00111 void GetUpVector (int idx, csVector3& v)
00112 {
00113 v.x = GetDimensionValue (3, idx);
00114 v.y = GetDimensionValue (4, idx);
00115 v.z = GetDimensionValue (5, idx);
00116 }
00118 void GetForwardVector (int idx, csVector3& v)
00119 {
00120 v.x = GetDimensionValue (6, idx);
00121 v.y = GetDimensionValue (7, idx);
00122 v.z = GetDimensionValue (8, idx);
00123 }
00124
00126 void GetInterpolatedPosition (csVector3& pos)
00127 {
00128 pos.x = GetInterpolatedDimension (0);
00129 pos.y = GetInterpolatedDimension (1);
00130 pos.z = GetInterpolatedDimension (2);
00131 }
00133 void GetInterpolatedUp (csVector3& pos)
00134 {
00135 pos.x = GetInterpolatedDimension (3);
00136 pos.y = GetInterpolatedDimension (4);
00137 pos.z = GetInterpolatedDimension (5);
00138 }
00140 void GetInterpolatedForward (csVector3& pos)
00141 {
00142 pos.x = GetInterpolatedDimension (6);
00143 pos.y = GetInterpolatedDimension (7);
00144 pos.z = GetInterpolatedDimension (8);
00145 }
00146 };
00147
00150 #endif // __CS_PATH_H__