Spring with joints?

Official forum for the Chipmunk2D Physics Library.

Spring with joints?

Postby Therion » Mon Dec 31, 2007 7:28 pm

Hi, Happy new year! I'm here in my first post to seek some advice!
I need to implement a trampoline that behaves kind of reallistically, my first thought was to use a lot of linear joints between small shapes, but them doesn't seem to work correctly for this purpose, because their lack of "shape conservation"... Anyone did this before or have any ideas to simulate a trampoline behavior?.

Thanks in advance!.
Therion
 
Posts: 2
Joined: Mon Dec 31, 2007 7:14 pm

Re: Spring with joints?

Postby slembcke » Tue Jan 01, 2008 4:50 pm

When you say "behaves kind of realistically" I assume that you mean you want it to stretch. Is that correct?

I guess the first thing that I would try is to chain a bunch of smallish circles together with springs (no joints). Give them an infinite moment of inertia in order to make the simulation more stable. If you need a better collision shape than circles, use line segments that overlap each other by a fair amount. If you use segments, you'll have to give them a moment of inertia, wikipedia has a list of formulas formulas to help here. You'll also need to figure out what works well for anchor points for the springs. Either way, make sure you give the springs some damping so that it doesn't oscillate forever.
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: Spring with joints?

Postby Therion » Tue Jan 01, 2008 8:07 pm

Yes, i want it to stretch, but you can give me some examples?, I'm trying to do the "a bunch of small circles" way, but I can't understand how exactly "cpDampedSpring" method works (and i'm kinda new to physics stuff too), i need to apply the method to all the circles like I'm doing with joints, but once or in every timestep?

Thanks for your help and patience!
Therion
 
Posts: 2
Joined: Mon Dec 31, 2007 7:14 pm

Re: Spring with joints?

Postby slembcke » Tue Jan 01, 2008 10:07 pm

The damped spring function I provide only generates the forces on the object once. You'll have to reset the forces and apply the spring function each time.
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: Spring with joints?

Postby blachman » Thu Jan 08, 2009 12:33 pm

So I'm playing around with something like this as well. I'm using 200 circles with a radius of 1 set next to each other with a 0.5 gap (previous_circle->p+2.5). I have no joints except on the first and last circles and the damping spring I apply to each circle each step is:

cpDampedSpring(circles[i], circles[i+1], cpv(1, 0), cpv(1,0), .25, 150, 15, dt);

e.g. a spring from the edge of each circle to the edge of the next with a resting length of .5 which is the space between the circles.

When I run this, it pretty much just explodes before I can drop anything on it. Any idea what I'm doing wrong?

Thanks a bunch.

->Ben
blachman
 
Posts: 4
Joined: Thu Jan 08, 2009 12:23 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron