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

Soft-Body physics and fluid dynamics in game programming

Started by Wonkyth Dec 27, 2010 at 6:52 AM 5 replies 4.1k views
Original Post
Wonkyth
Wonkyth
For a few weeks now I've been looking into Soft-body physics, and knowing how wonderful this can be in games(Gish, JellyCar, whatever), I decided that I must make a game that used soft-body physics and fluid dynamics, even if it was solely for educational purposes.
The problem I'm finding is that there doesn't seem to be many resources that are both related to actually programming the stuff(especially when it comes to fluid dynamics) and within the limit of my skills.
Unfortunately, I have good mathematical skills, but only in a relatively small area, as most of the maths I've learned have been purely out of self-interest.
This has become a bit of a problem as I look into these things, as I'm not sure I know enough to understand any articles I can find, or whether I just need to look harder.

So, do I need to learn more maths?
Is a good knowledge of Calculus important for understanding these kinds of physics?
If so, that's fine, I'll find some stuff and learn.
However, what SHOULD I learn?

If not, then why can I still not understand any of the articles I've found.
Is there any examples or explanations of these topics that someone could direct me to?

Any help is appreciated.
antaydos
antaydos
Speaking as someone with a degree in physics, I cannot recommend calculus enough. However, for the purposes of game programming, I've found that the mantra popularized by the creator of World of Goo "If you can get away with it, fake it" is always appropriate.

Calculus would be needed if you wanted to derive new equations for your objects' motion on a whim every frame. Fortunately for you, just about every system can be approximated once the general rules are set in place.

If you're still intent on fully understanding all the articles you're reading, perhaps link to some and either I or others can pinpoint which math discipline you'd need.
Wonkyth
Wonkyth
Thank you for the quick reply!

As I mentioned above, I've only managed to find a small number of resources that would appear to be of any use in this area, but I'll show you what I've unearthed.

http://www.sci.utah.edu/~guilkey/MPMPubs/steffen_08_IJNME_mpm_preprint.pdf
This is an article I found that looks very in-depth, and was mentioned on some page somewhere involving a liquid demo, I cant remember where.
Unfortunately, it makes constant use of terms I simply do not understand, and also seems to be presenting its approach as an alternative to other methods which I also do not (yet?) understand.

There are some more I found in other places, but unfortunately my laptop is undergoing repairs at the moment, and so I cannot make use of all my bookmarks.

I'm very much looking forward to replicating some of the awe-inspiring examples I've seen, and am quite resigned to working hard towards that goal.

Again, thank you for any help.
WavyVirus
WavyVirus
I don't have any experience in implementing/approximating/faking fluid dynamics for a real-time system, but the following link looks interesting:

http://cowboyprogramming.com/2008/04/01/practical-fluid-mechanics/


The field concerned with solving these types of problems outside of games is "scientific computation". It basically centers around solving systems of equations (or more often approximating the solution) at each node of some kind of grid or mesh. The famous set of equations governing fluid dynamics are the Navier-Stokes equations - solving these in real-time is not easy (Google turns up some interesting papers whcih might be of interest once you're a bit further on). There are many simpler equations which can be derived from these which apply in more restricted conditions. Check out the Hagen-Pouiseuille equation as one of the simplest examples (directly solvable on paper) - this applies to fluid flowing through cylindrical pipes. A few links to get you started:

http://en.wikipedia.org/wiki/Computational_science
http://en.wikipedia.org/wiki/Numerical_analysis#Discretization_and_numerical_integration
http://en.wikipedia.org/wiki/Navier–Stokes_equations

These course notes look solid, but more than a little terse:
http://www.cse.illinois.edu/heath/scicomp/notes/

Maybe the reading list from this page will be helpful:
http://www.eng.utah.edu/~cs3200/
Wonkyth
Wonkyth
Thanks!
That's a fantastic list there, and I don't believe I had previously found any of those!
I'm always happy for more info, but this should certainly keep me busy for some time!
Dawoodoz
Dawoodoz
If you keep it simple by having a fixed timestep of about 200 iterations per second and let graphics make a linear interpolation starting at where the last iteration was and using the remainder time that haven't been used yet as an offset. You can make it look as smooth as if the precision was adapted to the framerate but you won't have the problems with instability when running the games on slower computers. You don't have any use of more physics on fast computers if it gives an unfair advantage to a player with a faster of slower computer.

Pseudo code
RemainderTime = RemainderTime plus TimePerFramewhile ( RemainderTime > TimeStep ) {    RemainderTime = RemainderTime - TimeStep    IterateMidpointPhysics(TimeStep)}Draw items at LastPosition plus (LastVelocity * RemainderTime)


Why can't I write the plus sign in this forum?
emiel1
emiel1
Quote:
Original post by Dawoodoz
Why can't I write the plus sign in this forum?


You can: +. It just doesn't show in the preview window. The bug report can be seen here.

Emiel1

Topic Locked

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

Sign in to reply to this topic.