From c9d3242314248bfe065209cd1738803fa96eaaa2 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 31 Jan 2010 06:07:36 +0000 Subject: [PATCH] added support for hinge joints with anchor and axis git-svn-id: svn://anubis/misc/OdeWorld@228 bd8a9e45-a331-0410-811e-c64571078777 --- OdeWorld.cc | 11 +++++++++++ OdeWorld.h | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/OdeWorld.cc b/OdeWorld.cc index 342c2a9..65681b3 100644 --- a/OdeWorld.cc +++ b/OdeWorld.cc @@ -115,6 +115,17 @@ dJointID OdeWorld::createAMotor(dBodyID b1, dBodyID b2) return j; } +dJointID OdeWorld::createHinge(dBodyID b1, dBodyID b2, + dReal anchor_x, dReal anchor_y, dReal anchor_z, + dReal axis_x, dReal axis_y, dReal axis_z) +{ + dJointID j = dJointCreateHinge(m_world, 0); + dJointAttach(j, b1, b2); + dJointSetHingeAnchor(j, anchor_x, anchor_y, anchor_z); + dJointSetHingeAxis(j, axis_x, axis_y, axis_z); + return j; +} + void OdeWorld::destroyBody(dBodyID body) { m_bodies.erase(body); diff --git a/OdeWorld.h b/OdeWorld.h index cf6934b..da0165d 100644 --- a/OdeWorld.h +++ b/OdeWorld.h @@ -84,6 +84,9 @@ class OdeWorld void enableAllBodies(); dWorldID getWorldID() { return m_world; } dJointID createAMotor(dBodyID b1, dBodyID b2); + dJointID createHinge(dBodyID b1, dBodyID b2, + dReal anchor_x, dReal anchor_y, dReal anchor_z, + dReal axis_x, dReal axis_y, dReal axis_z); void setAMotorNumAxes(dJointID j, int num_axes) { #ifdef DEBUG_AMOTOR @@ -91,6 +94,13 @@ class OdeWorld #endif dJointSetAMotorNumAxes(j, num_axes); } + void setAMotorAngle(dJointID j, int anum, dReal val) + { +#ifdef DEBUG_AMOTOR + cout << "angle: " << val << endl; +#endif + dJointSetAMotorAngle(j, anum, val); + } void setAMotorAxis(dJointID j, int anum, int rel, dReal x, dReal y, dReal z) {