Overview

This procedure is for big leaves or branches, which bend on collision. It is a type of bone / rope setup based on UV instancing but newer versions of the engine actually feature a easier to use, more optimized approach known as merged mesh deform. Both techniques should be considered before applying. More information on merged mesh deform can be found at the bottom of the page

Touch bending is a simple rope setup to simulate a physical interaction between the player and vegetation foliage. This method works well for big leaves, with separate stems/branches, as well as bushes.

General Setup Information

Touch bending uses some clever techniques to simplify the setup procedure massively:

  • Instancing for the setup works via shared UV's: leaves which share the same UV space will automatically work with touch bending.
  • Joints are setup via helpers/dummies, which are connected via naming convention.
  • A volume proxy needs to include all branches being used for touch bending.

Setup of Instances (UV Layout)

  • By sharing the same UV space, objects can inherit the joint setup from a "master leaf".
  • Below you can find the UV Layout of a typical setup for a palm tree. The red outline indicates the UV for the upper side of the palm tree leaf.
  • Instances can be created by duplicating the "master leaf" an element or cluster within the same object. Rotation, translation, Scale and even changes to the shape of the instance can be applied to instances (moving individual vertices, not changing vertex count).

Joint Setup

The joint setup is controlled by placing helpers/dummies at sensible positions on a "master leaf" and by following a naming convention.

Position

Place the dummies where you would like the branch to start bending, one or more intermediate steps and at the tip of the branch.

The dummy position must be equal to the vertex's position, which they are supposed to animated. The best way to achieve this, is to snap the dummy to the vertex.

The engine interpolates between these dummies with a kind of rope setup and weights all other vertices automatically. Please check the picture below for the null positions.

Naming Convention

The system allows for numerous branches (this is how the rope based joints are called) per object. The naming convention is relatively simple:

branch<# of branch>_<# number of joint>

This dummy setup only has to be done once per shared UV Layout.

In the example above it is branch1_1, branch1_2 and branch1_3.

If you want to add another branch with a different UV Layout, just name the dummies for this branch: branch2_1, branch2_2, ..., branch2_4.

Volume Proxy

  • Your object need a proxy for this which is physicalized as "noCollide".
  • Touch bending will only be detected in this volume.
  • In the picture below, the orange circle indicates the size of this proxy. Ideally, the proxy is big enough to enclose all branches, being setup for touch bending.

3ds Max Setup

You can find a sample file in the Sample Assets Package.

This procedure is for big leaves or branches, which bend on collision. Its a kind of bone or rope setup based on UV instancing.

Your object need a proxy for this which is physicalized as "noCollide". Touch bending will only be detected inside this volume.

You can create the setup for one branch/leaf and it will be the same on all other branches/leaves which share the same UV mapping.

In the first example we have an object using the trunk as position and rotation parent. That means you can't attach a branch to another branch because it would take the trunk as rotation reference.

You need to place dummy objects using vertex snap so that they are exactly on the vertex.

Use the following names for the dummies:

  • branch1_1
  • branch1_2
  • branch1_3

If you want to make a second branch with a different mapping setup, name the dummies like this:

  • branch2_1
  • branch2_2
  • branch2_3

You can add more branches if you need to. Be sure to number them correctly. Set the pivot of your object to worldspace 0. At the moment we have a maximum limit of 32 ropes / bones in the engine.

Using Parents and Childs for bending:

To make a branch dependent on another branch, you have to give your parent another unique UV mapping (should not share the mapping with the childs). In addition your child "branch* _1" dummies (your start dummies) have to be within the bone's radius of your parent branch.

Keep in mind that the bones/ropes will be generated in-game always between two dummies which you placed in 3ds Max before. So you can place the start dummy for your child bone somewhere on the line between two linked branch dummies from your parent branch.

The engine will automatically detect those intersecting bones and creates a parent child setup. The parent branch dummies don't have to start with branch1_*. They could also use branch2_*. It just depends on, if your branch start dummy is intersecting with another "branch line" (two linked branch dummies).

You can use p_draw_helpers 2 in the console command line to debug touch bending in the editor. There is no way for artist to tweak the bending itself. Contact a Programmer for this.

Export your objects like this:

Maya Setup

1. Create a group under the 'cryexportnode' named '@_helper' replacing the '@' with the name of your model.
2. Create a material for the trunks which uses 'default' physicalisation to physicalise the render geometry.
3. Create a material for the leaves which has 'none' set for its physicalisation option.
4. Assign the relevant materials to the trunks and leaves.
5. To create a bendable branch you must place locators that are snapped to vertices along the leaf. The locators must use the naming convention branch%_$ - where % corresponds to the branch id and $ is the joint id on that branch eg. branch1_1, branch1_2 and branch1_3.

