This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Cloth Body

Cloth body enables physical simulation of textiles, clothing and foliage, as well as sheets of any soft material. A cloth can be torn to pieces and also it can be pinned to the following types of bodies:Cloth body 可以对纺织品、服装和树叶以及任何柔软材质的片材进行物理模拟。一块布可以撕成碎片,也可以钉在以下类型的物体上:

To pin a cloth to a body so it would hang like a cape or a curtain, use the Particles Joint.要将布钉在物体上使其像披风或窗帘一样悬挂,请使用粒子联合.

Cloth body greatly enhances the appearance of dressed characters (otherwise entirely animated) and saves the time of game artists. However, simulation of this type of body is quite costly and it is strongly recommended to use distance optimization to avoid performance hits.Cloth body 极大地增强了穿着角色的外观(否则完全动画)并节省了游戏美术师的时间。但是,这种类型的物体的模拟成本相当高,强烈建议使用距离优化以避免性能下降。

注意
Cloth body can be assigned only to Dynamic mesh objects.Cloth body 只能分配给 Dynamic mesh 对象。

See also也可以看看#

Mesh Requirements网格要求#

In most cases, it is important that polygon triangulation of the mesh, for which Cloth body is generated, is as illustrated! Otherwise, it may not stretch properly and evenly in all directions.在大多数情况下,生成 Cloth body 的网格的多边形三角剖分非常重要,如图所示!否则可能不会拉紧正确且均匀地向各个方向。

Required mesh triangulation

For example in 3ds Max, mesh topology needs to be edited manually: choose Modify > Selection > Edit Edges rollout and click Turn to turn the triangles in a poly.例如在 3ds Max 中,需要手动编辑网格拓扑:选择 Modify > Selection > Edit Edges 卷展栏并单击 Turn 将三角形转为多边形。

Mass-Spring Simulation Model质量弹簧仿真模型#

Cloth body is modeled as set of point masses (particles) located in the mesh vertices. Each particle is represented with a sphere shape and is linked together with other particles by inner spring joints that are located along the mesh edges. Inner joints allow to recreate mesh topology, on the one hand, and constrain stretching and folding, on the other.Cloth body 被建模为位于网格顶点的一组点质量(粒子)。每个粒子都用球体形状表示,并通过位于网格边缘的内部弹簧接头与其他粒子连接在一起。一方面,内部关节允许重新创建网格拓扑,另一方面可以限制拉伸和折叠。

Each particle is characterized by a position, mass and velocity and has a constant spherical shape with a set radius. The total mass of the whole body is equally distributed among them. In accordance with Newton's second law particles can be acted upon by a force or an impulse applied by inner joints and external forces (collision, gravity, air resistance, wind, etc.).每个粒子都以位置、质量和速度为特征,并具有恒定的球形,并具有一组半径.总数大量的全身的能量在他们中间平均分布。根据牛顿第二定律,粒子可以通过力量冲动由内关节和外力施加(碰撞,重力、空气阻力、风力等)。

Self-collision of the particles and collisions between different cloth bodies are not calculated. However, the cloth interacts with environment by colliding with other physical bodies if the Collision box is checked. Its behavior in case of contact is controlled by such parameters as friction and restitution. Selective physical interaction is available via corresponding bitmasks.不计算粒子的自碰撞和不同布体之间的碰撞。但是,如果选中 Collision 框,布料会通过与其他物理物体碰撞来与环境交互。它在接触情况下的行为由以下参数控制摩擦归还.选择性的物理交互可通过相应的位掩码.

Thus, Cloth body can be regarded as constrained system of rigid particles and therefore shares some parameters with rigid bodies:因此,Cloth body 可以被视为刚性粒子的约束系统,因此与刚体共享一些参数:

Particle Radius粒子半径#

