replaced setupBody() with setupGeom()
git-svn-id: svn://anubis/misc/OdeWorld@151 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
a60a729b49
commit
925140f3fb
40
OdeWorld.cc
40
OdeWorld.cc
@ -143,20 +143,15 @@ vector<dGeomID> OdeWorld::loadPhy(const std::string & path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OdeWorld::setupBody(bool static_data, dBodyID * body)
|
||||
{
|
||||
if (!static_data && *body == 0)
|
||||
*body = dBodyCreate(m_world);
|
||||
}
|
||||
|
||||
dGeomID OdeWorld::addCube(const string & name, bool static_data,
|
||||
dBodyID * body, const vector<float> args)
|
||||
{
|
||||
if (args.size() != 9)
|
||||
return 0;
|
||||
setupBody(static_data, body);
|
||||
dGeomID id = dCreateBox(m_space, args[0], args[1], args[2]);
|
||||
dGeomSetBody(id, *body);
|
||||
setupGeom(name, static_data, body, id, true,
|
||||
args[3], args[4], args[5],
|
||||
args[6], args[7], args[8]);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -165,9 +160,10 @@ dGeomID OdeWorld::addSphere(const string & name, bool static_data,
|
||||
{
|
||||
if (args.size() != 4)
|
||||
return 0;
|
||||
setupBody(static_data, body);
|
||||
dGeomID id = dCreateSphere(m_space, args[0]);
|
||||
dGeomSetBody(id, *body);
|
||||
setupGeom(name, static_data, body, id, true,
|
||||
args[1], args[2], args[3],
|
||||
0.0, 0.0, 0.0);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -176,9 +172,10 @@ dGeomID OdeWorld::addCylinder(const string & name, bool static_data,
|
||||
{
|
||||
if (args.size() != 8)
|
||||
return 0;
|
||||
setupBody(static_data, body);
|
||||
dGeomID id = dCreateCylinder(m_space, args[0], args[1]);
|
||||
dGeomSetBody(id, *body);
|
||||
setupGeom(name, static_data, body, id, true,
|
||||
args[2], args[3], args[4],
|
||||
args[5], args[6], args[7]);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -187,9 +184,10 @@ dGeomID OdeWorld::addCCylinder(const string & name, bool static_data,
|
||||
{
|
||||
if (args.size() != 8)
|
||||
return 0;
|
||||
setupBody(static_data, body);
|
||||
dGeomID id = dCreateCCylinder(m_space, args[0], args[1]);
|
||||
dGeomSetBody(id, *body);
|
||||
setupGeom(name, static_data, body, id, true,
|
||||
args[2], args[3], args[4],
|
||||
args[5], args[6], args[7]);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -198,10 +196,22 @@ dGeomID OdeWorld::addPlane(const string & name, bool static_data,
|
||||
{
|
||||
if (args.size() != 6)
|
||||
return 0;
|
||||
setupBody(static_data, body);
|
||||
float a, b, c, d;
|
||||
/* TODO: find a, b, c, d from args */
|
||||
dGeomID id = dCreatePlane(m_space, a, b, c, d);
|
||||
setupGeom(name, static_data, body, id, false,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
return id;
|
||||
}
|
||||
|
||||
void OdeWorld::setupGeom(const std::string & name, bool static_data,
|
||||
dBodyID * body, dGeomID geom, bool placeable,
|
||||
float locx, float locy, float locz,
|
||||
float rotx, float roty, float rotz)
|
||||
{
|
||||
if (placeable && !static_data && *body == 0)
|
||||
*body = dBodyCreate(m_world);
|
||||
if (placeable)
|
||||
dGeomSetBody(geom, *body);
|
||||
/* TODO: set up mass, location, and rotation */
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <ode/ode.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
class OdeWorld
|
||||
{
|
||||
@ -36,8 +37,12 @@ class OdeWorld
|
||||
dWorldID m_world;
|
||||
dSpaceID m_space;
|
||||
dJointGroupID m_contactJointGroup;
|
||||
std::map<std::string, dGeomID> m_objects;
|
||||
|
||||
void setupBody(bool static_data, dBodyID * body);
|
||||
void setupGeom(const std::string & name, bool static_data,
|
||||
dBodyID * body, dGeomID geom, bool placeable,
|
||||
float locx, float locy, float locz,
|
||||
float rotx, float roty, float rotz);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user