Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_COLLISION_BASE_PHYSICS_OBJECT_H__
00009 #define __SP_COLLISION_BASE_PHYSICS_OBJECT_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spDimensionVector3D.hpp"
00014
00015
00016 namespace sp
00017 {
00018 namespace scene
00019 {
00020
00021
00022 class CollisionNode;
00023
00029 class SP_EXPORT BaseCollisionPhysicsObject
00030 {
00031
00032 public:
00033
00034 virtual ~BaseCollisionPhysicsObject();
00035
00036
00037
00038 void arrestGravityForces();
00039 void reduceVelocity(const dim::vector3df &FactorVec);
00040
00041
00042
00044 inline void setGravity(const dim::vector3df &Gravity)
00045 {
00046 Gravity_ = Gravity;
00047 }
00049 inline dim::vector3df getGravity() const
00050 {
00051 return Gravity_;
00052 }
00053
00058 inline void setMass(f32 Mass)
00059 {
00060 Mass_ = math::Max(math::ROUNDING_ERROR, Mass);
00061 }
00063 inline f32 getMass() const
00064 {
00065 return Mass_;
00066 }
00067
00069 inline void setFriction(f32 Friction)
00070 {
00071 Friction_ = math::MinMax(Friction, 0.0f, 1.0f);
00072 }
00074 inline f32 getFriction() const
00075 {
00076 return Friction_;
00077 }
00078
00079 inline void setForce(const dim::vector3df &Force)
00080 {
00081 Force_ = Force;
00082 }
00083 inline void addForce(const dim::vector3df &Force)
00084 {
00085 Force_ += Force;
00086 }
00087 inline dim::vector3df getForce() const
00088 {
00089 return Force_;
00090 }
00091
00092 inline void setVelocity(const dim::vector3df &Velocity)
00093 {
00094 Velocity_ = Velocity;
00095 }
00096 inline void addVelocity(const dim::vector3df &Velocity)
00097 {
00098 Velocity_ += Velocity;
00099 }
00100 inline dim::vector3df getVelocity() const
00101 {
00102 return Velocity_;
00103 }
00104
00105 protected:
00106
00107
00108
00109 BaseCollisionPhysicsObject();
00110
00112 void integrate(CollisionNode* Node);
00113
00114 void applyFriction();
00115
00116 private:
00117
00118
00119
00120 dim::vector3df Gravity_;
00121 dim::vector3df Force_;
00122 dim::vector3df Velocity_;
00123
00124 f32 Mass_;
00125 f32 Friction_;
00126
00127 };
00128
00129
00130 }
00131
00132 }
00133
00134
00135 #endif
00136
00137
00138
00139