As it was already mentioned, each particle is a sphere with a set radius. That brings the following:正如已经提到的,每个粒子都是一个具有设定半径的球体。这带来了以下内容:

  • Cloth particles use continuous collision detection, so higher values are preferable for more robust behavior. Collisions between the particles are not calculated and should not be considered when setting a radius. Be careful, however, as particles too big in diameter can provide incorrect interaction with environment (twitching or blowing up of the cloth). Too low radius results in poor collision handling.布料粒子使用连续碰撞检测,因此更高的值对于更稳健的行为更可取。不计算粒子之间的碰撞,设置半径时不应考虑。但是要小心,因为直径太大的颗粒会导致与环境的不正确交互(布料抽搐或炸开)。半径太小会导致碰撞处理不佳。
  • As cloth particles are approximated with spheres, the cloth never lies flat on the ground or tightly adheres to the surfaces. There is always some gap that corresponds in size to set radius.由于布料颗粒近似于球体,因此布料永远不会平放在地面上或紧紧粘附在表面上。总是有一些间隙与设置半径的大小相对应。
注意
An object can pass through the cloth, when the particle radius is small and the cloth is stretched. The reason is that continuous collision detection is performed only for particle spheres located in vertices of cloth mesh.物体可以穿过布料,当粒子半径很小并且布料是拉伸.原因是连续碰撞检测只对位于布料网格顶点的粒子球体进行。

Joints Solver Iterations关节求解器迭代#

The number of iterations controls the accuracy of the solution of cloth inner joints. This number indicates how many times the joints are solved per physics frame. Joints are solved in a random order to provide more predictable stretching results.迭代次数控制着布料内部关节的求解精度。此数字表示每个关节求解的次数物理框架.关节以随机顺序求解,以提供更可预测的拉伸结果。

  • Low number of iterations results in faster simulation. However, in this case the cloth is more prone to stretching and looks more elastic. The minimum value is 1.迭代次数少可加快模拟速度。然而,在这种情况下,布料更容易拉伸,看起来更有弹性。最小值为 1
  • High number of iterations provides more accurate solution of constraints. In this case the cloth looks stiffer. The maximum value is 16.大量的迭代提供了更准确的约束解决方案。在这种情况下,布料看起来更硬。最大值为 16

    注意
    Increased number of iterations is considerably expensive and at some point ceases to bring a noticeable benefit, so it should be kept within a reasonable cost-effectiveness limit.增加迭代次数是相当昂贵的,并且在某些时候不再带来明显的好处,因此应将其保持在合理的成本效益范围内。

Increasing the number of iterations may help to avoid twitching of a cloth.增加迭代次数可能有助于避免布料抽搐。

Stretching and Folding拉伸和折叠#

A cloth may be deformed by stretching and folding. These deformations are controlled with joint constraints of two types:布料可能会因拉伸折叠而变形。这些变形由两种类型的关节约束控制:

With these types of constraints, it is possible to obtain the desired look and feel of the cloth and simulate a variety of different deformable materials ranging from a stiff carton to soft lycra.通过这些类型的约束,可以获得所需的布料外观和感觉,并模拟各种不同的可变形材质,从坚硬的纸箱到柔软的莱卡。

Linear Restitution线性恢复#

Linear restitution determines how far the cloth particles can be stretched apart from each other. It enforces cloth joints to restore the distance that was between the vertices of the original mesh:线性恢复决定了布料粒子可以相互拉伸多远。它强制布料关节来恢复原始网格顶点之间的距离:

  • By the maximum value of 1, the particles spring back with great force and the cloth is hard to stretch. It gives the effect of stiff non-stretch cloth, e.g. linen or tweed.1的最大值,粒子回弹力大,布料难以拉伸。它具有坚硬的无弹力布料效果,例如亚麻或粗花呢。
  • The lower the value, the easier the particles are moved away from each other and the more stretchable and elastic the cloth is, e.g. nylon or spandex.值越低,颗粒越容易相互远离,布料(例如尼龙或氨纶)的可拉伸性和弹性越大。

    注意
    0 and near zero values are not allowed because they cause unstable simulation and blowing up of the cloth.0 和接近零的值是不允许的,因为它们会导致模拟不稳定和布料爆炸。

