CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

path.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2001 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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__

Generated for Crystal Space by doxygen 1.2.14