搬运+机翻 Unity插件 OBICloth插件官方CharDemo分析

源地址http://obi.virtualmethodstudio.com/tutorials/proxycharactercloth.html
Use Case: Character Clothing Using Proxies
Last update: Obi Cloth version 2.X
This example goes in detail about how to replicate the trenchcoat sample scene included in Obi Cloth 3.0.
用例:使用代理的角色服装
最后更新:Obi Cloth版本2.X
这个例子详细介绍了如何复制Obi Cloth 3.0中包含的风衣样例场景。

Using proxies you can efficiently simulate complex character clothing with multiple layers.
In this example, we will use the trenchcoat mesh included in Obi 3.x. You can use any mesh you want, but remember that it has to contain skinning information (in other words, it has to use a SkinnedMeshRenderer) and should have a clean topology (no non-manifold structures).
First of all, we will set up the trenchcoat as we would with any other skinned cloth: generate a ObiMeshTopology asset for the trenchcoat mesh, add an ObiCloth component to the SkinnedMeshRenderer, and initialize the cloth. You can read about all of this in detail here and here, as we won’t go into further detail abou the basic setup here.
Note that we haven´t mentioned the ObiSolver component yet. Obi 3.x allows you to choose the space in which the simulation will be performed: world space or local space. Now, if we were to simulate the trenchcoat in world space, things would work ok for the most part. This is the default behavior of ObiSolver. However, simulating cloth in local space has two advantages: we will suffer no numerical precision loss when we wander away from the world’s origin (which is essential for big game worlds), and the ability to control how much of the character movement is transferred to the cloth. So for character cloth, local space simulation is reccomended. In order to simulate actors in local space, we must set up the ObiSolver in a slightly different way:
First, all ObiActors using the solver must be below it in the scene hierarchy. So in case of a character, the solver must be placed at the root game object.
The solver should have “Simulate in local space” enabled.
In the included sample scene, you´ll notice the ObiSolver component has been added to the Man_trenchcoat object, and that “Simulate in local space” is checked. The trenchcoat object itself is a direct child of this object. You should mimic this setup as closely as possible when adding cloth to your own characters.
Now that we have the solver and the cloth in place, let’s start with the simulation. Enter particle edit mode, select all particles that should be simulated (in our case, all trenchcoat particles from the waist down) and unfix them. You should end with something like this:
使用代理可以有效地模拟具有多个层的复杂角色服装。
在本例中,我们将使用Obi 3.x中包含的风衣网格。
您可以使用任何您想要的网格,但是请记住它必须包含剥皮信息(换句话说,它必须使用SkinnedMeshRenderer),并且应该有一个干净的拓扑结构(没有非流形结构)。
首先,我们将像设置任何其他有皮肤的布料一样设置trenchcoat:为trenchcoat网格生成ObiMeshTopology资产,向SkinnedMeshRenderer添加obiccloth组件,并初始化布料。
您可以在这里和这里详细阅读所有这些内容,因为我们不会在这里详细介绍基本设置。
注意,我们还没有提到ObiSolver组件。
奥比3。
x允许您选择执行模拟的空间:世界空间或本地空间。
现在,如果我们要在世界空间中模拟战壕大衣,大部分情况下都可以。
这是ObiSolver的默认行为。
然而,在局部空间中模拟布有两个优点:当我们离开世界的原点时(这对于大型游戏世界是至关重要的),我们将不会遭受数值精度的损失,并且能够控制角色的运动有多少转移到布上。
针对字符布,提出了局部空间仿真方法。
为了在局部空间模拟参与者,我们必须以稍微不同的方式设置ObiSolver:
首先,所有使用求解器的ObiActors必须位于场景层次结构的它下面。
因此,对于角色,求解器必须放在根游戏对象中。
求解器应该启用“模拟本地空间”。
在包含的示例场景中,您将注意到ObiSolver组件已经添加到Man_trenchcoat对象中,并且选中了“在本地空间中模拟”。
trenchcoat对象本身是该对象的直接子对象。
在为自己的角色添加布料时,应该尽可能地模拟这种设置。
现在我们已经有了求解器和布料,让我们从模拟开始。
进入粒子编辑模式,选择所有应该被模拟的粒子(在我们的例子中,所有的风衣粒子从腰部以下)并解开它们。
你应该这样结尾:

Now, by clicking “Optimize” in the ObiCloth inspector (see the optimization page for more info) we can get rid of all particles that won´t actually be part of the simulation, to concentrate resources on the ones we need:
现在,通过点击obiccloth检查器中的“优化”(更多信息见优化页面),我们可以去除所有实际上不属于模拟的粒子,将资源集中在我们需要的粒子上:

Using tether constraints for a cloth this dense is almost mandatory if we want to prevent over-stretching (which can be a problem specially in fast-moving characters), so we hit “Generate tether constraints” in the cloth inspector. By doing this, Obi will automatically calculate the best tether configuration for our cloth. You can enable the “visualize” checkbox to get a visual preview of what the tether setup looks like for your mesh. In the case of our trenchcoat, all free particles have been automatically tethered to the waist in order to prevent stretching. If you want to know more about tethers, see this.
如果我们想要防止过度拉伸(这在快速移动的字符中可能是一个特别的问题),那么在布料检查器中使用系绳约束几乎是强制性的,所以我们点击“生成系绳约束”。通过这样做,Obi将自动计算我们的布的最佳系绳配置。您可以启用“可视化”复选框,以获得对网格的缆索设置的可视化预览。以我们的风衣为例,所有的自由粒子都被自动地系在腰部,以防止拉伸。如果你想了解更多关于绳子的知识,请看这个。

