Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

path.h

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 
00022 #include "csgeom/spline.h"
00023 
00030 class csPath : public csCatmullRomSpline
00031 {
00032 private:
00033   void SetVectorAsDimensionValues (int dim, csVector3* v)
00034   {
00035     int i;
00036     float* x, * y, * z;
00037     x = new float [GetPointCount ()];
00038     y = new float [GetPointCount ()];
00039     z = new float [GetPointCount ()];
00040     for (i = 0 ; i < GetPointCount () ; i++)
00041     {
00042       x[i] = v[i].x;
00043       y[i] = v[i].y;
00044       z[i] = v[i].z;
00045     }
00046     SetDimensionValues (dim+0, x);
00047     SetDimensionValues (dim+1, y);
00048     SetDimensionValues (dim+2, z);
00049     delete[] x;
00050     delete[] y;
00051     delete[] z;
00052   }
00053 
00054 public:
00056   csPath (int p) : csCatmullRomSpline (9, p) { }
00057 
00059   virtual ~csPath () { }
00060 
00062   void SetPositionVectors (csVector3* v)
00063   {
00064     SetVectorAsDimensionValues (0, v);
00065   }
00067   void SetUpVectors (csVector3* v)
00068   {
00069     SetVectorAsDimensionValues (3, v);
00070   }
00072   void SetForwardVectors (csVector3* v)
00073   {
00074     SetVectorAsDimensionValues (6, v);
00075   }
00077   void SetPositionVector (int idx, const csVector3& v)
00078   {
00079     SetDimensionValue (0, idx, v.x);
00080     SetDimensionValue (1, idx, v.y);
00081     SetDimensionValue (2, idx, v.z);
00082   }
00084   void SetUpVector (int idx, const csVector3& v)
00085   {
00086     SetDimensionValue (3, idx, v.x);
00087     SetDimensionValue (4, idx, v.y);
00088     SetDimensionValue (5, idx, v.z);
00089   }
00091   void SetForwardVector (int idx, const csVector3& v)
00092   {
00093     SetDimensionValue (6, idx, v.x);
00094     SetDimensionValue (7, idx, v.y);
00095     SetDimensionValue (8, idx, v.z);
00096   }
00098   void GetPositionVector (int idx, csVector3& v)
00099   {
00100     v.x = GetDimensionValue (0, idx);
00101     v.y = GetDimensionValue (1, idx);
00102     v.z = GetDimensionValue (2, idx);
00103   }
00105   void GetUpVector (int idx, csVector3& v)
00106   {
00107     v.x = GetDimensionValue (3, idx);
00108     v.y = GetDimensionValue (4, idx);
00109     v.z = GetDimensionValue (5, idx);
00110   }
00112   void GetForwardVector (int idx, csVector3& v)
00113   {
00114     v.x = GetDimensionValue (6, idx);
00115     v.y = GetDimensionValue (7, idx);
00116     v.z = GetDimensionValue (8, idx);
00117   }
00118 
00120   void GetInterpolatedPosition (csVector3& pos)
00121   {
00122     pos.x = GetInterpolatedDimension (0);
00123     pos.y = GetInterpolatedDimension (1);
00124     pos.z = GetInterpolatedDimension (2);
00125   }
00127   void GetInterpolatedUp (csVector3& pos)
00128   {
00129     pos.x = GetInterpolatedDimension (3);
00130     pos.y = GetInterpolatedDimension (4);
00131     pos.z = GetInterpolatedDimension (5);
00132   }
00134   void GetInterpolatedForward (csVector3& pos)
00135   {
00136     pos.x = GetInterpolatedDimension (6);
00137     pos.y = GetInterpolatedDimension (7);
00138     pos.z = GetInterpolatedDimension (8);
00139   }
00140 };
00141 
00142 #endif // __CS_PATH_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000