| [1919] | 1 | #ifndef _OGREODECOLLISION_H_ | 
|---|
 | 2 | #define _OGREODECOLLISION_H_ | 
|---|
 | 3 |  | 
|---|
 | 4 | #include "OgreOdePreReqs.h" | 
|---|
| [1923] | 5 | #include <OgreVector3.h> | 
|---|
| [1919] | 6 |  | 
|---|
 | 7 | namespace OgreOde  | 
|---|
 | 8 | { | 
|---|
 | 9 |         class _OgreOdeExport CollisionListener | 
|---|
 | 10 |         { | 
|---|
 | 11 |         public: | 
|---|
 | 12 |                 CollisionListener(); | 
|---|
 | 13 |                 virtual ~CollisionListener(); | 
|---|
 | 14 |  | 
|---|
 | 15 |                 virtual bool collision(Contact* contact) = 0; | 
|---|
 | 16 |         }; | 
|---|
 | 17 |  | 
|---|
 | 18 |  | 
|---|
 | 19 |         /** Using the default collisionCallbacks provided here will use the internal collisions setting of  | 
|---|
 | 20 |                 of the space.  | 
|---|
 | 21 |                 The space collide function now takes a bool useInternalCollisionFlag if you want internal collisions. | 
|---|
 | 22 |         */ | 
|---|
 | 23 |         class _OgreOdeExport CollisionCallback : public CollisionListener | 
|---|
 | 24 |         { | 
|---|
 | 25 |         public: | 
|---|
 | 26 |          | 
|---|
 | 27 |                 friend class Space; | 
|---|
 | 28 |                 friend class Geometry; | 
|---|
 | 29 |          | 
|---|
 | 30 |                 CollisionCallback(); | 
|---|
 | 31 |                 virtual ~CollisionCallback(); | 
|---|
 | 32 |                  | 
|---|
 | 33 |                 /** handles the ode callback and passes on to pure virtual methods that inherited classes implement | 
|---|
 | 34 |                 */ | 
|---|
 | 35 |                 static void collisionCallback(void *data, dGeomID geom_a, dGeomID geom_b); | 
|---|
 | 36 |  | 
|---|
 | 37 |                 /** user impliemented | 
|---|
 | 38 |                 */ | 
|---|
 | 39 |                 virtual void collisionCallback(OgreOde::Space* spaceFirst, OgreOde::Space* spaceSecond); | 
|---|
 | 40 |                  | 
|---|
 | 41 |                 virtual void collisionCallback(OgreOde::Space* space, OgreOde::Geometry* geometry); | 
|---|
 | 42 |                  | 
|---|
 | 43 |                 virtual void collisionCallback(OgreOde::Space* space); | 
|---|
 | 44 |                  | 
|---|
 | 45 |                 // This is down to a AABB level of the geometry, call collide() in here to go down further. | 
|---|
 | 46 |                 virtual void collisionCallback(OgreOde::Geometry* geometryFirst, OgreOde::Geometry* geometrySecond); | 
|---|
 | 47 |         }; | 
|---|
 | 48 |  | 
|---|
 | 49 |  | 
|---|
 | 50 |         class _OgreOdeExport Contact | 
|---|
 | 51 |         { | 
|---|
 | 52 |                 friend class Geometry; | 
|---|
 | 53 |                 friend class ContactMapCollisionListener; | 
|---|
 | 54 |          | 
|---|
 | 55 |         public: | 
|---|
 | 56 |                 enum Flag | 
|---|
 | 57 |                 { | 
|---|
 | 58 |                         Flag_UseAdditionalFriction                      = dContactMu2, | 
|---|
 | 59 |                         Flag_UseFirstFrictionDirection          = dContactFDir1, | 
|---|
 | 60 |                         Flag_SurfaceIsBouncy                            = dContactBounce, | 
|---|
 | 61 |                         Flag_UseERP                                                     = dContactSoftERP, | 
|---|
 | 62 |                         Flag_UseCFM                                                     = dContactSoftCFM, | 
|---|
 | 63 |                         Flag_IndependentMotion                          = dContactMotion1,  | 
|---|
 | 64 |                         Flag_AdditionalIndependentMotion        = dContactMotion2, | 
|---|
 | 65 |                         Flag_UseFDS                                                     = dContactSlip1, | 
|---|
 | 66 |                         Flag_UseAdditionalFDS                           = dContactSlip2, | 
|---|
 | 67 |                         Flag_FrictionPyramid                            = dContactApprox1_1, | 
|---|
 | 68 |                         Flag_AdditionalFrictionPyramid          = dContactApprox1_2, | 
|---|
 | 69 |                         Flag_BothFrictionPyramids                       = dContactApprox1  | 
|---|
 | 70 |                 }; | 
|---|
 | 71 |  | 
|---|
 | 72 |         public: | 
|---|
 | 73 |                 Contact(); | 
|---|
 | 74 |                 ~Contact(); | 
|---|
 | 75 |  | 
|---|
 | 76 |                 const Ogre::Vector3& getPosition(); | 
|---|
 | 77 |                 const Ogre::Vector3& getNormal(); | 
|---|
 | 78 |                 Ogre::Real getPenetrationDepth(); | 
|---|
 | 79 |  | 
|---|
 | 80 |         int getFirstSide(); | 
|---|
 | 81 |         int getSecondSide(); | 
|---|
 | 82 |  | 
|---|
 | 83 |                 Geometry* getFirstGeometry(); | 
|---|
 | 84 |                 Geometry* getSecondGeometry(); | 
|---|
 | 85 |  | 
|---|
 | 86 |                 void setFirstFrictionDirection(const Ogre::Vector3& vector); | 
|---|
 | 87 |                 void setFrictionMode(Contact::Flag flag); | 
|---|
 | 88 |  | 
|---|
 | 89 |                 void setCoulombFriction(Ogre::Real mu, Ogre::Real additional_mu = -1.0); | 
|---|
 | 90 |                 void setBouncyness(Ogre::Real bouncyness, Ogre::Real velocity_threshold = -1.0); | 
|---|
 | 91 |                 void setSoftness(Ogre::Real ERP, Ogre::Real CFM); | 
|---|
 | 92 |                 void setIndependentMotion(Ogre::Real velocity, Ogre::Real additional_velocity = -1.0); | 
|---|
 | 93 |                 void setForceDependentSlip(Ogre::Real FDS); | 
|---|
 | 94 |                 void setAdditionalFDS(Ogre::Real FDS); | 
|---|
 | 95 |  | 
|---|
 | 96 |                 inline void setContact(dContact* contact) | 
|---|
 | 97 |                 { | 
|---|
 | 98 |                         _contact = contact; | 
|---|
 | 99 |                         _contact->surface.mode = 0; | 
|---|
 | 100 |                 } | 
|---|
 | 101 |         protected: | 
|---|
 | 102 |                 inline Contact& operator=(dContact* contact) | 
|---|
 | 103 |                 { | 
|---|
 | 104 |                         _contact = contact; | 
|---|
 | 105 |                         _contact->surface.mode = 0; | 
|---|
 | 106 |                         return *this; | 
|---|
 | 107 |                 } | 
|---|
 | 108 |  | 
|---|
 | 109 |         protected: | 
|---|
 | 110 |                 dContact* _contact; | 
|---|
 | 111 |                 Ogre::Vector3 _position,_normal; | 
|---|
 | 112 |         }; | 
|---|
 | 113 |  | 
|---|
 | 114 |         class _OgreOdeExport ContactMapCollisionListener:public CollisionListener | 
|---|
 | 115 |         { | 
|---|
 | 116 |         public: | 
|---|
 | 117 |                 ContactMapCollisionListener(); | 
|---|
 | 118 |                 virtual ~ContactMapCollisionListener(); | 
|---|
 | 119 |  | 
|---|
 | 120 |                 virtual bool collision(Contact* contact); | 
|---|
 | 121 |  | 
|---|
 | 122 |                 void createContact(MaterialID materialA,MaterialID materialB);  | 
|---|
 | 123 |                 Contact *getContactPtr(MaterialID materialA,MaterialID materialB);  | 
|---|
 | 124 |  | 
|---|
 | 125 |         protected: | 
|---|
 | 126 |                 std::map<MaterialID,MaterialMap* > _map; | 
|---|
 | 127 |         }; | 
|---|
 | 128 | } | 
|---|
 | 129 |  | 
|---|
 | 130 | #endif | 
|---|