Buoyancy Class |
Namespace: DigitalRune.Physics.ForceEffects
The Buoyancy type exposes the following members.
Name | Description | |
---|---|---|
Buoyancy |
Initializes a new instance of the Buoyancy class.
| |
Buoyancy(IAreaOfEffect) |
Initializes a new instance of the Buoyancy class.
|
Name | Description | |
---|---|---|
Apply |
Applies the force effect to the specified body.
(Overrides ForceFieldApply(RigidBody).) | |
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnAddToSimulation |
Called when this force effect is added to a simulation.
(Inherited from ForceEffect.) | |
OnApply |
Called when the simulation wants this force effect to apply forces to rigid bodies.
(Inherited from ForceField.) | |
OnDisabled |
Called when this force effect was disabled.
(Inherited from ForceEffect.) | |
OnEnabled |
Called when this force effect was enabled.
(Inherited from ForceEffect.) | |
OnRemoveFromSimulation |
Called when this force effect is removed from a simulation.
(Inherited from ForceEffect.) | |
Prepare |
Prepares the specified rigid body for the buoyancy effect.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
AngularDrag |
Gets or sets the angular drag coefficient.
| |
AreaOfEffect |
Gets or sets the area of effect.
(Inherited from ForceField.) | |
Density |
Gets or sets the density of the liquid.
| |
Enabled |
Gets or sets a value indicating whether this ForceEffect is enabled.
(Inherited from ForceEffect.) | |
Gravity |
Gets or sets the gravity acceleration.
| |
LinearDrag |
Gets or sets the linear drag coefficient.
| |
Simulation |
Gets the simulation to which this force effect belongs.
(Inherited from ForceEffect.) | |
Surface |
Gets or sets the water surface plane (in world space).
| |
Velocity |
Gets or sets the linear velocity of the water.
|
This force field applies a buoyancy force to create the effect of rigid bodies swimming in water. The force effect is applied to all bodies in the AreaOfEffect. Typically this will be an GeometricAreaOfEffect: A collision object models the area of the water, e.g. a box can be used to model a swimming pool and all bodies touching this box are subject to the buoyancy effect. But the area of effect does not define the plane of the water surface - this is defined using the property Surface. The area of effect could also be a GlobalAreaOfEffect which means that simply all rigid bodies in a simulation are subject to the buoyancy force. Forces are only applied if a part of the body is below the water surface.
Since this effect uses a Plane to model the water surface, it cannot be used to model uneven water surface (waves, waterfalls, etc.).
This effects also applies a drag force (damping of movement) on the swimming bodies. The strength of the damping depends on LinearDrag and AngularDrag. To find good values for these coefficients, you can use following approach: First, set the coefficients to 0 and drop an average body into the water. The body will fall into the water and shoot back out. Repeat the experiment with increasing LinearDrag values until you have a good value. Then drop rotating bodies in the water and increase the AngularDrag until rotational damping fits your needs.
This force effect stores additional information in the rigid bodies. This additional information is computed when a rigid body starts to touch the water. The computation of this information can take some time, which can be a problem if many bodies are dropped into the water simultaneously. To avoid this problem, the method Prepare(RigidBody) can be called to compute the additional information ahead of time (e.g. when the game level is loading). If there are several instances of Buoyancy in a simulation, it is sufficient to call Prepare(RigidBody) only once per rigid body. The buoyancy information is shared between Buoyancy instances.