[ODE] hinge joint?

Michael Jones m.pricejones at gmail.com
Thu Aug 10 10:44:24 MST 2006


I'm not too experience with the ODE myself but here are my thoughts. The
basic steps involve creating two bodies and their corresponding collision
geoms, positioning the bodies, attaching the bodies to the geoms and then
creating a hinge joint and attaching it to the two bodies. So:

(pseudo code, for two boxes)

1. bodyA = dBodyCreate(world)
2. bodyB = dBodyCreate(world)

3. geomA = dCreateBox(space, 1.0, 0.5, 0.5)
4. geomB = dCreateBox(space, 1.0, 0.5, 0.5)

5. dBodySetPosition(bodyA, 1.0, 0.0, 0.0)
6. dBodySetPosition(bodyB, -1.0, 0.0, 0.0)

7. dGeomSetBody(geomA, bodyA)
8. dGeomSetBody(geomB, bodyB)

9. hinge = dJointCreateHinge(world, 0)
10. dJointAttach(hinge, bodyA, bodyB)
11. dJointSetHingeAnchor(0.0, 0.0, 0.0)           // positioned between the
boxes
12. dJointSetHingeAxis(1.0, 0.0, 0.0)               // set to whatever axis
you decide is best

You might also need to set the mass up which involves something like:

dMass mA;
dMassSetBox(&mA, 1.0, 1.0, 0.5, 0.5);
dMassAdjust(&mA, 1.0);

dMass mB;
dMassSetBox(&mB, 1.0, 1.0, 0.5, 0.5);
dMassAdjust(&mB, 1.0);

dBodySetMass(bodyA, &mA)
dBodySetMass(bodyB, &mB)


The main thing with the joint in particular is to get the bodies positioned
correctly and then set the joint between them and get the axis correct.

Hope this helps,
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://q12.org/pipermail/ode/attachments/20060810/6c262fd1/attachment.htm


More information about the ODE mailing list