Game Development Reference
The formula for the force calculation is therefore
where s is the submersion depth (the depth at which the object is completely sub-
merged), ρ is the density of the liquid, v is the volume of the object, and d is the
amount of the object submerged, given as a proportion of its maximum submersion
depth (i.e., when it is fully submerged, d
1, and when it is fully out of the water,
y o −
y w −
where y o is the y coordinate of the object and y w is the y coordinate of the liquid plane
(assuming it is parallel to the XZ plane). This can be implemented like this:
Excerpt from include/cyclone/pfgen.h
* A force generator that applies a buoyancy force for a plane of
* liquid parallel to XZ plane.
class ParticleBuoyancy : public ParticleForceGenerator
* The maximum submersion depth of the object before
* it generates its maximum buoyancy force.
* The volume of the object.
* The height of the water plane above y=0. The plane will be
* parallel to the XZ plane.
* The density of the liquid. Pure water has a density of
* 1000 kg per cubic meter.