Game Development Reference
In-Depth Information
The formula for the force calculation is therefore
0
when d
0
f
=
when d
1
dvρ
otherwise
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,
d
0):
y o
y w
s
d
=
2 s
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.
*/
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.
*/
Search Nedrilad ::




Custom Search