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
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
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.
-
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
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
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Simple boat buoyancy demo
Thank you for your explanation !
-
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
-
- Posts: 1
- Joined: Wed Aug 18, 2010 1:17 pm
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.
-
- Posts: 14
- Joined: Tue Jul 16, 2013 2:57 pm
Re: Simple boat buoyancy demo
I would also like to see the sorcecode of this boat buoyancy demo.
-
- Posts: 149
- Joined: Fri May 24, 2013 6:08 am
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.
-
- Posts: 14
- Joined: Tue Jul 16, 2013 2:57 pm
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.
-
- Posts: 2
- Joined: Mon Mar 25, 2019 9:13 am
Re: Simple boat buoyancy demo
I'm happy to follow this up, if nobody else cares to, and hi, Erwin!