This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Rigid Body

Along with static meshes, objects with rigid bodies are most commonly used. Assigning an objects rigid body together with collision shape ensures that it moves and realistically interacts with other objects according to rigid bodies dynamics. Representing objects as rigid bodies is the most effective in terms of performance.

It is characterized by total mass of all its shapes, damping of linear and angular velocities etc. In addition to that, it is possible to control the undermentioned parameters.

Rigid bodies

See also

Shape-based mass parameters

The rigid body is comprised of shapes that approximate its volume. A shape has a mass (and density), a center of mass and inertia tensor calculated on the base of the previous two. As for the whole body, these parameters of each shape and shape positioning within the body can be used to compute the body's total mass and inertia properties. This computation is automatically done if Shape-based mass parameters box is checked.

Setting the individual masses or densities of the shapes is the most intuitive method to achieve correct physical behavior of the body. Even if overridden by body parameters, they are still used to determine the distribution of mass within the object.

Shapes that approximate rigid bodies

Rigid bodies that are approximated with different shapes according to their geometry

Overriding Shapes Parameters

Unchecking the Shape-based mass parameters box allows to redefine some total parameters for the body: corresponding fields are activated where the custom values are set up manually. For example, body's mass overrides the calculated sum of all the shapes masses.

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 for more desirable and pleasing to the eye. For example, tilting doll with a sphere shape requires an uneven mass distribution: its weight should be centered closer to the bottom, so it always stands up when tilted.

Center of mass is set as coordinates of the point in local space of the body.

Inertia

The moment of inertia describes the resistance to rotation of the body in different directions. It is a rotational analog of mass for linear motion. However, it's not only related to the total mass of the body, but also to the distribution of the mass throughout the body. The farther from the axis of rotation is, the more rotational inertia the body has. For example, imagine rotating a dumbbell around the center: if the weights are far on the opposite sides, the speed of rotation decreases. And vice versa, bringing the weights closer to the center results in faster and more effortless spinning.

The inertia tensor that allows to compute a moment of inertia about arbitrary axis is represented as a matrix, I:

I xx   I xy   I xz  
I yx   I yy   I yz  
I zx   I zy   I zz  

Here I xx sets the moment of inertia around the X-axis when the the body is rotated around the X-axis, I xy sets the moment of inertia around the Y-axis when the objects are rotated around the X-axis, etc. As for values:

  • The higher the moment of inertia value, the more torque should be be applied to rotate the body about a particular axis. Conversely, the lower the value, the easier it is to change the angular velocity of a body about a particular axis. Values are corrected with respect to the average value to provide smoother movement.
  • To rotate the body evenly about the rotation axis, the matrix should be diagonal, i.e all values outside the main diagonal are set to zero. Otherwise, the body may start to rotate chaotically.
Notice
Values should be no lower than 0.011. Otherwise, the matrix won't be properly inverted, which is necessary to apply collision impulse.

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.

Different Inertia tensors

Different inertia tensors that override shape-based parameters

Freezable Body

If a Freezable flag is set for a rigid body, its simulation is freezed when necessary.

Notice
Freezable flag is recommended to be always set for all rigid bodies except for Player Actor. Freezing a player causes it to react to the user's input with a time lag, small but nonetheless perceptible.
Last update: 2017-07-03
Build: ()