Liquid physics?

Nibbie
Posts: 1
Joined: 2010.02
Post: #1
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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...
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #3
Perhaps you can you simulate this using Jos Stam's fluid dynamics, representing each liquid with a different color.
Quote this message in a reply
Member
Posts: 281
Joined: 2009.04
Post: #4
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

~ Bring a Pen ~
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
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...
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2010.09
Post: #7
(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.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2011.06
Post: #8
You want to look into "smoothed particle hydrodynamics" (SPH)
There are many tutorials, videos, source codes and libraries out there
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2012.01
Post: #9
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.
Quote this message in a reply
Post Reply