Here's a short demo of a boat sailing through waves on an unbounded ocean. Buoyancy is modelled by attaching floats to the body which simply apply a force acording to their depth below the surface at discrete points. The ocean surface is functionally generated, so it is infinite in extent. Replacing the quick + simple but completely wrong sine waves with something more physically correct is on my todo list, as is making a better boat model

Note this is not using the technique demonstrated in HeightFieldFluidDemo, which models the water as a finite heightfield.

## Simple boat buoyancy demo

### Re: Simple boat buoyancy demo

Nice video and physic effect !

Could you please explain a little further the approach you used ? From what you've written I presume you attached some rigid bodies (how many, which shape, where, with which constraint?) to the boat rigid body so that you can apply a force on each of them at every internal timestep proportional to the body distance from the water surface. Correct?

I'm not asking any source code, just a further explanation of one line or two. Thank you in advance.

Flix.

Code: Select all

`Buoyancy is modelled by attaching floats to the body which simply apply a force acording to their depth below the surface at discrete points.`

I'm not asking any source code, just a further explanation of one line or two. Thank you in advance.

Flix.

### Re: Simple boat buoyancy demo

Cheers!

The floats are not real Bullet bodies - they are imaginary things attached to points on my boat object.

But yes, in the timestep the each float tests the water level at their position, then applies a force to the boat's rigid body at their position relative to the boat. I imagine each float as a cylinder which is always vertical, regardles of the orientation of the boat. The force is proportional to how deeply immersed they are, up to a maximum defined by their volume.

At the moment the boat has just 4 floats - bow, stern, port & starboard. I manually set their volumes to provide enough force to counteract gravity, and then adjust the positions and cylinder lengths to tweak the way the boat moves. I've got a vague idea to generate the floats by packing cylinders into the rigid body volume somehow, but that's something for the future

The floats are not real Bullet bodies - they are imaginary things attached to points on my boat object.

Code: Select all

```
boat
+ btRigidBody
+ Ogre renderable
+ floats
```

At the moment the boat has just 4 floats - bow, stern, port & starboard. I manually set their volumes to provide enough force to counteract gravity, and then adjust the positions and cylinder lengths to tweak the way the boat moves. I've got a vague idea to generate the floats by packing cylinders into the rigid body volume somehow, but that's something for the future

### Re: Simple boat buoyancy demo

Thank you for your explanation !

### Re: Simple boat buoyancy demo

Could anybody send me a sample code on how to proceed to make a similar sample as shown by robagar?

I would like to use OgreBullet framework for making this.

Thanks in advance.

I would like to use OgreBullet framework for making this.

Thanks in advance.

### Re: Simple boat buoyancy demo

I would also like to see the sorcecode of this boat buoyancy demo.

### Re: Simple boat buoyancy demo

Considering his last visit to the forum was 2 years ago, you might have to be contented with his explanation instead of his source.

### Re: Simple boat buoyancy demo

I don´t realy expected the topicstarter to give me the sorces, but may be the sources, even posible modified, are avaible somewhere and someone can say where to find them.c6burns wrote:Considering his last visit to the forum was 2 years ago, you might have to be contented with his explanation instead of his source.

### Re: Simple boat buoyancy demo

I'm happy to follow this up, if nobody else cares to, and hi, Erwin!