00001 /* 00002 * Physics dynamic object header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_PHYSICS_DYNAMICOBJECT_H__ 00009 #define __SP_PHYSICS_DYNAMICOBJECT_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 00014 #ifdef SP_COMPILE_WITH_PHYSICS 00015 00016 00017 #include "Framework/Physics/spPhysicsBaseObject.hpp" 00018 00019 #include <boost/function.hpp> 00020 00021 00022 namespace sp 00023 { 00024 namespace physics 00025 { 00026 00027 00028 class DynamicPhysicsObject; 00029 00030 typedef boost::function<void (DynamicPhysicsObject* PhysicsObject)> PhysicsGravityCallback; 00031 00032 00033 class SP_EXPORT DynamicPhysicsObject : virtual public PhysicsBaseObject 00034 { 00035 00036 public: 00037 00038 virtual ~DynamicPhysicsObject(); 00039 00040 /* === Functions === */ 00041 00043 virtual void setGravity(const dim::vector3df &Gravity); 00044 00046 virtual void setMass(f32 Mass); 00047 00049 virtual void setAutoSleep(bool Enable); 00050 00052 virtual void setGravityCallback(const PhysicsGravityCallback &Callback); 00053 00055 virtual void setMassCenter(const dim::vector3df &LocalPoint) = 0; 00057 virtual dim::vector3df getMassCenter() const = 0; 00058 00059 virtual void addVelocity(const dim::vector3df &Direction) = 0; 00060 virtual void setVelocity(const dim::vector3df &Direction) = 0; 00061 virtual dim::vector3df getVelocity() const = 0; 00062 00068 virtual void addImpulse(const dim::vector3df &Direction, const dim::vector3df &PivotPoint) = 0; 00069 00074 virtual void setForce(const dim::vector3df &Direction) = 0; 00075 00076 /* === Inline functions === */ 00077 00079 inline dim::vector3df getGravity() const 00080 { 00081 return Gravity_; 00082 } 00084 inline f32 getMass() const 00085 { 00086 return Mass_; 00087 } 00089 inline bool getAutoSleep() const 00090 { 00091 return AutoSleep_; 00092 } 00094 inline PhysicsGravityCallback getGravityCallback() const 00095 { 00096 return GravityCallback_; 00097 } 00098 00099 protected: 00100 00101 DynamicPhysicsObject(); 00102 00103 /* === Members === */ 00104 00105 dim::vector3df Gravity_; 00106 f32 Mass_; 00107 bool AutoSleep_; 00108 00109 PhysicsGravityCallback GravityCallback_; 00110 00111 }; 00112 00113 00114 } // /namespace physics 00115 00116 } // /namespace sp 00117 00118 00119 #endif 00120 00121 #endif 00122 00123 00124 00125 // ================================================================================