[1919] | 1 | #ifndef _OGREODEMASS_H_ |
---|
| 2 | #define _OGREODEMASS_H_ |
---|
| 3 | |
---|
| 4 | #include "OgreOdePreReqs.h" |
---|
| 5 | |
---|
| 6 | namespace OgreOde |
---|
| 7 | { |
---|
| 8 | class _OgreOdeExport Mass |
---|
| 9 | { |
---|
| 10 | friend class Body; |
---|
| 11 | |
---|
| 12 | public: |
---|
| 13 | Mass(); |
---|
| 14 | Mass(Ogre::Real mass, const Ogre::Vector3& center_of_gravity, const Ogre::Matrix3& intertia_matrix); |
---|
| 15 | virtual ~Mass(); |
---|
| 16 | |
---|
| 17 | inline Mass(const Mass& other) |
---|
| 18 | { |
---|
| 19 | memcpy(&_mass,&(other._mass),sizeof(_mass)); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | inline Mass& operator=(const Mass& other) |
---|
| 23 | { |
---|
| 24 | memcpy(&_mass,&(other._mass),sizeof(_mass)); |
---|
| 25 | return *this; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | inline Mass& operator=(const dMass* other) |
---|
| 29 | { |
---|
| 30 | assert(other); |
---|
| 31 | memcpy(&_mass,other,sizeof(_mass)); |
---|
| 32 | return *this; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | void adjust(Ogre::Real mass); |
---|
| 36 | void translate(const Ogre::Vector3& offset); |
---|
| 37 | void rotate(const Ogre::Quaternion& orientation); |
---|
| 38 | void add(const Mass& other); |
---|
| 39 | |
---|
| 40 | // total mass of the rigid body |
---|
| 41 | Ogre::Real getMassValue() const; |
---|
| 42 | // center of gravity position in body frame (x,y,z) |
---|
| 43 | Ogre::Vector3 getCenterOfGravity() const; |
---|
| 44 | // 3x3 inertia tensor in body frame, about POR |
---|
| 45 | Ogre::Matrix3 getLocalInertiaTensor() const; |
---|
| 46 | |
---|
| 47 | protected: |
---|
| 48 | const dMass* getMassPtr() const; |
---|
| 49 | dMass _mass; |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | class _OgreOdeExport SphereMass:public Mass |
---|
| 53 | { |
---|
| 54 | public: |
---|
| 55 | SphereMass(); |
---|
| 56 | SphereMass(Ogre::Real mass, Ogre::Real radius); |
---|
| 57 | ~SphereMass(); |
---|
| 58 | |
---|
| 59 | void setDensity(Ogre::Real density, Ogre::Real radius); |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | // To add |
---|
| 63 | // void dMassSetTrimesh(dMass *, dReal density, dGeomID g) |
---|
| 64 | |
---|
| 65 | class _OgreOdeExport CapsuleMass:public Mass |
---|
| 66 | { |
---|
| 67 | public: |
---|
| 68 | CapsuleMass(); |
---|
| 69 | CapsuleMass(Ogre::Real mass, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length); |
---|
| 70 | ~CapsuleMass(); |
---|
| 71 | |
---|
| 72 | void setDensity(Ogre::Real density, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length); |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | class _OgreOdeExport CylinderMass:public Mass |
---|
| 76 | { |
---|
| 77 | public: |
---|
| 78 | CylinderMass(); |
---|
| 79 | CylinderMass(Ogre::Real mass,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length); |
---|
| 80 | ~CylinderMass(); |
---|
| 81 | |
---|
| 82 | void setDensity(Ogre::Real density,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length); |
---|
| 83 | }; |
---|
| 84 | |
---|
| 85 | class _OgreOdeExport BoxMass:public Mass |
---|
| 86 | { |
---|
| 87 | public: |
---|
| 88 | BoxMass(); |
---|
| 89 | BoxMass(Ogre::Real mass,const Ogre::Vector3& size); |
---|
| 90 | ~BoxMass(); |
---|
| 91 | |
---|
| 92 | void setDensity(Ogre::Real density,const Ogre::Vector3& size); |
---|
| 93 | }; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | #endif |
---|