# BodyWater Class

This class is used to simulate water body that provide buoyancy and waves from other physical bodies. It is simulated as a 2D grid with point particles positioned in the vertices of the mesh.

## BodyWater Class

This class inherits from Body### Members

## BodyWater ()

Constructor. Creates a water body with default properties.## BodyWater (Object object)

Constructor. Creates a water body with default properties for a given object.### Arguments

*Object*- Object with a new water body.**object**

## void addParticleHeight (vec3 position, float height)

Adds the vertical shift to the water. Nearby water particles, that form a plane water grid, will change their height accordingly, simulating rings on the water.### Arguments

*vec3*- Point local coordinates (only along**position***X*and*Y*axes) of the vertical shift.*float*- Height in units of the vertical water shift.**height**

## void addParticleVelocity (vec3 position, vec3 velocity)

Applies the force to the water. To nearby water particles, that form a plane water grid, will be passed appropriate velocity values, simulating wake from the moving object.### Arguments

*vec3*- Point local coordinates (only along**position***X*and*Y*axes) of applying the force.*vec3*- Velocity value.**velocity**

## int getAbsorption ()

Returns a value indicating if the waves are dispersed along the mesh perimeter.### Return value

Positive value, if the waves are dispersed along the mesh perimeter;**0**if they are reflected.

## float getAngularDamping ()

Returns the current value indicating how much the angular velocity of the objects decreases when they get into the water.### Return value

Anglular damping value.## float getDensity ()

Returns the current density of the water that determines objects buoyancy.### Return value

Density value.## float getDepth ()

Returns the current depth of the water (unless intersection has occured).### Return value

Depth value.## float getDistance ()

Returns the current distance of water simulation. It does not interfere with objects buoyancy.### Return value

Simulation distance.## float getInteractionForce ()

Returns the current interaction force that determines how much velocity values of water and objects that get into it are leveled.### Return value

Interaction force value.## int getIntersection ()

Returns a value indicating if intersection with the ground is enabled. The ground should be a parent node.### Return value

Positive value if intersection is enabled,**0**if disabled.

## float getLinearDamping ()

Returns the current value indicating how much the linear velocity of the objects decreases when they get into the water.### Return value

Linear damping value.## float getLiquidity ()

Returns the current fluidity of the water.### Return value

Liquidity value.## float getParticleHeight (vec3 position)

Returns the vertical shift of the given point of the water.### Arguments

*vec3*- Point local coordinates (only along**position***X*and*Y*axes).

### Return value

Height in units of the vertical water shift.## vec3 getParticleVelocity (vec3 position)

Returns the velocity value in the given point of the water.### Arguments

*vec3*- Point local coordinates (only along**position***X*and*Y*axes).

### Return value

Velocity value.## void setAbsorption (int absorption)

Updates a value indicating if the waves should be dispersed along the mesh perimeter.### Arguments

*int*- Positive number to allow wave dispersion,**absorption****0**for the waves to be reflected.

## void setAngularDamping (float damping)

Updates a value indicating how much the angular velocity of the objects decreases when they get into the water.### Arguments

*float*- Anglular damping value. If a negative value is provided,**damping****0**will be used instead.

## void setDensity (float density)

Updates the density of the water that determines objects buoyancy.### Arguments

*float*- Density value. If a negative value is provided,**density****0**will be used instead.

## void setDepth (float depth)

Updates the depth of the water (unless intersection has occured).### Arguments

*float*- Depth value. If a negative value is provided,**depth****0**will be used instead.

## void setDistance (float distance)

Updates the distance of water simulation. It does not interfere with objects buoyancy.### Arguments

*float*- Simulation distance. If a negative value is provided,**distance****0**will be used instead.

## void setInteractionForce (float force)

Updates the interaction force that determines how much velocity values of water and objects that get into it are leveled.### Arguments

*float*- Interaction force value. If a negative value is provided,**force****0**will be used instead.

## void setIntersection (int intersection)

Updates a value indicating if intersection with the ground is enabled. The ground should be a parent node.### Arguments

*int*- Positive value to enable intersection,**intersection****0**to disable it.

## void setLinearDamping (float damping)

Updates a value indicating how much the linear velocity of the objects decreases when they get into the water.### Arguments

*float*- Linear damping value. If a negative value is provided,**damping****0**will be used instead.

## void setLiquidity (float liquidity)

Updates the viscosity of the water.### Arguments

*float*- Liquidity value. If a negative value is provided,**liquidity****0**will be used instead.

Last update: 2017-07-03

Help improve this article

Was this article helpful?

(or select a word/phrase and press Ctrl+Enter)