This project has moved and is read-only. For the latest updates, please go here.

Moving a body of water

Topics: Developer Forum, User Forum
Jul 23, 2010 at 3:56 PM
So I was looking at the water examples with 2.1.3, but before I try using water in my own project, I need to be able to move the body of water. In the example, you set the position of the body of water, but the position is static, I want to be able to have water in a cup, tip the cup over, and let the water flow out naturally. Is this possible in farseer 2.1.3 or 3? Thank you for the engine though, it's worked wonders for my project.
Jul 24, 2010 at 3:20 AM

Someone else can probably tell you for sure, but I don't think this is possible with the water simulated in FP2.x or 3.  


You might be looking for something like this:

Jul 24, 2010 at 6:21 AM

It is possible, but it won't be easy. Have a look at this discussion on the Box2D forums:

If you are not too fussy on how realistic it is, you can just use lot's of small circles. However to get a proper fluid simulation you will need to use SPH on the particles:

Anyway that discussion talks about it, and even has a sample in JBox2D (java) to look at. Farseer 3 is almost a port of Box2D, so it shouldn't be too difficult to translate if you have the time.

Jul 24, 2010 at 7:45 AM
Edited Jul 24, 2010 at 7:46 AM
@Jerky, thanks for the reply, but I'm going to look at the fluids from JBox2D.

@robertdodd, thanks for the link to the forum, I'm downloading the source code for JBox2D right now, it's fluid simulation is just what I was looking for.

I'll be sure to come back when I make some progress, but for now I'm going to bed.

Jul 25, 2010 at 11:59 AM
Edited Jul 25, 2010 at 12:48 PM
Okay, I've converted the jist of it all, but I'm not exactly sure what's happening in the physics engine to be able to make it work, can someone please try looking at this? I'm definite that the problem is in applyLiquidConstraint() -- Just copy that into the CharacterCollisionTest.cs in the farseer 3 testbed source. -- That's the liquid test code from JBox2D for comparison.

Jul 26, 2010 at 2:12 PM
Edited Jul 26, 2010 at 2:40 PM

Fishsticks - can you forward your code to bell [.dot.] jeremy [@at@] ? gmail [.dot.] com? pastebin is blocked here.



Jul 27, 2010 at 12:24 PM
Edited Jul 27, 2010 at 11:21 PM
@JeroMiya, thanks for taking interest, I've sent you the couple of emails.

Though, I think I've found the main problem, in the "if (liquid[i].Position.Y < -10.0f)" , I've just realised that all the values for the liquid bodies are either null or 0. Now all the bodies are kept in a Body[] array.. so any idea where all the data is going?

EDIT: No idea how I fixed it, but I had to do with something in applyLiquidConstraint(), commented out these two lines:

liquid[i].Position = new Vector2(xchange[i] / multiplier, ychange[i] / multiplier); liquid[i].LinearVelocity = new Vector2(xchange[i] / (multiplier * deltaT), ychange[i] / (multiplier * deltaT));

Now it's looks like I'm starting to get there..