6. To enable the branches to become usable in game you must add a 'bending_proxy' volume that encompasses the extents of the leaves that will be bendable. eg. create a sphere and ensure the branches are on the inside of the sphere.
7. Create a new material for the bending proxy with 'NoCollide' set as its physicalisation.
8. Apply the bending proxy material to the bending_proxy geometry.

9. Select the 'cryexportnode' group.
10. Select the file type from the drop down that appears in the 'Node Options' section.
11. Ensure the 'Do Not Merge Nodes' option in the 'Node Options' section is checked.
12. Click the 'Export' button on the 'Crytek Export' dialog.
13. The hierarchy with lods and proxies and branches should look like the above.

Editor Setup

Place your object as vegetation. The material needs to be Vegetation Shader with the leaves checkbox turned on.

Merged Mesh Deform

This is a new option for deformable, interactive vegetation, setup is similar to previous techniques but much easier to use. Please visit Cloth Merged Mesh Deform for more information.


Additional Settings

The following console variables can be used to tweak the physical behavior of the branches (some of them can also be set on a per-asset basis via UDP keywords, listed in brackets - for instance "damping 10.5")

  • e_FoliageBranchesStiffness (stiffness) - how fast the branches will try to return to the original pose
  • e_FoliageBranchesDamping (damping) - used to damp the stiffness; without it a branch would sway back and forth, never coming to rest
  • e_FoliageBranchesTimeout (timeout) - if a vegetation object doesn't have any collisions within this time interval, it gets forcefully deactivated (even if it still moves)
  • e_FoliageBrokenBranchesDamping - same as damping, but for parts of vegetation that breaks away
  • thickness (UDP-only; if not set, either 0.03 or 0.1 is used, depending on length) - sets ropes' thickness

 

触碰弯曲

本程序适用于碰撞时会弯曲的较大的树叶或分枝。这是一种基于 UV 实例的骨骼/绳索设置。

触碰弯曲是一种简单的绳索设置,模拟玩家与植被叶子之间的物理交互作用。此方法不仅适用于灌木,还对带有单独的茎/分枝的大树叶效果很好。
 

通用设置信息

触碰弯曲使用一些聪明的技术来大量地简化设置程序:

实例设置(UV 布局)

关节设置

通过在“主叶”上“具有重要战略意义”的位置放置 null 以及通过命名规范来控制关节设置。

位置

这些位置是分枝弯曲的起点,弯曲经过一个或多个中间步骤到达分枝的尖端。Null 的位置应与要制作成动画的顶点位置相等。实现此目的的最好方法是将 null 与顶点对齐。引擎在这些 null 之间插入一种绳索设置并自动为所有其他的顶点加权重。有关 null 的位置请查看下图。

命名规范

系统允许每个对象中存在许多分支(这就是将绳索称为基于关节的绳索的原因)。命名规范相对简单:

branch<# of branch>_<# number of joint>
这个 null 设置只需对每个共享的 UV 布局设置一次。

上方是示例是 branch1_1branch1_2 和 branch1_3
如果想用不同的 UV 布局添加其他分枝,只将此分枝的 null 命名为 branch2_1, branch2_2, ..., branch2_4 即可。

容积代理

3ds Max 设置

此处使用了 3ds Max 示例文件

本程序适用于碰撞时会弯曲的较大的树叶或分枝。这是一种基于 UV 实例的骨骼或绳索设置。

为此,对象需要一个物理化成“无碰撞”的代理。只能在此容积内检测到触碰弯曲。以后植物只在此区域内会受到影响。此设置基于 UV 实例。为分枝或叶子进行的设置会应用到共享相同的 UV 映射的所有其他的树叶。

在第一个实例中,有一个将树干作为位置和旋转父级别的对象。那就意味着不能将一个分枝附加到另一个分枝上,因为对象将会以树干作为旋转参考。

使用顶点对齐放置助手对象以便将对象精确地放置在顶点。

使用以下名称:

  • branch1_1
  • branch1_2
  • branch1_3

如果用不同的映射设置生成第二个分枝,请将助手像这样命名:

  • branch2_1
  • branch2_2
  • branch2_3

