[ODE] Locking a body to a point in space

Nate W coding at natew.com
Thu Mar 27 13:17:02 2003


On Thu, 27 Mar 2003, Ted Milker wrote:

> What's the correct way to lock a body to a fixed point in space(or if
> it's possible, lock it to it's current position).  Basically, I've got
> two boxes connected by a ball joint, I'd like to lock one of the boxes
> in mid-air and have it stay there, so if I were to apply force to the
> second box, it would swing around the first one.  I've pored over the
> archives and docs but I can't find a solution.  

There's two options... 

1) Use a 0-DOF joint ("fixed joint") to attach one box to it current
position in the universe.  I think the docs use the phrase "attached to
the static environment."  This is the method that Juice uses when you
"tack" a body into position.  One advantage to this approach is that you
can simply remove the joint if you want things to behave normally again.  
One drawback to this approach is that the 0-DOF joint adds 6 constraints
to the system, which must be solved, and that takes CPU cycles.

2) For the "locked" object, do not create a body - create only a geometry
object.  Then, for your ball joint, set one dBodyID to the free box, and
set the other dBodyID to null.  This basically attaches the joint to its
current position in the universe.  The advantage to this approach is that
it doesn't add any constraints to the system.  In fact it probably speeds
up computation, because there's one less body in the universe.

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com