Rigid Body
Rigid body enables simulation of physical bodies in accordance with Rigid body dynamics. This type of body is the most commonly used and the most efficient in terms of performance.
The set of parameters of a Rigid body in accordance with Rigid body dynamics includes the following:
- Density
- Linear Damping and Angular Damping
- Maximum Linear Velocity and Maximum Angular Velocity
- Friction
- Restitution
- Freezable
- Immovable
See also#
Programming realization:
- BodyRigid class.
Shape-based mass parameters#
Volume of a Rigid body can be approximated by several shapes (e.g. a concave object divided into a set of convex hulls or a Ragdoll body). Each shape has its mass and density. Therefore certain parameters of a Rigid body, such as its total mass, center of mass, and inertia tensor, are determined by its shapes. These parameters can be calculated automatically if the Shape-based option is enabled.
To enable this option for a body via UnigineEditor perform the following steps:
- Select the desired object with a Rigid body assigned.
- Go to the Physics tab in the Parameters window.
- In the Body section, check the Shape-based option.
Overriding Shapes Parameters#
Disabling the Shape-based option makes it possible to manually redefine some total parameters for the body.
To disable this option for a body via UnigineEditor perform the following steps:
- Select the desired object with the Rigid body assigned.
- Go to the Physics tab in the Parameters window.
- In the Body section, check Shape-based option. The fields of total parameters for the body will be activated.
- Set up body parameters manually.
Center of mass#
An arbitrary point can be set to be a center of mass of the body. It may be necessary to correct the motion of an object to provide desirable look. For example, a tilting doll with a sphere shape requires an uneven mass distribution: its center of mass should be located closer to the bottom, so it always stands up when tilted.
Moment of Inertia#
The moment of inertia is a rotational analog of mass, describing the resistance of the body to rotation in different directions. It is determined by the distribution of mass throughout the body volume. The farther from the axis of rotation the center of mass is, the more rotational inertia the body has.
The inertia tensor that allows to compute a moment of inertia about an arbitrary axis is represented as a matrix, I:
Ixx | Ixy | Ixz |
Iyx | Iyy | Iyz |
Izx | Izy | Izz |
where Iij sets the moment of inertia around the i -axis when the body is rotated around the j-axis.
As for values of the moment of inertia:
- The higher the value, the more torque must be be applied to rotate the body about a particular axis.
-
The lower the value, the easier it is to change the angular velocity of a body about a particular axis.
It is not recommended to set values less than 0.011! Otherwise, the matrix won't be properly inverted, which is necessary to apply collision impulse.
Values are corrected with respect to the average value to provide smoother movement.
For example, the following illustration shows three boxes with different inertia tensors. The yellow box has very high inertia:
100 | 0 | 0 |
0 | 100 | 0 |
0 | 0 | 100 |
Because of that, it can only slide down when falling upon the tilted plane. The red box, on the contrary, has the lowest inertia and rotates most eagerly.
Freezable Body#
If the Freezable flag is set for a Rigid body, its simulation is freezed when necessary.
Immovable#
The Immovable flag toggles the static mode for a Rigid body on and off. If the flag is set, the body will ignore all forces in the world and keep its position while being a collider object.
Assigning a Rigid Body#
To assign the Rigid body to an object via UnigineEditor perform the following steps:
- Open the World Hierarchy window.
- Select an object to assign a Rigid body to.
-
Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> Rigid.
- Set the body name and change other parameters if necessary.