Liquid physics?
Hi,
I am new to IPhone SDK and I would like to hear from you guys if that can be done.
I would like to have a transparent bottle (the more realistic the better) filled with OIL and WATER and than when someone shakes it the liquid would be mixed (kinda), just like in a real bottle+OIL+Water.
Is that easily feasible? Is there any API/Library which would help me on that?
Cheers
I am new to IPhone SDK and I would like to hear from you guys if that can be done.
I would like to have a transparent bottle (the more realistic the better) filled with OIL and WATER and than when someone shakes it the liquid would be mixed (kinda), just like in a real bottle+OIL+Water.
Is that easily feasible? Is there any API/Library which would help me on that?
Cheers
It's a hard problem, computationally very intensive, possibly out of reach of even the 3GS to do "realistically", depending on the resolution of the simulation.
There may be a decent "faking it" option I suppose...
There may be a decent "faking it" option I suppose...
Perhaps you can you simulate this using Jos Stam's fluid dynamics, representing each liquid with a different color.
If it's not too much of a strain on the iPhone the way I have seen most people do this is with small particle systems. If you want you could make some way of drawing joins between close particles. You may want to look at the way Phun does it:
http://www.youtube.com/watch?v=HbXVc7Zl-Nw
http://www.youtube.com/watch?v=HbXVc7Zl-Nw
~ Bring a Pen ~
that 48-second movie took 30 minutes of real time to render, according to the description. Not exactly useful for a game. And that's presumably on a 2+GHz desktop CPU...
While particle based fluids let you do some fancy-ish effects, they are also extremely computationally expensive. I've never tried it, but AquaForest did this on the iPhone: http://www.youtube.com/watch?v=hxpGdRH7J5I
It looks like it has pretty coarse particles and poor framerates when there is only a small amount of liquid on the screen. I'm guessing that it's also already highly optimized.
It looks like it has pretty coarse particles and poor framerates when there is only a small amount of liquid on the screen. I'm guessing that it's also already highly optimized.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
(Mar 2, 2010 01:37 PM)Skorche Wrote: While particle based fluids let you do some fancy-ish effects, they are also extremely computationally expensive. I've never tried it, but AquaForest did this on the iPhone: http://www.youtube.com/watch?v=hxpGdRH7J5I
It looks like it has pretty coarse particles and poor framerates when there is only a small amount of liquid on the screen. I'm guessing that it's also already highly optimized.
Actually, it's the steam particles that make it lag.
You want to look into "smoothed particle hydrodynamics" (SPH)
There are many tutorials, videos, source codes and libraries out there
There are many tutorials, videos, source codes and libraries out there
We created a liquid/goo dynamic for our game, Critter Chaos.
http://critterchaos.infinitebeta.com
It's just a bunch of rigid bodies connected by joints, and yes, performance did suffer.
I optimized the hell out of it, and we also changed the rules of the game to limit the amount of goo that could be on the stage at one time.
http://critterchaos.infinitebeta.com
It's just a bunch of rigid bodies connected by joints, and yes, performance did suffer.
I optimized the hell out of it, and we also changed the rules of the game to limit the amount of goo that could be on the stage at one time.

