Buoyancy

Started by
8 comments, last by MGB 16 years, 9 months ago
Hiya, I'm currently looking for a physics SDK to integrate with my current engine project. So far I've tried a PhysX and TrueAxis - I'm very impressed with TrueAxis, but PhysX seems to be more oriented towards using hardware physics cards. Aside from the usual rigid body dynamics and ragdoll which both SDKs support, I'd really like some sort of built-in buoyancy - support for volumes of fluid, if that makes sense. TrueAxis doesn't support this though, and I was wondering if it's terribly complex to implement it myself (probably using TrueAxis as the underlying SDK). Any suggestions or pointers to resources (no pun intended) would be very much appreciated. Thanks for any help [smile]
Advertisement
Well in order to do this, you're going to have to come up with a fluid volume system which denotes areas of the world that have a certain fluid in them. Each fluid could be moddeled as a primitive such as a box, and anything that collides with that box will be in the fluid. Once you have this, you're going to have to also have a system for coming up with the volume of objects, if this isn't supported by the SDK. Idealy, you need to know how much volume each object displaces (how much of its own volume is within the fluid). This will probably be a fairly complex computation, especially for triangle meshes. If you manage to get this to work, the boyancy force is given as follows:

F = - p*V*g

where p is the density of the fluid, V is the displaced volume, and g is the gravitational acceleration at that point (usually 9.81 m/s^2). This force is equal to the weight of the displaced fluid, which makes sense.


Have fun!
Thanks. Time to dig out that A-level maths and physics, I think [smile].
I think Erin Catto wrote a nice article in GPG6 about buoyancy. This seems to work quite nice, so you might want to check this...
Yes, Erin's chapter was in Game Programming Gems 6. Its a fine chapter, quite straightforward, with sample code that works well. Recommended.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
The Newton physics sdk has built-in buoyancy. Can be rather hard to tweak though as I found.
I'd wager calculating the force using just the bounding box or sphere would look fine for most objects. Spherical objects and a simple water plane would be a good thing to experiment with, and you can amp it up from there. All depends how accurate you want it. In some cases you could get away with a simple force proportional to the distance between the centre of the object and the surface, clamped within reasonable bounds. You might also want a righting force. Never underestimate the power of cheating.

You might also consider treating the object as a point cloud, where each point gives a certain upward force if it is in the water volume. Simple, and arbitrarily accurate.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
Quote:Original post by RAZORUNREAL
I'd wager calculating the force using just the bounding box or sphere would look fine for most objects. Spherical objects and a simple water plane would be a good thing to experiment with, and you can amp it up from there. All depends how accurate you want it. In some cases you could get away with a simple force proportional to the distance between the centre of the object and the surface, clamped within reasonable bounds. You might also want a righting force. Never underestimate the power of cheating.

You might also consider treating the object as a point cloud, where each point gives a certain upward force if it is in the water volume. Simple, and arbitrarily accurate.


Some good ideas there. However, I would avoid using the bounding box approach because it looks crappy when objects have a large (or small) aspect ratio (length:width). Guesstimating a force based on the displacement of the objects centre from the surface of the water can work pretty well for most shapes (works best when the aspect ratio is close to one), but you will definitely want to have a 'righting' force.

The point cloud approach doesn't work so well unless the points are well-distributed over the surface of the object. You could improve the behaviour of poorly distributed points by weighting their contribution but I have no experience with that approach, so I can't say whether calculating good weights is straightforward or problematic.

However, if the OP is not going to have many objects in water at the same time, the method that Erin Cato discusses is pretty straightforward.

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

Be warned though, some numerical methods (Euler's method for an instance) that are rock solid for regular dynamics may break down horribly when confronted with oscillatory motions (such as bobbing up and down in water.)
I've used the point cloud approach - works quite well, though some aspects are hard to simulate (i.e. water 'suction' and bobbing as Eudoxie said, though this can be mitigated by using more and weaker points).

This topic is closed to new replies.

Advertisement