Custom Joints

Official forum for the Chipmunk2D Physics Library.
Post Reply
Zamaster
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm
Contact:

Custom Joints

Post by Zamaster »

Actually didn't find anything about this on the forum. Sooo, is this a thing? In particular I'm interested in coding a rail joint which needs to be a weird hybrid of semi-circular sections and straight lines. By rail I mean that an anchor point is confined to a pre-defined "rail" (think roller coaster). This is for some wall climbing type code.

Anyway, is there any documented way to create a custom joint, or at least some specifications? Thanks!
Zamaster
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm
Contact:

Re: Custom Joints

Post by Zamaster »

I should add the rail itself is the joint and the anchor points are from the one object to which the rail is fixed and the other which is fixed to the rail. Hopefully this could be facillitated by chipmunk somehow.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Custom Joints

Post by slembcke »

So other than the code of the existing joints there isn't really any documentation on how it all works. Sounds like you want something that is a hybrid of the groove and pin joints though. Since you'll need to be switching between different joint modes anyway, you can probably get away with actually switching joints. Detect which section of the track you are on and activate that joint.

Better custom joint support is something I really want to tackle for Chipmunk 7, but that's a ways off.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Zamaster
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm
Contact:

Re: Custom Joints

Post by Zamaster »

Good idea! Much better to use whats there than reinvent the wheel. Thanks.
Zamaster
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm
Contact:

Re: Custom Joints

Post by Zamaster »

I suppose my other question is whether or not there is some way mid step to sort of stop, hammer time and switch joints, then resume the step? I suppose this could be done with some flavor of callbacks, but I feel like theres a good way and an uninformed way to do it and I'll probably end up doing it the uninformed way.
offonoff
Posts: 28
Joined: Sun Nov 06, 2011 1:38 am
Contact:

Re: Custom Joints

Post by offonoff »

Why would you need to do this mid step? I (a noob) would think you would use a collision handler to determine when the object needs to switch rails, and set a post step callback to remove one joint and add another.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Custom Joints

Post by slembcke »

Well, since the rail parts aren't actually collision shapes, I'm not sure how that would help you really. I'd just do it outside of the timestep completely.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Zamaster
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm
Contact:

Re: Custom Joints

Post by Zamaster »

I was more or less thinking about an object moving over a rail, if things weren't handled during the step, the object might stop moving at the groove joint endpoints. If there were some way to switch joint types at certain endpoint conditions (hit an end of the groove / reached a certain realative angle of a pin joint) either mid step, OR, stop the simulation at such a condition without applying impulses -> disconnect+reconnect some joints -> continue the simulation.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Custom Joints

Post by slembcke »

Just set up the groove joints to extend beyond the straight segments of your track. No need to be super exact.
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 26 guests