Rendering a Pivot joint correctly

Discuss new features and future development.
Post Reply
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Rendering a Pivot joint correctly

Post 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:
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Rendering a Pivot joint correctly

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests