Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/ogreode/OgreOdeCollision.h @ 1919

Last change on this file since 1919 was 1919, checked in by rgrieder, 16 years ago

Added OgreODE to our source repository because already we really need the newest version. And there is no hope to find any packages under linux.
The files included should compile and link with Ogre 1.4/1.6 and ODE 0.9/0.10. I was only able to test Ogre 1.4 and ODE 0.9/.10 under msvc until now.

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