added createObject() factory method, get position/rotation functions for Objects

git-svn-id: svn://anubis/misc/OdeWorld@162 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2009-10-08 04:11:43 +00:00
parent 3c6d089a47
commit ccb6708633
2 changed files with 34 additions and 0 deletions

View File

@ -80,6 +80,11 @@ void OdeWorld::step()
dJointGroupEmpty(m_contactJointGroup);
}
OdeWorld::Object * OdeWorld::createObject(bool is_static)
{
return new Object(is_static, m_world, m_space);
}
/* push an OpenGL matrix onto the matrix stack for a given
* ODE body position and rotation */
void OdeWorld::pushTransform(const float pos[3], const float R[12])
@ -306,3 +311,29 @@ void OdeWorld::Object::setupGeom(dGeomID geom, dMass * mass,
dBodySetMass(m_body, &origmass);
}
}
const dReal * OdeWorld::Object::getPosition()
{
if (m_body != NULL)
{
return dBodyGetPosition(m_body);
}
else if (m_geoms.size() > 0)
{
return dGeomGetPosition(m_geoms[0]);
}
return NULL;
}
const dReal * OdeWorld::Object::getRotation()
{
if (m_body != NULL)
{
return dBodyGetRotation(m_body);
}
else if (m_geoms.size() > 0)
{
return dGeomGetRotation(m_geoms[0]);
}
return NULL;
}

View File

@ -21,6 +21,8 @@ class OdeWorld
void loadPhy(const std::string & path);
void setPosition(double x, double y, double z);
void getPosition(double * x, double * y, double * z);
const dReal * getPosition();
const dReal * getRotation();
std::vector<dGeomID> loadPhy(const std::string & path,
dBodyID * body, bool is_static = false);
void addCube(const std::vector<float> args);
@ -42,6 +44,7 @@ class OdeWorld
};
Object * createObject(bool is_static);
void setGravity(float x, float y, float z)
{
dWorldSetGravity(m_world, x, y, z);