This page has been translated automatically.
编程
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Rag Doll Body

Rag doll is an another important type of body in real-time physics simulation. It allows to provide a bone-animated characters with procedural animation of a death sequence: they fall on the ground in a unique way depending on how and where they were hit.

Rag doll bodies can be assigned only to skinned mesh objects.

Rag doll animation

Rag doll animation

See also

Creating Physical Rag Doll

After the body is assigned to the skinned mesh, the first step is to create a rigid body that will represent each bone in physical simulation. A rag doll is effectively a collection of multiple rigid bodies, that follow the bones transformations. They are attached to each other by joints, which restrict how the rigid bodies may move relative to each other. When the object collapses to the ground, joint limits are taken into account and make the falling look more realistic, as more correct interaction with the environment is provided.

For now, all the bones are free, meaning there is no rigid body associated with them. To automatically generate a rag doll, i.e. rigid bodies and approximating shapes along with joints to connect them, Create button should be clicked. Automatic generation is done basing on the following parameters:

Approximation Shape

Bones can be approximated either with Convex hulls or Capsules, if Capsule shape box is checked:

  • Capsules provide very fast physics simulation and continuous collision detection.
  • Convex hulls allow more accurate approximation.

If any other shape is required, approximation is to be done manually.

Approximation with capsules and convex hulls

Approximation with capsules and convex hulls
Notice
Remember, physical shapes need not reproduce the mesh precisely. Rough approximation provides physical interaction that is realistic and convincing enough.

Total Mass

Total mass of the rag doll will be automatically distributed among all the shapes that approximate bones. By distribution, the volume that the shape occupies is taken into account. If the mass is changed afterwards, all the shapes masses are recomputed. And the opposite way, if shape mass is changed, the total mass is modified correspondingly.

Approximation Error

If convex hulls are used to approximate bones, the result may contain too much detail for collision geometry. In common cases, it is not necessary, because there is no stunning visual difference when highly detailed shapes collide, yet their impact on performance is substantial. Approximation error allows to control the number of vertices in the resulting convex hull:

  • The lower the value, the more accurate and close to the mesh approximated shape is.
  • The maximum value of 1 provides quite rough approximation that may not cover all the mesh volume.

If a character is approximated with capsules, low value of approximation error will orient shapes more precise.

Volume Threshold

When creating a rag doll, small bones (like finger bones, for example) are rarely simulated. They are too insignificant to change the motion of the whole object, as their mass and volume is not sufficient for that. Volume threshold allows to merge all small adjacent bones, the volume of which is too small, into one shape:

  • By the minimum value of 0, all the bones without exception are represented in rigid bodies and hence shapes.
  • By the maximum value of 1, approximation shapes are big and follow only the major bones. Small bones are included in this volume, but their individual transformations are not considered in physical simulation.

Minimum volume threshold     Maximum volume threshold
Volume threshold defines whether all bones up to the smallest one should be simulated separately or merged into bigger shapes

 

Body Hierarchy for Bones

After a rag doll has been created, all the bones that are represented in rigid bodies and shapes and specify their movement are marked as bound in the hierarchy. All the small bones not participating in physical body movement, stay marked as free. If automatically generated shapes are too loose, they can be tuned manually till approximation is satisfying enough.

Hierarchy of bodies and shapes that approximate bones can be saved into a .node and loaded from one. The set hierarchy can as well be removed from the rag doll body and created anew.

Hierarchy of rigid bodies that represent bones

Manual Creation of a Rag Doll

It is also possible to create a rag doll manually. By that, the choice of shapes that approximate bones is not limited to convex hull or capsule. Moreover, different types of shapes can be freely mixed to be used together in one rag doll body. Follow these step to create a rag doll manually:

  1. Create a dummy node that will be a parent node for future rag doll hierarchy.
  2. Add a dummy object and make it a child node. Assign a rigid body to it and name the body after the bone it will represent. After that, approximate the bone with any necessary shape.
  3. Create all rigid bodies and shapes for the rag doll bones. Hierarchy is of no importance, only names of the bodies do.
  4. Export the parent node into the .node file.
  5. Select the character and load this file for its rag doll body.
  6. Add and set up joints that connect rigid bodies within the rag doll.

Enabling Rag Doll Animation

When the character hits some obstacle or, for example, he is shot and dies, it is necessary to turn off bone-based animation playback and simulate the character realistically falling according to the physical laws. When the Frame-based animation box is unchecked, rag doll body is no longer driven by the bone transformations. It collapses according to rigid body dynamics (masses of all rigid bodies, that represent parts of a rag doll, velocity damping, etc.), joint constraints and rigidity of motion.

Notice
Enabling rag doll animation influences only those bones that were physically approximated. For example, small bones that were discarded due to volume threshold, will still move. To prevent this from happening, mesh animation should be stopped explicitly.

Rigidity of Movement

Rigidity parameter allows to additionally constrain the motion of a rag doll. It determines how uniform the motion of rag doll parts is. To achieve that, both linear and angular velocities of each separate rigid body are corrected according to the total velocities interpolated from all the bodies.

  • By the minimum value of 0, all rag doll parts represented in rigid bodies move independently and unrestricted (of course, except for joint constrains). This gives an impression of loose and floppy movement.
  • By the maximum value of 1, rag doll parts move in a uniform and stiff manner, which may seem over-constrained.

Combined Animation and Inverse Kinematics

The problem with pre-backed animation is that it does not offer proper environmental interaction. For example, when walking up or down the hill, character's feet do not land firmly on terrain. Or as he climbs the ladder, the hands have to tightly grab the rungs. This effect is achieved with combined animation: motion animation is played for the basic bones, while smaller bones (feet or hands, for example) are simulated physically.

Frame-based animation can be disabled for each of the rigid bodies that approximate bones. Instead of following specific bone transformation, rigid body sags loose under its own weight and connects to collider objects underneath it.

For instance, physically-driven motion of the leg requires disabling bone animation of the whole limb: thigh, calf and foot. Inverse kinematics allows to properly position the chain of bones given the position of the lowest bone in the hierarchy, the foot. So when the character walks or runs, his foot collides with the ground, while the knee bends and straightens according to the joint constrain.

Inverse Kinematics

With inverse kinematics feet of the characters are tightly glued to the floor no matter how tilted the surface is
Last update: 2017-07-03
Build: ()