Custom Joints

Official forum for the Chipmunk2D Physics Library.

Custom Joints

Postby Zamaster » Tue May 21, 2013 3:01 pm

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

Re: Custom Joints

Postby Zamaster » Tue May 21, 2013 3:04 pm

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.
Zamaster
 
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm

Re: Custom Joints

Postby slembcke » Tue May 21, 2013 3:43 pm

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

Re: Custom Joints

Postby Zamaster » Tue May 21, 2013 5:57 pm

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

Re: Custom Joints

Postby Zamaster » Tue May 21, 2013 6:08 pm

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.
Zamaster
 
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm

Re: Custom Joints

Postby offonoff » Wed May 22, 2013 9:17 am

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.
offonoff
 
Posts: 28
Joined: Sun Nov 06, 2011 1:38 am

Re: Custom Joints

Postby slembcke » Wed May 22, 2013 9:22 am

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

Re: Custom Joints

Postby Zamaster » Wed May 22, 2013 12:25 pm

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.
Zamaster
 
Posts: 37
Joined: Tue Feb 12, 2013 8:09 pm

Re: Custom Joints

Postby slembcke » Wed May 22, 2013 1:02 pm

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


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 2 guests

cron