00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OXYGEN_BODY_H
00023 #define OXYGEN_BODY_H
00024
00025 #include "odeobject.h"
00026
00027 namespace oxygen
00028 {
00029 class World;
00030
00038 class Body : public ODEObject
00039 {
00040
00041
00042
00043 public:
00044 Body();
00045 virtual ~Body();
00046
00048 dBodyID GetODEBody() const;
00049
00057 void Enable();
00058
00060 void Disable();
00061
00063 bool IsEnabled() const;
00064
00069 void UseGravity(bool f);
00070
00073 bool UsesGravity() const;
00074
00076 void SetMass(float mass);
00077
00079 void SetMassParameters(const dMass& mass);
00080
00082 float GetMass() const;
00083
00085 void GetMassParameters(dMass& mass) const;
00086
00091 void SetSphere(float density, float radius);
00092
00097 void SetSphereTotal(float total_mass, float radius);
00098
00103 void SetBox(float density, const salt::Vector3f& size);
00104
00109 void SetBoxTotal(float total_mass, const salt::Vector3f& size);
00110
00117 void SetCylinder (float density, float radius, float length);
00118
00125 void SetCylinderTotal(float total_mass, float radius, float length);
00126
00127
00128
00129
00130
00131
00132
00133
00134 void SetCappedCylinder (float density, float radius, float length);
00135
00136
00137
00138
00139
00140
00141
00142
00143 void SetCappedCylinderTotal(float total_mass, float radius, float length);
00144
00146 salt::Vector3f GetVelocity() const;
00147
00149 void SetVelocity(const salt::Vector3f& vel);
00150
00152 void SetRotation(const salt::Matrix& rot);
00153
00155 salt::Vector3f GetAngularVelocity() const;
00156
00158 void SetAngularVelocity(const salt::Vector3f& vel);
00159
00161 static boost::shared_ptr<Body> GetBody(dBodyID id);
00162
00164 void AddForce(const salt::Vector3f& force);
00165
00167 void AddTorque(const salt::Vector3f& torque);
00168
00170 void SetPosition(const salt::Vector3f& pos);
00171
00173 salt::Vector3f GetPosition() const;
00174
00175 protected:
00179 virtual void OnLink();
00180
00182 bool CreateBody();
00183
00184 private:
00189 virtual void PostPhysicsUpdateInternal();
00190
00191
00192
00193
00194 protected:
00196 dBodyID mODEBody;
00197 };
00198
00199 DECLARE_CLASS(Body);
00200
00201 }
00202
00203 #endif //OXYGEN_BODY_H