shown in other instead.
Bodies can be considered physical approximations of objects. They describe the object's behavior and represent a set of its physical parameters, such as mass, velocity, etc. It is the body that enables interaction of an object with other objects and external physical forces. Each type of body is used for simulation of a specific type of object:
- Rigid body (also requires a shape to be assigned) — enables simulation of objects in accordance with the rigid body dynamics.
- Ragdoll body (also requires a shape to be assigned for each bone) — provides bone-animated characters with procedural animation of a death sequence.
- Fracture body — enables real-time simulation of destructible objects.
- Rope body — enables physical simulation of various types of ropes and wires.
- Cloth body — enables physical simulation of various types of cloth.
- Water body — enables physical simulation of liquids of different density and viscous behavior including buoyancy effect and wave dynamics.
- Dummy body — a static type of body without physical properties. It is used to attach other bodies via joints.
- Path body — a static type of body without physical properties. It is a spline, along which an arbitrary rigid body can be moved.
For quick visualization of all types of bodies, watch a fragment of our video tutorial on physics.
Rigid Body Dynamics#
Most physics simulations are based on rigid body dynamics. A rigid body is an ideal representation of a solid body, which occupies a finite volume of space. This volume of space is determined by a shape or a set of shapes assigned to the body. Rigid bodies cannot be deformed, i.e. their geometry does not change no matter what happens with this body. Rigid body dynamics is applied to the following bodies with shapes assigned:
After being enabled, all these bodies and their shapes that approximate the object's volume share common properties of rigid objects obeying Newtonian mechanics.
Watch a fragment of our video tutorial on physics for illustration of this article.
A state of a rigid body at any moment is specified with its position, orientation in space (with respect to some reference point — center of mass), and velocity. There are two types of body motion and, therefore, two velocity components:
- Linear motion. If we imagine that the orientation of the body is fixed, then the only movement the body can undergo is translation motion — change in linear position. This change is performed with linear velocity.
- Angular motion. On the other hand, if we freeze the center of mass of our body in space, the only movement the body will be able to perform is rotation, which is described by angular velocity.
As the body moves, its linear and angular momenta change. The linear momentum can be thought of as an extent to which the body will continue to move along a straight path. It is the product of mass and linear velocity of the body:
p = m * v
F = m * a
Impulse is the integral of force over time. It may be regarded as a change in momentum of an object to which a resultant force is applied. For example, when two bodies collide, they exchange impulses that are equal and opposite, as Newton's third law applies, and result in moving apart.
Similarly to the linear momentum, the angular momentum is the measure of the "quantity of rotation motion" and can be thought of as an extent to which the body will continue to rotate around an axis of symmetry. It is expressed as the product of the inertia tensor of the body and its angular velocity.
Rotation continues until torque, a rotational force, is exerted on this body. Torque is the cross product of the radius vector (a vector from the center of mass to the point where torque is applied) and the force vector (the magnitude of the force). Loosely speaking, it acts like a lever affecting rotational speed.
Forces and impulses can also be applied to an arbitrary point of the body and may cause body rotation, when this point is not the center of mass. In this case, force is computed as a cross product of force vector and radius vector (from the center of mass to the necessary point) and is added to the torque. And the other way around, torque applied not to the center of mass increases force.
To sum it up, the movement is characterized by the following basic parameters:
|Linear Motion||Angular Motion|
|Mass (scalar)||Inertia tensor (mat3)|
|Linear velocity (vec3)||Angular velocity (vec3)|
|Force(vec3) Impulse ( vec3)||Torque (vec3)|
Adjustable body parameters that determine its behavior in the framework of rigid body dynamics are as follows:
Mass of the object multiplied by gravity specified for the world defines its weight:
The center of mass is automatically calculated as the mean location of mass of all shapes that approximate the object. It serves as a reference point for linear motion and rotation, as well as application of external force and torque.
Density of the objects is defined as its mass per unit volume:
Density value evidently depends on the mass value and vice versa: the higher the values are, the heavier and more dense the object is.
Density determines buoyancy of the body in accordance with Archimedes' principle. The higher the density, the less tendency a body has to float.
Linear Damping and Angular Damping#
When the object begins moving in a definite direction, the linear damping force slows it down to a complete stop. Similar to linear damping, angular damping reduces angular velocity of objects over time, so that their rotation ceases. To the linear damping of the body, the global Linear Damp is added, and the exponential function is calculated. In exactly the same way to angular damping of the body, the global Angular Damp is added.
These two parameters ensure that objects smoothly come to a stop and no calculations are done for unnecessary motion.
Maximum Linear Velocity and Maximum Angular Velocity#
Maximum linear and angular velocity define the maximum possible velocities of the body. Velocities that exceed this limit are clipped. For example, the maximum linear velocity parameter can help to avoid tunneling (penetration) effect.
Coefficient of friction allows to model more rough rubbing of surfaces and is opposite to the body's movement direction. The higher the value, the less tendency the body has to slide. The friction values of both surfaces being in contact are considered.
The resulting calculated friction depends on the objects' masses and gravity, and the angle between contacting surfaces. For example, if a body slides down an inclined plane, the friction becomes lower because the force of gravity, which is perpendicular to the face of the surface, diminishes.
Friction is calculated at contact between physical bodies.
Coefficient of restitution determines the degree of relative kinetic energy retained after a collision. It defines how bouncy the object is by contacting with another object. It depends on the elasticity of materials of colliding bodies. The simulated restitution, like friction, considers the total value for both objects being in contact.
- The maximum value of 1 models elastic collision. Objects bounce off according to the impulse they get by contact.
- The minimum value of 0 models inelastic collision. Objects do not bounce at all.
Again, just like friction, restitution is calculated by the contact between physical bodies.
When a body does not move and stays in the equilibrium for some time, it will most probably be immobile until an external force is exerted on it and urges it to move again. During this period of inactivity, there is actually no need to simulate it. This state is called freezing and it allows saving a great deal of computational resources.
Frozen blue and unfrozen red boxes. The impulse applied to the pyramid of boxes unfroze all but one
- Its linear velocity is lower than Frozen linear velocity and its angular velocity is lower than Frozen angular velocity. Both velocity values must be lower at the same time, otherwise, the simulation will not stop.
There are also Frozen linear velocity and Frozen angular velocity thresholds set for the whole world. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.
- Velocity values stay lower than frozen velocities for the number of Frozen frames. This is done to ensure that the body has really terminated its motion.
When the body is frozen, its linear and angular velocity are set to 0. The simulation of the body movement starts again as another non-frozen object touches it or some force is applied to it.
Setting Body Parameters#
The parameters of each body are determined by its type. To view or adjust these parameters via UnigineEditor: