lugre_ode.h

Go to the documentation of this file.
00001 #ifndef _LUGRE_ODE_H_
00002 #define _LUGRE_ODE_H_
00003 
00004 #include "lugre_prefix.h"
00005 #include "lugre_listener.h"
00006 
00007 #ifdef ENABLE_ODE
00008 
00009 void    RegisterLua_Ode_GlobalFunctions (lua_State* L);
00010 void    OdeLuaRegister(lua_State* L);
00011 
00012 #include <list>
00013 #include <boost/timer.hpp>
00014 
00015 namespace ODE {
00016 #include <ode/ode.h>
00017 }
00018 
00019 namespace Lugre {
00020 
00021 class cOdeObject;
00022 class cOdeWorld;
00023 
00025 class cOdeObject : public cSmartPointable {
00026     friend class cOdeWorld;
00027 public:
00029     cOdeObject(cOdeWorld* world, const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00030 
00033     void DeleteShape();
00035     void SetShapeSphere(const ODE::dReal radius, const ODE::dReal mass);
00037     void SetShapeBox(const ODE::dReal mass, const ODE::dReal lx, const ODE::dReal ly, const ODE::dReal lz);
00039     void SetPosition(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00040     void GetPosition(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z);
00041     void SetRotation(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z, const ODE::dReal w);
00042     void GetRotation(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z, ODE::dReal &w);
00043     
00044     void SetLinearVelocity(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00045     void GetLinearVelocity(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z);
00046     void SetAngularVelocity(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00047     void GetAngularVelocity(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z);
00048 
00049     void SetTorque(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00050     void GetTorque(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z);
00051 
00052     void SetForce(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00053     void GetForce(ODE::dReal &x, ODE::dReal &y, ODE::dReal &z);
00054 
00056     void GetAABB(ODE::dReal* aabb);
00057     
00060     void AddForce(const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz);
00062     void AddRelForce(const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz);
00064     void AddForceAtPos(
00065         const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz,
00066         const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00068     void AddForceAtRelPos(
00069         const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz,
00070         const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00071     void AddRelForceAtPos(
00072         const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz,
00073         const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00074     void AddRelForceAtRelPos(
00075         const ODE::dReal fx, const ODE::dReal fy, const ODE::dReal fz,
00076         const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00077 
00079     void SetEnabled(const bool enabled);
00080     bool IsEnabled();
00081 
00083     void SetAutoDisableFlag(bool enabled);
00084     bool IsAutoDisableFlagEnabeled();
00085 
00087     void GetRelPosVel(const ODE::dReal lx, const ODE::dReal ly, const ODE::dReal lz,
00088         ODE::dReal &vx, ODE::dReal &vy, ODE::dReal &vz);
00089 
00090     virtual ~cOdeObject();
00091 
00092 private:
00093 
00094     ODE::dBodyID    moBody;
00095     ODE::dGeomID    moGeom;
00096     ODE::dMass      mMass;
00097     cOdeWorld*  mpWorld;
00098 };
00099 
00101 class cOdeWorld : public cSmartPointable {
00102     friend class cOdeObject;
00103 public:
00104     cOdeWorld(float secondsByStep);
00105     ~cOdeWorld();
00106     
00108     void Step();
00109     
00111     void SetGravity(const ODE::dReal x, const ODE::dReal y, const ODE::dReal z);
00112     
00114     void HandleCollisionBetween(ODE::dGeomID o0, ODE::dGeomID o1);
00115     
00117     void SetAutoDisableFlag(bool enabled);
00118     bool IsAutoDisableFlagEnabeled();
00119     
00120 private:
00122     void KillDeadObjects();
00123     
00124     ODE::dWorldID       moWorld;
00125     ODE::dSpaceID       moSpace;
00126     ODE::dJointGroupID  moContactgroup;
00127     boost::timer        mTimer; 
00128     float               mfSecondsByStep;
00129     std::list<cOdeObject *> mlObject;
00130     std::list<cOdeObject *> mlDeadObject;
00131 };
00132 
00133 }
00134 
00135 #endif
00136 
00137 #endif

Generated on Wed May 23 06:00:13 2012 for cpp by  doxygen 1.5.6