Sign in to follow this  
daveodonoghue

Determining bouyancy of a custom built boat

Recommended Posts

Ok, I'm trying to add boat building to my fps game. I've built the functionality to actually build the boat using materials but now I need a way to make it float based on it's components. It doesn't need to be realistic just fun.

Here's how I'm thinking of doing it, let me know if you have ideas about how to improve on this, please bear in mind I am very bad and maths and physics so the idea is based on the little knowledege i have.


I'll use a more complicated example to explain the theory as I need to make sure the idea can handle many different shapes of boats.

Here's a boat with two hulls:

Boat with two hulls



Known Factors:
1. The mass of the boat is known due to all the materials having individual weight
2. The center of mass is known due to all the materials having known positions and weight


The Theory:
1. Determine the bounds of the boat by finding the min/max vectors of all objects that make up the boat

2. Calculate volumes by ray casting down, left, right, front and back (not up) every 1m2 for 1m.

If the ray cast hits another raycaster or hits part of the boat then those squares are combined to create a group, if the ray cast hits the air then that group is not valid.

This will give me 3 groups, 1 for the cabin and one for each hull.

3. Calculate bouyancy across groups: using the center of mass, gravity and the bounds I can figure out which volume will sit lower in the ocean if there were no forces impacting the hulls then I can fake the percentage of bouyancy that would be gained or lost based on the amount of displacement the surface could create if fully submerged using the amount of squares the volume uses, this should give me a boat that will sag in areas if the boat was designed poorly.


4. Adding forces: the groups will only receive bouyancy forces if they are actually touching the water which will allow the cabin in the middle to give weight to the boat but wont help keep it afloat until the cabin actually hits the ocean line.

5. Sinking the ship will depend on a lot more raycasts to see if holes exist but I plan on doing these overtime in a thread, doesn't matter if the boat doesn't react to holes immediately.

Also, I need it to be quick so that I can check the bouyancy after collisions with other objects and hull breaches.

Share this post


Link to post
Share on other sites
What are the primitives used to construct the boat? Is it arbitrary triangle soup? A closed triangulated manifold? Tetrahedral mesh? Ellipsoids/capsules/boxes and other "physics primitives?"

Share this post


Link to post
Share on other sites
For reference, Erin Catto (of Box2D fame) wrote a nice chapter for the book "Game Programming Gems 6" that provided an elegant method of simulating buoyancy. His chapter was titled "Exact Buoyancy for Polyhedra." An excellent chapter, by the way, intuitive and easy to use.

(Disclosure: I was a section editor for that book, so I get a small royalty share per copy sold.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this