67 lines
2.1 KiB
C++
67 lines
2.1 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);
|
|
|
|
void loadPhy(const std::string & path);
|
|
void setPosition(double x, double y, double z);
|
|
void getPosition(double * x, double * y, double * z);
|
|
|
|
protected:
|
|
bool m_is_static;
|
|
dBodyID m_body;
|
|
std::vector<dGeomID> m_geoms;
|
|
};
|
|
|
|
void setGravity(float x, float y, float z)
|
|
{
|
|
dWorldSetGravity(m_world, x, y, z);
|
|
}
|
|
void step();
|
|
std::vector<dGeomID> loadPhy(const std::string & path,
|
|
dBodyID * body, bool is_static = false);
|
|
dGeomID addCube(const std::string & name, bool is_static,
|
|
dBodyID * body, const std::vector<float> args);
|
|
dGeomID addSphere(const std::string & name, bool is_static,
|
|
dBodyID * body, const std::vector<float> args);
|
|
dGeomID addCylinder(const std::string & name, bool is_static,
|
|
dBodyID * body, const std::vector<float> args);
|
|
dGeomID addCCylinder(const std::string & name, bool is_static,
|
|
dBodyID * body, const std::vector<float> args);
|
|
dGeomID addPlane(const std::string & name, bool is_static,
|
|
dBodyID * body, const std::vector<float> args);
|
|
|
|
friend void OdeWorld_collide_callback(void * data,
|
|
dGeomID o1, dGeomID o2);
|
|
|
|
static void pushTransform(const float pos[3], const float R[12]);
|
|
|
|
protected:
|
|
dWorldID m_world;
|
|
dSpaceID m_space;
|
|
dJointGroupID m_contactJointGroup;
|
|
std::map<std::string, dGeomID> m_objects;
|
|
|
|
void setupGeom(const std::string & name, bool is_static,
|
|
dBodyID * body, dGeomID geom, dMass * mass,
|
|
float locx, float locy, float locz,
|
|
float rotx, float roty, float rotz);
|
|
};
|
|
|
|
#endif
|