Posted: 20th Oct 2011 12:14
Hi all,
Anybody knows how to simulate water and fluids in AppGameKit? I've tryed with particles with circle shapes (shape little smaller than the image in order to allow some mix in the image particles) and works but... it's not very reallystic.
Can anybody share any ideas or knows any tutorial about?

Thanks in advance and excuse my english.
Regards.
Posted: 20th Oct 2011 13:12
animated sprites & a good artist!
Posted: 20th Oct 2011 13:26
Hmmmm... Not exactly. I refer to the water physics behavior and how the bodies and water drops reacts, not the water graphics itself.
Posted: 20th Oct 2011 14:49
I think you can use a sensor SetSpritePhysicsIsSensor to determine when an object is in the water, so you apply a force against the object pushing it to the surface, when the object is in the surface, gravity will push it back against the water making a buoyancy effect. I think it works.
Posted: 20th Oct 2011 15:20
It's a good idea I'll try it, thanks Almus!
Posted: 20th Oct 2011 15:25
Using circles is the usual way in Box2D. You can get some pretty good results too but you need to work on the surface tension code... that's the hardest part I believe.

The main thing is working out which particles are near the edge and keeping them connected up to a certain amount of force. When they are separated they will still need to attract one another within a certain distance.

Finally you'll have to work out how to make it look like water. Particles at the surface will need to have more intelligent textures than those underneath.

Diggsey produced a great demo for his Box2D plugin for DBPro. I would take a look at that if you're using C++ and want to try a shader...

EDIT: if your water only has a surface at the top then the above suggestion is fine. Nice idea.