RagDoll Body
RagDoll body enables inverse kinematics and procedural animation of a death sequence for bone-animated characters. This type of body is actually a set of Rigid bodies representing each bone of a character linked together by joints. These joints restrict movement of the bones relative to each other, providing realistic look.RagDoll物体使能反向运动学和死亡序列的程序动画骨骼动画人物。这种体型其实是一组刚体代表通过关节连接在一起的角色的每个骨骼。这些关节限制骨骼相对于彼此的运动,提供逼真的外观。
See also也可以看看#
- BodyRagdoll classBodyRagdoll 类
- Fragment of the video tutorial on physics illustrating inverse kinematics of a RagDoll body说明物理的视频教程的片段RagDoll物体的逆运动学
Assigning a RagDoll Body分配RagDoll物体#
To assign a RagDoll body to an object via UnigineEditor perform the following steps:通过将 RagDoll物体分配给对象统一编辑器执行以下步骤:
- Open the World Hierarchy window.打开 World Hierarchy 窗口。
- Select a Mesh Skinned object to assign a RagDoll body to.选择一个网格蒙皮要为其分配 RagDoll物体的对象。
-
Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> RagDoll.转到 Parameters 窗口中的 Physics 选项卡并分配一个物理物体通过选择 Body -> RagDoll 到选定的对象。
- Set the body name and refer to the next section to create a RagDoll.设置body名称,参考下一节创建RagDoll。
Creating a Physical RagDoll创建物理RagDoll#
There are two ways of creating a RagDoll:有两种方法可以创建 RagDoll:
- Automatic generation.自动生成。
- Manual creation.手动创建.
After the body is assigned to the Mesh Skinned, the first step is to create a Rigid body that will represent each bone in physical simulation.将 body 分配给 Mesh Skinned 后,第一步是创建一个 Rigid body,它将代表物理模拟中的每个骨骼。
For now, all the bones are free, meaning there is no Rigid body associated with them. To automatically generate a RagDoll, i.e. rigid bodies and approximating shapes along with joints to connect them, Create button should be clicked.目前,所有骨骼都是free ,这意味着没有 Rigid body 与它们关联。要自动生成 RagDoll,即刚体和近似形状以及连接它们的关节,应单击 Create 按钮。
Automatic generation is performed on the basis of the following parameters:自动生成基于以下参数执行:
Approximation Shape近似形状#
Bones can be approximated either with Convex hull or Capsule, if Capsule shape box is checked:如果选中 Capsule shape 框,可以使用 Convex hull 或 Capsule 来近似骨骼:
- Capsule provides very fast physics simulation and continuous collision detection.Capsule 提供非常快速的物理模拟和连续碰撞检测。
- Convex hull provides more accurate approximation.Convex hull 提供更准确的近似值。
If any other shape is required, approximation is to be done manually.如果需要任何其他形状,则应进行近似手动.
Total MassTotal Mass#
Total mass of the RagDoll 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.全部的大量的RagDoll 将自动分布在所有近似骨骼的形状中。通过分布,形状占据的体积被考虑在内。如果此后更改了质量,则会重新计算所有形状的质量。反之,如果改变形状质量,则总质量也相应改变。
Approximation ErrorApproximation Error#
If convex hulls are used to approximate bones, the result may contain too much detail for collision geometry. As a rule, it is unnecessary, because a highly detailed shape does not provide noticeable visual difference while significantly affecting performance. Approximation error makes it possible 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.1 的最大值提供了可能无法覆盖所有网格体积的非常粗略的近似值。
If a character is approximated with capsules, low value of approximation error provides more precise shape orientation.如果使用胶囊来近似字符,则近似误差的低值提供更精确的形状方向。
Volume ThresholdVolume Threshold#
When creating a RagDoll, 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:创建 RagDoll 时,很少模拟小骨骼(例如手指骨骼)。它们太微不足道了,无法改变整个物体的运动,因为它们的质量和体积不足以改变整个物体的运动。体积阈值允许将所有体积太小的相邻小骨骼合并为一个形状:
- By the minimum value of 0, all the bones without exception are represented in rigid bodies and hence shapes.通过 0 的最小值,所有骨骼无一例外都以刚体和形状表示。
- 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.通过 1 的最大值,近似形状很大并且仅跟随主要骨骼。此卷中包含小骨骼,但在物理模拟中不考虑它们的个别变换。
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 RagDoll 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.创建 RagDoll 后,所有以刚体和形状表示并指定其运动的骨骼在层次结构中都标记为绑定。所有不参与物体运动的小骨头,都标记为空闲。如果自动生成的形状太松散,可以手动调整它们直到近似值足够令人满意。
Hierarchy of bodies and shapes that approximate bones can be saved into a *.node file and loaded from it. The set hierarchy can as well be removed from the RagDoll body and created anew.近似骨骼的物体和形状的层次结构可以保存到 *.node保存到文件中并从中加载。集合层次结构也可以从 RagDoll物体中删除并重新创建。
Manual Creation of a RagDoll手动创建RagDoll#
It is also possible to create a RagDoll manually. In this case arbitrary shapes can be used to approximate bones of a RagDoll body. To create a RagDoll manually follow these steps:也可以手动创建 RagDoll。在这种情况下,可以使用任意形状来近似 RagDoll物体的骨骼。要手动创建 RagDoll,请执行以下步骤:
- Create a Node Dummy that will be a parent node for future RagDoll hierarchy.创建一个 Node Dummy,它将成为未来 RagDoll 层次结构的父节点。
- 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.添加一个 Dummy Object 并使其成为子节点。为它分配一个 Rigid body 并以它所代表的骨骼命名物体。之后,用任何必要的形状近似骨骼。
- Create all Rigid bodies and shapes for the RagDoll bones. Hierarchy is of no importance, only names of the bodies do — they should be the same as the names of the bones. If body names mismatch bone names, it will cause an error.为 RagDoll 骨骼创建所有 Rigid 实体和形状。等级并不重要,重要的是物体的名字——它们应该和骨骼的名字一样。如果体名与骨名不匹配,将导致错误。
- Export the parent node into the *.node file.将父节点导出到 *.node 文件中。
- Select the character and load this file for its RagDoll body.选择角色并为其 RagDoll物体加载此文件。
- Add and set up joints that connect rigid bodies within the RagDoll.添加和设置连接 RagDoll 内刚体的关节。
Enabling RagDoll Animation启用RagDoll动画#
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 box is unchecked, RagDoll 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 RagDoll, velocity damping, etc.), joint constraints and Rigidity of motion.当角色撞到障碍物或中弹身亡时,需要关闭骨骼动画播放,根据物理规律真实模拟角色坠落。取消选中 Frame-based 框时,RagDoll物体不再由骨骼变换驱动。它根据Rigid body 动力学(质量所有刚体,代表 RagDoll 的一部分,速度阻尼等),联合约束和刚性的运动。
Rigidity of Movement运动刚性#
The Rigidity parameter allows to additionally constrain the motion of a RagDoll. It determines how uniform the motion of RagDoll 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.Rigidity 参数允许额外限制 RagDoll 的运动。它决定了 RagDoll 部分的运动有多均匀。为了实现这一点,每个单独刚体的线速度和角速度都根据从所有刚体插入的总速度进行校正。
- By the minimum value of 0, all RagDoll parts represented in rigid bodies move independently and unrestricted (of course, except for joint constrains). This gives an impression of loose and floppy movement.通过 0 的最小值,刚体中表示的所有 RagDoll 部分独立且不受限制地移动(当然,关节约束除外)。这给人一种松散和松软运动的印象。
- By the maximum value of 1, RagDoll parts move in a uniform and stiff manner, which may seem over-constrained.通过 1 的最大值,RagDoll 零件以均匀和僵硬的方式移动,这似乎过度约束。
Combined Animation and Inverse Kinematics组合动画和反向运动学#
The problem with pre-baked 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 it 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.例如,腿部的物理驱动运动需要禁用整个肢体的骨骼动画:大腿、小腿和脚。给定层次结构中最低骨骼(脚)的位置,反向运动学允许正确定位骨骼链。因此,当角色走路或跑步时,他的脚会与地面发生碰撞,而膝盖则根据关节约束弯曲和伸直。