Page 1 of 1

Rendering a Pivot joint correctly

PostPosted: Thu Oct 30, 2008 5:45 pm
by ehudros
Hi everyone,
I was wondering what's the right way to render a pivot joint?
It has several members that I don't really know how to use in order to calculate the actual position of the joint at rendering time.
I must say the the documentation is a bit lacking on joints in general, and I'm not even sure I need pivot joints for what I'm trying to do :)
I am trying to create a chain or bridge like effect, as seen in demo7. I saw it uses pivot joints and pretty much copied the code, but I can't say i understand why...

Thanks, and sorry for a confused post... :roll:

Re: Rendering a Pivot joint correctly

PostPosted: Thu Oct 30, 2008 6:44 pm
by slembcke
You should store the joint anchor points yourself. The internal representation of the joint is not documented for good reason. It stores a number of values that aren't going to be useful outside of the Chipmunk impulse solver.

To convert the world coordinate pivot point into relative anchor points, use cpBodyWorld2Local() on both bodies. To get convert the relative anchor points back to world coordinates to render the joint later, use cpBodyLocal2World().

Pivot joints will work to create a bridge just fine. Though it will act as though each link was bolted to the next. If you want the chain to have some slack, use a slide joint instead. You can set a minimum and maximum separation distance with that so that each link can move a little in relation to it's neighbors.