Up to this point, there’s been not many differences in our workflow when compared to a simple, single layered cloth. However, if we were to simulate the trenchcoat at this point, we’d see lots of artifacts and self-intersections because the mesh has two-sides that cannot collide with each other. Also, it has pockets, zones of different thickness… it would be insanely slow (and not very reliable) to try and simulate all of this using self-collisions.
For this reason, we will use cloth proxies. The same mesh can act both as proxy source and target, and that’s exactly what we´ll do here. Add a ObiClothProxy component to the trenchcoat, and you´ll see it only has two parameters: the source particle proxy (drag the trenchcoat itself here) and the skin map used to transfer the source simulation to the target mesh.
到目前为止,与简单的单层布料相比,我们的工作流程并没有太多的不同。然而,如果我们在这一点上模拟战壕大衣,我们会看到许多人工制品和自交点,因为网格有两面,不能互相碰撞。此外,它有口袋,不同厚度的区域…尝试使用自碰撞来模拟所有这一切将是极其缓慢的(而且不是非常可靠的)。
因此,我们将使用布代理。相同的网格可以同时作为代理源和目标,这正是我们在这里要做的。将ObiClothProxy组件添加到沟槽中,您将看到它只有两个参数:源粒子代理(将沟槽本身拖动到这里)和用于将源模拟转移到目标网格的皮肤映射。
It’s time now to author the skin map, which we will use to tell Obi which parts of the trenchcoat should be simulated, and which parts should simply follow the movement of the simulated part. In case of a trenchcoat, it is simpler to simulate the inner side of it, and skin the outside of the mesh -which has complex details- to it. Right-click on one of your project folders, and go to Create->Obi->Obi Triangle Skin Map. This will create a new skin map asset in your folder, rename it if you wish and check out its inspector:
现在是创建皮肤地图的时候了,我们将使用它来告诉Obi应该模拟战壕大衣的哪些部分,以及哪些部分应该简单地跟随模拟部分的运动。
在风衣的情况下,它是比较简单的模拟内部的一面,并皮肤的外部网格-这有复杂的细节-到它。
右键单击一个项目文件夹,然后转到创建->Obi->Obi三角形皮肤映射。
这将在你的文件夹中创建一个新的皮肤映射资产,如果你愿意重命名它,并检查它的检查器:

Set the source topology to be the one you generated the cloth with, and the target mesh to be the mesh you want to drive. In our case, we´ll use the trenchcoat topology and the trenchcoat mesh, since it will be both source and target. Now click “Edit Skin Map” to enter skin map editor:
将源拓扑设置为生成布料的拓扑,目标网格设置为要驱动的网格。
在我们的示例中,我们将使用trenchcoat拓扑和trenchcoat网格,因为它既是源也是目标。
现在点击“编辑皮肤地图”进入皮肤地图编辑器:

Once in the editor, we need to tell Obi which parts of the source mesh are going to drive the target mesh, and which parts of the target mesh should be driven. This is done using skin channels. Vertices in the target mesh will only be skinned to triangles in the source mesh that share at least one skin channel with them. In the case of the trenchcoat, there’s a cut at the back of it. Vertices at one side of the cut could accidentally be skinned to triangles on the other side, but we don´t want this to happen. The solution is to paint 2 skin channels: one for the left part of the trenchcoat, and another for the right part. This way, vertices won´t be able to latch to triangles on the other side of the cut.
进入编辑器后,我们需要告诉Obi源网格的哪些部分将驱动目标网格,以及应该驱动目标网格的哪些部分。这是通过皮肤通道完成的。目标网格中的顶点将只被蒙皮到源网格中的三角形中,这些三角形与它们共享至少一个蒙皮通道。就风衣来说,后面有个口子。切割的一边的顶点可能会被意外地剥成另一边的三角形,但我们不希望这种情况发生。解决方案是绘制2个皮肤通道:一个在风衣的左边,另一个在右边。这样,顶点就不能与切边另一边的三角形连接。

Skin channels 0 and 1 for the source mesh (seen from below, as they are inside the trenchcoat)

Skin channels 0 and 1 for the target mesh.
Once we are done painting our source/target skin channels, we can hit “Bind” and Obi will calculate and store the skin map for us. Now we are ready to use it, hit “Done” to close the editor and go back to the trenchcoat’s ObiClothProxy component and feed the skin map to it. That’s all!
To wrap up, this is everything we did:
Create and setup an ObiCloth component for the trenchcoat, as usual.
Add an ObiSolver component to the character root, and enable local space simulation. Note the trenchcoat is a child of the solver.
Create a ObiTriangleSkinMap and use skin channels to define driving/driven parts of the mesh.
皮肤通道0和1为目标网格。一旦我们完成绘制我们的源/目标皮肤通道,我们可以点击“绑定”,Obi将为我们计算和存储皮肤地图。现在我们可以使用它了,点击“完成”关闭编辑器,回到trenchcoat的ObiClothProxy组件,并将皮肤映射提供给它。这是所有!最后,这就是我们所做的一切:像往常一样,为战壕大衣创建并设置一个obiccloth组件。向字符根添加一个ObiSolver组件,并启用本地空间模拟。注意trenchcoat是solver的子元素。创建一个ObiTriangleSkinMap并使用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值