Jump to content
• Advertisement

# Buoyancy

This topic is 3999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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]

#### Share this post

##### Share on other sites
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!

#### Share this post

##### Share on other sites
Thanks. Time to dig out that A-level maths and physics, I think [smile].

#### Share this post

##### Share on other sites
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...

#### Share this post

##### Share on other sites
Yes, Erin's chapter was in Game Programming Gems 6. Its a fine chapter, quite straightforward, with sample code that works well. Recommended.

#### Share this post

##### Share on other sites
The Newton physics sdk has built-in buoyancy. Can be rather hard to tweak though as I found.

#### Share this post

##### Share on other sites
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.

#### Share this post

##### Share on other sites
Quote:
 Original post by RAZORUNREALI'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.

#### Share this post

##### Share on other sites
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.)

#### Share this post

##### Share on other sites
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).

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5
• Advertisement

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!