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

coldetimpl.h

Go to the documentation of this file.
00001 #ifndef H_COLDET_IMPL
00002 #define H_COLDET_IMPL
00003 
00004 #include "coldet.h"
00005 #include "box.h"
00006 #include "math3d.h"
00007 #include <vector>
00008 
00009 __CD__BEGIN
00010 
00011 class CollisionModel3DImpl : public CollisionModel3D
00012 {
00013 public:
00014   CollisionModel3DImpl(bool Static);
00015   void setTriangleNumber(int num) { if (!m_Final) m_Triangles.reserve(num); }
00016 
00017   void addTriangle(float x1, float y1, float z1,
00018                    float x2, float y2, float z2,
00019                    float x3, float y3, float z3)
00020   {
00021     addTriangle(Vector3D(x1,y1,z1),
00022                 Vector3D(x2,y2,z2),
00023                 Vector3D(x3,y3,z3));
00024   }
00025   void addTriangle(float v1[3], float v2[3], float v3[3])
00026   {
00027     addTriangle(Vector3D(v1[0],v1[1],v1[2]),
00028                 Vector3D(v2[0],v2[1],v2[2]),
00029                 Vector3D(v3[0],v3[1],v3[2]));
00030   }
00031   void addTriangle(const Vector3D& v1, const Vector3D& v2, const Vector3D& v3);
00032   void finalize();
00033 
00034   void setTransform(float m[16]) { setTransform(*(Matrix3D*)m); }
00035   void setTransform(const Matrix3D& m);
00036 
00037   bool collision(CollisionModel3D* other, 
00038                  int AccuracyDepth, 
00039                  int MaxProcessingTime,
00040                  float* other_transform);
00041 
00042   bool rayCollision(float origin[3], float direction[3], bool closest,
00043                     float segmin, float segmax);
00044   bool sphereCollision(float origin[3], float radius);
00045 
00046   bool getCollidingTriangles(float t1[9], float t2[9], bool ModelSpace);
00047   bool getCollidingTriangles(int& t1, int& t2);
00048   bool getCollisionPoint(float p[3], bool ModelSpace);
00049 
00050 
00051   int getTriangleIndex(BoxedTriangle* bt)
00052   {
00053     return int(bt-m_Triangles.begin());
00054   }
00055 
00059   std::vector<BoxedTriangle> m_Triangles;
00061   BoxTreeInnerNode           m_Root;
00063   Matrix3D                   m_Transform,m_InvTransform;
00065   Triangle                   m_ColTri1,m_ColTri2;
00067   int                        m_iColTri1,m_iColTri2;
00069   Vector3D                   m_ColPoint;
00070 
00072   enum { Models, Ray, Sphere }       
00073                              m_ColType;
00075   bool                       m_Final;
00079   bool                       m_Static;
00080 };
00081 
00082 __CD__BEGIN
00083 
00084 #endif // H_COLDET_IMPL

Generated at Sat Nov 18 00:15:14 2000 for coldet by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000