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:
parent
3c6d089a47
commit
ccb6708633
31
OdeWorld.cc
31
OdeWorld.cc
@ -80,6 +80,11 @@ void OdeWorld::step()
|
|||||||
dJointGroupEmpty(m_contactJointGroup);
|
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
|
/* push an OpenGL matrix onto the matrix stack for a given
|
||||||
* ODE body position and rotation */
|
* ODE body position and rotation */
|
||||||
void OdeWorld::pushTransform(const float pos[3], const float R[12])
|
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);
|
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;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,8 @@ class OdeWorld
|
|||||||
void loadPhy(const std::string & path);
|
void loadPhy(const std::string & path);
|
||||||
void setPosition(double x, double y, double z);
|
void setPosition(double x, double y, double z);
|
||||||
void getPosition(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,
|
std::vector<dGeomID> loadPhy(const std::string & path,
|
||||||
dBodyID * body, bool is_static = false);
|
dBodyID * body, bool is_static = false);
|
||||||
void addCube(const std::vector<float> args);
|
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)
|
void setGravity(float x, float y, float z)
|
||||||
{
|
{
|
||||||
dWorldSetGravity(m_world, x, y, z);
|
dWorldSetGravity(m_world, x, y, z);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user