Buoyancy and water heightfield

Hi

I'm wondering if anybody here successfully reproduce the water buoyancy heightfield of Farseer visible here : http://www.youtube.com/watch?v=04LB7Hscw50

I know someone already write this ( http://lab.polygonal.de/2006/08/30/moto ... -buoyancy/) but it's look like too complicated to implement for me at the moment.

Also from the forum there is a paper about this http://www.matthiasmueller.info/talks/g ... ds2007.pdf but it's far from giving true answers...

Isn't there something better or simple to reproduce this effect ?
This don't need to be very precise a simple splash effect similar to the new super mario (http://www.youtube.com/watch?v=91fhyubdN8c) would be very good.

What I'm about to try is simply using a sensor to push up object to the surface when his center mass pass though it. So it's still possible to swim inside the "sensor water" object.
I know Farseer is using a specific AABB box input but getting contacts point position and normal to "animate" the splash effect seems a good way to achieve this quickly.

Any ideas on this ?
Thanks
A while ago I tried porting the polygonal.de code. Motor Physics is based on Box2d, so it's probably your best bet. I think I gave up at the point where I realized that Motor Physics triangulates ALL polygons (even convex ones), and the buoyancy code depended on slicing the triangles in half at the buoyancy line. I didn't know how to slice a polygon with more than 3 points, so I gave up.

I also tried your sensor approach. The problem with that is that it can create a really awkward bouncing effect. Say a rectangle falls into a water length wise - it should eventually flatten itself out and float like a wood plank. But it'll just keep bouncing up and down at the same angle it hit the water.

If all you want to do it make a "splash" though, there's probably a simpler solution that all-out buoyancy.
Thanks Mayobutter
I didn't think about this problem...
Maybe adding a bit of torque or angular velocity to roughly fake random forces waves ?

Currently I study the new paper about Height Fields ( http://www.matthiasmueller.info/talks/GDC2008.pdf ) things are a bit more well explained (with 1D operations) and I think it's possible to go with this solution.

But I really would like some objects floating with this buoyancy effect.
Is there no other choice than the complicated motor physics method ? Except waiting the buoyancy feature of course 😉
Yeah, buoyancy is waaaay at the bottom of the to-do list, so we might see it eventually.
mayobutter wrote:
I also tried your sensor approach. The problem with that is that it can create a really awkward bouncing effect. Say a rectangle falls into a water length wise - it should eventually flatten itself out and float like a wood plank. But it'll just keep bouncing up and down at the same angle it hit the water.


If the upward force comes from the point of impact this should generate torque around the center of mass causing it to level out, i haven't tested this, but seems like it should work okay?
thesleepless wrote:
If the upward force comes from the point of impact this should generate torque around the center of mass causing it to level out, i haven't tested this, but seems like it should work okay?

I was just thinking about this solution. But what if the body is completely submerged? I'm not sure how the contact point normals behave when a sensor is completely overlapping a body. Anyone know this? I'll try running some tests when I've got some spare time...
Buoyancy is not an easy issue. I think all these faking ways will have some case that they fail for, or at least look slightly unnatural. I have an idea that I think could do buoyancy without lots of tricky geometry, but I'm keeping it to myself until I can test it.

The water effects on the other hand, are completely separate, and very easy. The mario one is just an animated sprite, that works spectacularly well as long as your objects are small. The Farseer one is closer to what I would do. Basically, you have the height field and wave mechanics on that, then the hard part is you need to figure out how to have the shapes impacting it properly. Farseers solution appears to be to give the water a push on every Add and Remove event (in Box2D parlance). You can see it's a bit unrealistic when he pulls things out of the water, you only get waves when the last part leaves, no matter how small.

I'd try something like: For every point in the heightfield overlapping a shape, accelerate it up/down according to the local velocity of the shape at that point.

I don't know how effective it'd be though. The linked paper gives some more advanced techniques, and talks about displacement, but it looks tough to get right.
The farseer video looks nice at first, but you soon realize that the boxes do not behave realistically at all. They seem to freely spin while floating on the surface, which is no doubt because it's not taking displacement into account. With something like that (i.e. buoyancy forces applied on the center of gravity only, no torques) you can't even think about keeping anything afloat and stable because it'll just tip over.
I thought the farseer demo did calculate displacement correctly. For the thin rectangles, you can see that they are definitely spun to lie flat on the water. However, there is no water resistance to motion, so stuff spins and spins, aside from the normal damping. Water resistance is probably even harder than boyancy, as it depends on surface area (surface length?) in contact with the water.
BorisTheBrave wrote:
I thought the farseer demo did calculate displacement correctly. For the thin rectangles, you can see that they are definitely spun to lie flat on the water. However, there is no water resistance to motion, so stuff spins and spins, aside from the normal damping. Water resistance is probably even harder than boyancy, as it depends on surface area (surface length?) in contact with the water.

You may be right about that, actually. They really need to tweak some settings there though because the blocks are clearly less dense than the water, and i am certain that if you send a spinning rectangular block into some water it will NOT keep spinning on the surface like that. the problem of figuring out the rotational viscous resistance is also a problem, although this could probably be somehow calculated and stored internally kinda like moment of inertia, etc. but then you'd need a 2-d tensor field quantity or some such for the linear damping factor. And if you're gonna go that far you can't really ignore currents inside the fluids and thats even more of a problem to simulate.

Original thread: https://box2d.org/forum/viewtopic.php?t=1162