76 lines
2.4 KiB
C++
76 lines
2.4 KiB
C++
|
|
#ifndef ODEWORLD_H
|
|
#define ODEWORLD_H
|
|
|
|
#include <ode/ode.h>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
class OdeWorld
|
|
{
|
|
public:
|
|
OdeWorld();
|
|
~OdeWorld();
|
|
|
|
class Object
|
|
{
|
|
public:
|
|
Object(bool is_static, dWorldID world, dSpaceID space,
|
|
float scale = 1.0f);
|
|
Object(const Object & orig);
|
|
~Object();
|
|
|
|
void setPosition(double x, double y, double z);
|
|
void getPosition(double * x, double * y, double * z);
|
|
void setRotation(dReal x, dReal y, dReal z);
|
|
const dReal * getPosition();
|
|
const dReal * getRotation();
|
|
bool addCube(const std::vector<float> args);
|
|
bool addSphere(const std::vector<float> args);
|
|
bool addCylinder(const std::vector<float> args);
|
|
bool addCCylinder(const std::vector<float> args);
|
|
bool addPlane(const std::vector<float> args);
|
|
void addForce(dReal fx, dReal fy, dReal fz);
|
|
void addRelForce(dReal fx, dReal fy, dReal fz);
|
|
void addTorque(dReal fx, dReal fy, dReal fz);
|
|
void addRelTorque(dReal fx, dReal fy, dReal fz);
|
|
void finalize();
|
|
|
|
protected:
|
|
bool m_is_static;
|
|
dBodyID m_body;
|
|
dMass m_mass;
|
|
dWorldID m_world;
|
|
dSpaceID m_space;
|
|
std::vector<dGeomID> m_geoms;
|
|
float m_scale;
|
|
dReal m_position[3];
|
|
dReal m_rotation[12];
|
|
|
|
void setupGeom(dGeomID geom, dMass * mass,
|
|
float locx, float locy, float locz,
|
|
float rotx, float roty, float rotz);
|
|
dGeomID cloneGeom(dGeomID geom, dBodyID body);
|
|
};
|
|
|
|
Object * createObject(bool is_static, float scale = 1.0f);
|
|
void setGravity(float x, float y, float z)
|
|
{
|
|
dWorldSetGravity(m_world, x, y, z);
|
|
}
|
|
void step();
|
|
|
|
friend void OdeWorld_collide_callback(void * data,
|
|
dGeomID o1, dGeomID o2);
|
|
|
|
static void pushTransform(const dReal * pos, const dReal * R);
|
|
|
|
protected:
|
|
dWorldID m_world;
|
|
dSpaceID m_space;
|
|
dJointGroupID m_contactJointGroup;
|
|
};
|
|
|
|
#endif
|