Skip to main content
GameDev.net gamedev.net
🔒 Locked

Soft Body Physics Dissertation

Started by gameXcore Feb 20, 2009 at 7:08 AM 10 replies 3.4k views
Original Post
gameXcore
gameXcore
Hi, I'm currently a second year student, starting to decide and do some initial research into my dissertation project. A topic I'm considering is soft body physics simulations with the intention of creating a small soft body physics library. Since I'm currently in an initial research stage and assessing the suitability of this topic, I'm just wondering if anyone has any pointers towards resources I could take a look at, or any experience with soft body physics they wish to share themselves. Thanks, Scott Bevin
Game development blog and portfolio: http://gamexcore.co.uk
h4tt3n
h4tt3n
Hi Scott,

I've been working with 2d soft body physics for a while and wouldn't mind sharing ideas and source code. I started out by implementing the ideas in this fairly easy-to-understand article:

http://panoramix.ift.uni.wroc.pl/~maq/soft2d/howtosoftbody.pdf

It's a nice place to start - it simulates soft bodys using point masses attached into closed objects by linear springs. An area based pressure force algorithm makes the bodys keep a near-constant volume, like a balloon. Just make sure to swap the erroneous(?) Gauss 2d volume algorithm with a regular 2d polygon area algo.

Feel free to ask!

Cheers,
Mike
gameXcore
gameXcore
Hi Mike,

Thanks for that link, I've just glossed over it (trying not to go into too much detail yet, else ill scare myself away frmt he topic before I even get into my 3rd year) but it did sound very promising.

Scott
Game development blog and portfolio: http://gamexcore.co.uk
h4tt3n
h4tt3n
I've cooked up a little illustrative example for you. It's ~ 250 lines of commented source code + exe. It pretty much uses the method described in the above paper, except for a few bug fixes and improvements. If you want to compile the code example you'll need the FreeBasic compiler.

http://www.jernmager.dk/stuff/freebasic/soft_body_simulation.zip

cheers,
Mike
jdindia
jdindia
I did a bit of quick searching on this topic about a year ago and didn't find much (which usually means I typed the wrong thing in google). I did find the paper quoted above which I tried implementing and I wasn't terribly happy with the results. Springs are difficult to get right. You want something a little firmer so you increase the stiffness and boom your simulation starts blowing up. More abstractly, I don't see how you can get the shape control you'd want with every vertex connected by a spring. There's just too much freedom of movement. You want your frog to look like your original frog model until you start smacking it - not to just ooze around all over the place once you start your simulation. I can't imagine it being particularly fast either since any solution would require lots of iteration per frame.

Clearly better soft body physics algorithms exist. Some of the physics engines listed in the FAQ support it. But you don't see it a lot in games, and I imagine that's mainly because it's too slow.

Best of luck with your research.
h4tt3n
h4tt3n
Oh, but I beg to differ! :-)

Quote:
Original post by jdindia
I did find the paper quoted above which I tried implementing and I wasn't terribly happy with the results. Springs are difficult to get right. You want something a little firmer so you increase the stiffness and boom your simulation starts blowing up.


With force based movement that's always a potential problem, but there's soo much you can do about it! I usually always use an iterative velocity-verlet integration algorithm for stability. I run it 4 times per simualtion loop - like the runge-kutta 4th order - which allows literally astronomical spring k values, higher than what rk4 allows. Besides, I've implemented linear and angular global damping algorithms, which stabilises the simulation heavily and allows you to make much more viscous soft bodys, acting like bags of sand or like chewing gum.
Adding a velocity squared air friction is also good!

Quote:
More abstractly, I don't see how you can get the shape control you'd want with every vertex connected by a spring. There's just too much freedom of movement. You want your frog to look like your original frog model until you start smacking it - not to just ooze around all over the place once you start your simulation. I can't imagine it being particularly fast either since any solution would require lots of iteration per frame.


Solved that one too with angular springs. The method I've developed recycles the data you needed for the linear springs anyway, so it's very cpu efficient. As already mentioned I usually run 4 iterationes / frame. You can give your soft body any shape you desire, and it'll keep it rubber-chicken style.

Quote:
Clearly better soft body physics algorithms exist. Some of the physics engines listed in the FAQ support it. But you don't see it a lot in games, and I imagine that's mainly because it's too slow.


There's probably something better around than what I've cooked up, but I still haven't seen it - please do prove me wrong, I like fresh input every now and then :-) As for soft bodies in games - they're definitely not too slow, that's not the reason. Collision detection is always the big killer. The trouble is that rigid body dynamics are just more popular, just look at the forum topics here and over at the bullet forum. All other kinds of physics - gravitational / magnetic interaction, fluid dynamics, springs, and whatnot - are just second to that, don't ask why.

I'll throw in a few more examples to proove my point:

http://www.jernmager.dk/stuff/freebasic/blobby_vehicle_simulation.zip

Cheers,
Mike

[Edited by - h4tt3n on February 21, 2009 4:04:16 PM]
h4tt3n
h4tt3n
Here's a little soft body sandbox. Pick up the soft bodys witn the mouse and throw them around. The sim allows you to change a number of variables like spring stiffnes and damping during run-time, so you can see how they affect the simulation. It comes with somewhat commented FreeBasic source code.

http://www.jernmager.dk/stuff/freebasic/soft_body_toy_00.zip

cheers,
Mike
nairda
nairda
the link to "howtosoftbody.pdf" seems to be broken. would you be able to explain how you made the constraints in your simulation? (like the wheels)
gameXcore
gameXcore
Lots of replys, where have I been =] All very very usefull stuff, I especially enjoyed playing with that little car "hold down, shake, shake, BOOM" love it :D

Thanks for all the feedback guys, I'm compiling a rather large collection of resources to sift through here.

Scott
Game development blog and portfolio: http://gamexcore.co.uk
h4tt3n
h4tt3n
Quote:
Original post by nairda
the link to "howtosoftbody.pdf" seems to be broken. would you be able to explain how you made the constraints in your simulation? (like the wheels)


Weird, I downloaded the document again just the other day...

I'm not quite sure what you're asking here. All constraints are force based springs. Wheel to ground interaction is based on physically realistic friction, which oliii explained me how to do - there are several threads on this topic here at the gamedev forum).

Cheers,
Mike
wodan
wodan
Quote:
Original post by h4tt3n
Quote:
Original post by nairda
the link to "howtosoftbody.pdf" seems to be broken. would you be able to explain how you made the constraints in your simulation? (like the wheels)


Weird, I downloaded the document again just the other day...

I'm not quite sure what you're asking here. All constraints are force based springs. Wheel to ground interaction is based on physically realistic friction, which oliii explained me how to do - there are several threads on this topic here at the gamedev forum).

Cheers,
Mike



Here's a mirror. The "howtosoftbody.pdf" is inside the .zip:

http://physics.hardwire.cz/mirror/GasFilledBody.zip


h4tt3n
h4tt3n
here's a cpp soft body sample with commented source:

http://www.jernmager.dk/stuff/cpp/soft_body_03.zip

Cheers,
Mike

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.