Angular Restitution角度恢复#

Angular restitution determines the possible angle between cloth triangles that are formed by particles. It constrains the folding of the cloth by enforcing joints to keep the angle that was between triangles of the original mesh:角度恢复决定了由粒子形成的布料三角形之间可能的角度。它通过强制关节保持原始网格三角形之间的角度来约束布料的折叠:

  • By the maximum value of 1, the angles tend to be retained and the cloth resists folding. The cloth appears to be stiff and wrinkle-free (for example, paper).通过 1 的最大值,角度趋于保持并且布料抵抗折叠。布看起来很硬,没有皱纹(例如,纸)。

    注意
    The maximum value may provide unsteady behavior.最大值可能会提供不稳定的行为。
  • By the minimum value of 0, the cloth can be easily folded and bent in any direction, regardless of the original topology of the mesh.通过 0 的最小值,无论网格的原始拓扑如何,布料都可以轻松地向任何方向折叠和弯曲。
注意

If the cloth is too stretchy and rubbery, try one of the following:如果布料太有弹性和弹性,请尝试以下方法之一:

  • Set linear restitution to 1.将线性恢复设置为 1
  • Increase the number of joints solver iterations.增加关节求解器的数量迭代.
  • Use the mesh with fewer vertices.使用顶点较少的网格。

Rigidity of Motion运动刚性#

Rigidity parameter is an additional constraint of the cloth motion to make it stiffer and more inflexible. For that purpose, linear and angular velocities of each cloth particle are corrected according to the total velocities interpolated for all the particles.刚性参数是布料运动的附加约束,使其更硬和更不灵活。为此,每个布料粒子的线速度和角速度根据为所有粒子插值的总速度进行校正。

  • The minimum value of 0, makes the cloth elastic, flexible and easily deformable.0 的最小值,使布料有弹性、柔韧且容易变形。
  • The maximum value of 1, makes the cloth stiffer and less prone to deformation.1 的最大值,使布料更硬,不易变形。

Tearing撕裂#

When the cloth is stretched beyond its elastic limit or folded, it tears and shreds into pieces. Tearing is caused by applying the force or collision with a physical body, and depends on the cloth stiffness (controlled by linear and angular restitution parameters). For example, imagine the cannonball hitting the sail and leaving the hole in it. The cloth is torn only along the edges of cloth triangles, splitting mesh vertices and duplicating particles.当布料被拉伸超过其弹性极限或折叠时,它会撕裂并撕成碎片。撕裂是由施加力或与物理物体碰撞引起的,并且取决于布料的刚度(由控制线性角度恢复参数)。例如,想象炮弹击中帆并在帆上留下洞。布料仅沿布料三角形的边缘撕裂,分裂网格顶点并复制粒子。

Cloth tearing

Tearing of cloth布料撕裂
注意
If torn pieces of cloth fall onto one plane, they cause Z-fighting.如果撕裂的布块落在一个平面上,它们会引起 Z-fighting。

Linear Threshold Distance线性阈值距离#

Linear threshold sets the distance limit for stretching the cloth. When two particles move away from each other further than this limit, joints that connect them break and the tear appears.线性阈值设置距离限制伸展布。当两个粒子彼此远离的距离超过此限制时,连接它们的关节会断裂并出现撕裂。

  • If set to infinity (inf), the cloth is stretched without tearing. This value is set by default.如果设置为无穷大 (inf),布料会被拉伸而不会撕裂。该值是默认设置的。

Angular Threshold Angle角度阈值角度#

