Game Development Reference
In-Depth Information
can simply fix the center of buoyancy to the rigid body. In a real boat the center
of buoyancy will move around as the boat pitches and rolls and a different volume
of water is displaced. Most boats are designed so that this variation is minimized,
however. Fixing the center of buoyancy doesn't look odd for most games. It shows
itself mostly with big waves, but can be easily remedied, as we'll see later.
Our buoyancy force generator can be updated to take an attachment point;
otherwiseitisasbefore:
Excerpt from include/cyclone/fgen.h
/**
* A force generator to apply a buoyant force to a rigid body.
*/
class Buoyancy : public ForceGenerator
{
/**
* The maximum submersion depth of the object before
* it generates its maximum buoyancy force.
*/
real maxDepth;
/**
* The volume of the object.
*/
real volume;
/**
* The height of the water plane above y=0. The plane will be
* parallel to the XZ plane.
*/
real waterHeight;
/**
* The density of the liquid. Pure water has a density of
* 1000 kg per cubic meter.
*/
real liquidDensity;
/**
* The center of buoyancy of the rigid body, in body coordinates.
*/
Vector3 centerOfBuoyancy;
public:
/** Creates a new buoyancy force with the given parameters. */
Search Nedrilad ::




Custom Search