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