[21] | 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 | Ogre::Matrix3 getLocalInertiaTensor() const; |
---|
| 41 | |
---|
| 42 | protected: |
---|
| 43 | const dMass* getMassPtr() const; |
---|
| 44 | dMass _mass; |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | class _OgreOdeExport SphereMass:public Mass |
---|
| 48 | { |
---|
| 49 | public: |
---|
| 50 | SphereMass(); |
---|
| 51 | SphereMass(Ogre::Real mass, Ogre::Real radius); |
---|
| 52 | ~SphereMass(); |
---|
| 53 | |
---|
| 54 | void setDensity(Ogre::Real density, Ogre::Real radius); |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | class _OgreOdeExport CapsuleMass:public Mass |
---|
| 58 | { |
---|
| 59 | public: |
---|
| 60 | CapsuleMass(); |
---|
| 61 | CapsuleMass(Ogre::Real mass, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length); |
---|
| 62 | ~CapsuleMass(); |
---|
| 63 | |
---|
| 64 | void setDensity(Ogre::Real density, Ogre::Real radius,const Ogre::Vector3& direction, Ogre::Real length); |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | class _OgreOdeExport CylinderMass:public Mass |
---|
| 68 | { |
---|
| 69 | public: |
---|
| 70 | CylinderMass(); |
---|
| 71 | CylinderMass(Ogre::Real mass,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length); |
---|
| 72 | ~CylinderMass(); |
---|
| 73 | |
---|
| 74 | void setDensity(Ogre::Real density,const Ogre::Vector3& direction, Ogre::Real radius, Ogre::Real length); |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | class _OgreOdeExport BoxMass:public Mass |
---|
| 78 | { |
---|
| 79 | public: |
---|
| 80 | BoxMass(); |
---|
| 81 | BoxMass(Ogre::Real mass,const Ogre::Vector3& size); |
---|
| 82 | ~BoxMass(); |
---|
| 83 | |
---|
| 84 | void setDensity(Ogre::Real density,const Ogre::Vector3& size); |
---|
| 85 | }; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | #endif |
---|