Fluid Containers? Can they work?

Feb 26, 2009 at 1:40 PM
i was wondering if fluid containers were possible in farseer at the moment like in this


i was wondering if anyone had a sample anywhere or some code to give me a hint on how to do this
thanks in advance
Feb 26, 2009 at 2:32 PM
Edited Feb 26, 2009 at 2:34 PM
Indeed it's possible. What you see is actually Farseer Physics ported to BMX.
We only have a silverlight water sample at the moment, but it should not be too difficult to understand the workings and transfer it to XNA.

Essentially it works by using a FluidDragController combined with a class that controls what enters the FluidDragController. (needs to inherit the IFluidContainer interface. You can use AABBFluidContainer or create your own. I'll use the AABBFluidContainer as the example from now on.).
When ever a body enters the AABBFluidContainer (it is a AABB that checks for intersections and containment) the FluidDragController calculates the stuff that makes the bodies float.
Remember that Farseer Physics does not draw anything so if you need to draw waves, you will need to find a wave algorithm (There is one in the silverlight sample and the BMX port of Farseer Physics).

EDIT: Remember to read the documentation about the FluidDragController (it's in XML format inside the FluidDragController.cs file) There is a lot of good info on how to use the controller.