Show DopeJoint.cpp syntax highlighted
#include "DopeJoint.h"
#include "DopeEntidad.h"
namespace Dope {
//-------------------------------------------------------------------------
Joint::Joint(Joint::JointType jtype)
: mType(jtype), mAnchor(Vector3::ZERO), mOdeJoint(NULL)
{
mAxes.first = Vector3::UNIT_X;
mAxes.second = Vector3::UNIT_Z;
// Subclasses must set attachment since mOdeJoint must be created
}
//-------------------------------------------------------------------------
Joint::JointType Joint::getType(void)
{
return mType;
}
//-------------------------------------------------------------------------
const Vector3& Joint::getAnchorPosition(void)
{
return mAnchor;
}
//-------------------------------------------------------------------------
void Joint::setAttachments(Entidad* obj1, Entidad* obj2)
{
dBodyID b1, b2;
b1 = b2 = 0;
if (obj1)
{
assert(obj1->getOdeBody() && "Cannot attach objects which do not have ODE bodies.");
b1 = obj1->getOdeBody()->id();
}
if (obj2)
{
assert(obj2->getOdeBody() && "Cannot attach objects which do not have ODE bodies.");
b2 = obj2->getOdeBody()->id();
}
mOdeJoint->attach(b1, b2);
mAttachedObjects.first = obj1;
mAttachedObjects.second = obj2;
}
//-------------------------------------------------------------------------
const std::pair<Entidad*, Entidad*>&
Joint::getAttachments(void)
{
return mAttachedObjects;
}
//-------------------------------------------------------------------------
const std::pair<Vector3, Vector3>&
Joint::getAxes(void)
{
return mAxes;
}
//-------------------------------------------------------------------------
}
See more files for this project here