如果需要就可以添加更多的“分支”。确保将分支正确地编号。将对象的轴心点设为世界空间 0。如果需要就可以添加更多的“分支”。只需确保分支编号的正确性就可继续添加。此时,引擎中已有 32 个绳索/骨骼,这是最大限度。

使用弯曲父级别和子级别

若要使一个分支依赖另一个分支,就需要为父级别指定另一个唯一的 UV 映射(不能与子级共享此映射)。此外,子级别 "branch* _1" 虚拟物体(起始虚拟物体)必须在父级别分支骨骼的半径内。

记住游戏中骨骼/绳索总是在之前放入 3ds Max 的两个虚拟物体之间生成。因此,可以将子级别骨骼的起始虚拟物体放置在父级别分支中两个链接的分支虚拟物体之间线的某处。

引擎将自动检测这些交叉的骨骼并创建父级别子级别设置。父级别虚拟物体不需要以 branch1_* 开始。它们可以使用 branch2_*。这只取决于分支起始助手是否和另一个“支线”(两个链接的分支助手)交叉。

使用控制台命令行的 "p_draw_helpers 2" 调试编辑器中的触碰弯曲。艺术家是不能微调弯曲的。对此,可联系程序员。

像这样导出对象:

Maya 设置

1. 在 "cryexportnode" 下创建一个名为 "@_helper" 的组,将 "@" 替换成模块名称。
2. 为树干创建一个材质,此材质使用“默认”物理化使渲染器几何体物理化。
3. 为树叶创建一个材质,此材质中物理化选项被设为“无”。
4. 将相关材质指定到树干和树叶。
5. 若要创建可弯曲的分枝,必须沿着叶子放置与顶点对齐的定位器。定位器必须使用命名规范 branch%_$:% 对应分枝 id,$ 是分枝上的关节 id。例如:branch1_1、branch1_2 和 branch1_3。

6. 为使分枝在游戏中可用,必须添加 "bending_proxy" 容积,包含可弯曲的所有树叶。例如,创建一个球体并确保分枝都在球体的里面。
7. 为弯曲代理创建一个新的材质且材质的物理化被设置为“无碰撞”。
8. 将弯曲代理材质应用到 bending_proxy 几何体。

9. 选择 "cryexportnode" 组。
10. 在“节点选项”区段出现的下拉列表中选择文件类型。
11. 确保已选中“节点选项”区段中的“不合并”选项。
12. 单击“Crytek 导出”对话框上的“导出”按钮。
13. 带有 LOD、代理和树枝的层级结构应看起来像上述那样。

为使易碎树叶在 Sandbox 中运行,应将其作为放置在地形上的植被对象放置。另外,Sys_spec 关卡设置必须将树的 LOD 允许至最低的 LOD 以允许破坏。

CryENGINE3\Game\Config\CVarGroups 有一个名为 sys_spec_ObjectDetail.cfg 的文件,您可以使用这些值开始游戏。如果想知道每个 cvar 的作用,在控制台上输入 DumpCommandsVars。系统就会在您的版本中创建一个巨大的 html 帮助系统。

了解整个系统配置也很有益。系统配置必须要和 Env. Lead 和控制台程序员一起设置。

XSI 中的设置

层级设置

除正常的层级结构外,所有的分支关节节点都要链接到 CryExportNode。

请参阅下图:

材质设置

对 null 不需要进行特别设置。需要将“触碰弯曲”容积代理的物理设置设为“无碰撞”。这样就允许玩家穿过代理边界,但是会提示引擎以特别的方式对待此容积。

设置棕榈树树叶

下方的简单示例解释了为植被对象上的弯曲树叶创建 XSI 设置的步骤。

创建一个“主叶”,关节设置将从此主叶中创建。

确保所有的 UV 坐标被规格化(0 < UV 坐标 <1)。

创建第一个分支助手并将其命名为 branch1_1。在所有轴上将其缩放至 0.1 以使其更好地适配到模块。

启用*对齐点*并将其移动到树叶的根部。

设置 3 至 4 个分支助手,将它们相应地命名并与适当的顶点对齐。

打开*多边形岛屿*,选择滤镜过滤以轻松地选择单一树叶。

选择主叶并使用工具“复制多边形”。

将生成的新序列多边形平移、旋转和缩放。创建新的树叶直到能形成漂亮、看起来自然的树冠。

为对象添加树干,将分支助手设置为 CryExportNode 的父级别。层级结构应和下图相似:

此时可将树导出并在引擎中测试。

编辑器设置

将对象作为植被放置。打开树叶复选框,材质需要是“植被 Shader”。