Same as linear threshold, angular threshold represents a maximum angle to fold the cloth relative to its initial state. If cloth triangles are bent any further, the joint breaks and triangles are separated along the adjacent edge.与线性阈值相同,角度阈值表示最大角度折叠布料相对于其初始状态。如果布料三角形被进一步弯曲,接头会断裂,三角形会沿着相邻的边缘分开。

  • If set to infinity (inf), the cloth is folded without tearing. This value is set by default.如果设置为无穷大 (inf),则将布料折叠而不撕裂。该值是默认设置的。

    注意
    It is recommended to keep the angular threshold lower or equal to 180 degrees.建议保持角度阈值低于或等于 180 度。

Optimizing Simulation优化仿真#

Updating each frame a huge number of objects located far away from the camera that are hardly distinguishable or observed as a mass is a waste of resources.更新每一帧远离相机的大量物体,这些物体几乎无法区分或观察为质量是一种资源浪费。

To improve performance and avoid the excessive load, simulation of the cloth can be updated with a reduced framerate. When the player is out of the area specified by the Update Distance Limit, the cloth stops to be updated and freezes statically.为了提高性能并避免过度负载,可以对布料进行模拟更新了降低的帧率.当玩家离开 Update Distance Limit 指定的区域时,布料停止更新并静态冻结。

The set of frame rates given below enables you to specify how often the cloth simulation should be updated when the object is visible, when only its shadow is visible, or when it is not visible at all.下面给出的一组帧速率使您能够指定在对象可见、仅其阴影可见或根本不可见时应更新布料模拟的频率。

Parameters -> Physics tab -> Periodic Update sectionParameters -> Physics 选项卡 → Periodic Update 部分
FPS When Object Is Rendered To Viewport Update rate value for the case when the object is rendered to viewport.对象渲染到视口时的更新速率值。
FPS When Only Object Shadows Are Rendered Update rate value when the object itself is outside the viewing frustum, and only its shadow is rendered to viewport.当对象本身在视锥体之外时更新速率值,并且只有它的阴影被渲染到视口。
FPS When Object Is Not Rendered At All Update rate value when both the object and its shadow are not rendered to the viewport.当对象及其阴影都未渲染到视口时更新速率值。
Update Distance Limit Distance from the camera up to which the object should be updated.对象应更新到的距离相机的距离。
注意
These values are not fixed and can be adjusted by the Engine at any time to ensure best performance.这些值不是固定的,引擎可以随时调整以确保最佳性能。

This feature is enabled with default settings ensuring optimum performance and can be adjusted per-object in UnigineEditor or via API at run time.此功能使用默认设置启用,可确保最佳性能,并且可以在 UnigineEditor 中或通过 API 在运行时针对每个对象进行调整。

警告
Please be aware that using reduced update frame rate for an object should be carefully considered in your application's logic, as it may lead to various issues with rendering skinned and dynamic meshes (flickering due to misalignment, e.g. in case of attaching a cloth to a skinned mesh).请注意,在应用程序的逻辑中应仔细考虑对对象使用降低的更新帧速率,因为这可能会导致渲染Mesh Skinned和Mesh Dynamic的各种问题(由于未对齐而闪烁,例如在将布附加到Mesh Skinned的情况下)。

Assigning a Cloth Body指定布体#

To assign a Cloth body to an object via UnigineEditor perform the following steps:通过将 Cloth body 分配给对象统一编辑器执行以下步骤:

  1. Open the World Hierarchy window.打开 World Hierarchy 窗口。
  2. Select a Dynamic Mesh object to assign a Cloth body to.选择要分配 Cloth bodyDynamic Mesh 对象。

    注意
    Make sure that object's mesh meets requirements!确保对象的网格满足要求
  3. Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> Cloth.转到 Parameters 窗口中的 Physics 选项卡并分配一个物理物体通过选择 Body -> Cloth 到选定的对象。

    Adding a body

  4. Set body's name and change other parameters, if necessary.如有必要,设置物体的名称并更改其他参数。

Attaching the Cloth连接布料#

I'm Batman!

Cloth attached to animated character附加到动画角色的布料

A cloth can be attached to the following types of bodies:布可以附着在以下类型的物体上:

To attach a cloth to a body use a Particles Joint. In case of Rigid bodies (either static, or dynamic) and Dummy bodies, pinned particles stay fixed in their position and follow transformations of attached objects pulling the cloth with it.要将布料附加到物体,请使用 Particles Joint。在 Rigid 实体(静态或动态)和 Dummy 实体的情况下,固定粒子保持固定在其位置并跟随附着对象的变换拉动布料。

  1. Select Rigid body, Ragdoll body or Dummy body.选择 Rigid body, Ragdoll bodyDummy body
  2. Add Particles Joint.添加 Particles Joint
  3. Specify Cloth body.指定 Cloth body
  4. Adjust the pinning area using the Threshold and Size parameters of the particles joint.使用粒子关节的 ThresholdSize 参数调整钉扎区域。
注意
To ensure stable simulation, set appropriate masses of the cloth and the attached body. Unbalanced masses may cause twitching of the cloth joints.为了确保稳定的模拟,设置适当的布料和附着体的质量。不平衡的质量可能会导致布料接头抽搐。

Attachment to Skinned Mesh附加到Skinned Mesh#

Convincing simulation of the clothing on a skinned character requires a different approach. To follow bones transformations, each vertex of the cloth that is found in the Particles Joint area is mapped to the nearest skinned mesh vertex (up to the distance specified by the Threshold parameter of the particles joint).令人信服的模拟皮肤角色的服装需要不同的方法。为了遵循骨骼变换,在 Particles Joint 区域中找到的布料的每个顶点都映射到最近的蒙皮网格顶点(最多由粒子关节的 Threshold 参数指定的距离)。

注意
It is not recommended to attach the cloth directly to the skinned character, because difference in topologies may result in visual artifacts. Instead of it, it is better to create an identical cloth surface on the skinned mesh character, make it invisible and attach a physical cloth to it.不建议将布料直接贴在蒙皮角色上,因为拓扑不同可能会导致视觉伪影。取而代之的是,最好在蒙皮网格角色上创建相同的布料表面,使其不可见并在其上附加物理布料。

For example, we need to create a cape that is glued to the shoulders of a skinned character while the rest flaps and folds loosely. It is done in the following steps:例如,我们需要创建一个披风,它粘在蒙皮角色的肩膀上,而其余部分则松散地襟翼和折叠。它是通过以下步骤完成的:

  1. When creating a Mesh Skinned, add a cape surface identical to the cape that the character would wear. It can be either a whole cape, or only its clipped part that needs to be pinned. The latter is preferable when complex clothing is simulated, which requires more flexible control over which parts to simulate physically and which ones to move with skinned character. In our case, it's cloth part over the shoulders.创建 Mesh Skinned 时,添加与角色将穿的披风相同的披风表面。它可以是整个披风,也可以只是需要固定的剪裁部分。当模拟复杂的服装时,后者更可取,这需要更灵活地控制哪些部分进行物理模拟,哪些部分与蒙皮角色一起移动。在我们的例子中,它是肩膀上的布料部分。
  2. Add skinned mesh that has a Ragdoll body assigned. Make sure that the cape surface is enabled.添加分配了 Ragdoll body 的蒙皮网格。确保启用了斗篷表面。
  3. Add a separate dynamic cloth mesh and synchronize its position with skinned character. Turn off physical simulation (CTRL + SPACE) and assign a Cloth body.添加单独的动态布料网格并将其位置与蒙皮角色同步。关闭物理模拟 (CTRL + SPACE) 和分配Cloth body
  4. Attach Cloth body to Ragdoll body. If the Threshold distance of the particles joint is set low enough, the physical cape will be automatically attached only to the cape surface (i.e. shoulders). After that, the cape surface is simply disabled and does not provide any load at all.Cloth bodyRagdoll body。如果particles关节的 Threshold 距离设置得足够低,物理披风将自动仅附加到披风表面(即肩部)。之后,斗篷表面被简单地禁用并且根本不提供任何负载。
最新更新: 2023-06-21
Build: ()