继续解析《Electric Dreams》项目中的自定义节点和子图:ApplyHierarchy
![在这里插入图片描述](https://img-blog.csdnimg.cn/8f7b0cc8281748a1b5a693322fe48b9e.png)
前导文章
《UE5《Electric Dreams》项目PCG技术解析 之 理解Assembly(以SplineExample为例)》
《虚幻引擎程序化资源生成框架PCG 之 UPCGBlueprintElement源码笔记(一)》
《虚幻引擎程序化资源生成框架PCG 之 UPCGBlueprintElement源码笔记(二)数据流》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(一)》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(二)Look At》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(三)SG_CopyPointsWithHierarchy》
标准组合拳
![在这里插入图片描述](https://img-blog.csdnimg.cn/3025401deed943798ffbd0c26beb5b2a.png)
上一篇博文《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(三)SG_CopyPointsWithHierarchy》,我们分析了这套组合拳中SG_CopyPointsWithHierarchy
的工作原理,简单来说:
-
SG_CopyPointsWithHierarchy
其实就是携带source中层级信息和相对Transform的高级版CopyPoints。
- 它需要和"PCGSettings"一起工作(需要"PCGSettings"中原始
ActorIndex
和ParentIndex
信息)。
- 一般要和本文中介绍的
ApplyHierarchy
一起使用构成组合拳。
ApplyHierarchy
在使用ApplyHierarchy
之前,点云里存在一个由Actor Index
和Parent Index
索引构成的树形结构,而Relative Transform
则代表着每个层级子级Point
和父级Point
之间的"相对变换"。ApplyHierarchy
的作用就是将这个树形结构中一层层的Relative Transform
应用到每个Point
的Position
、Rotation
、Scale
属性(Property
)上。
Execute with Context
以上部分(包含Iteration Loop)的作用就是构造2个数组Ids
和Hierarchy Depths
:
-
Ids
数组:数组的Index
对应Point
的Index;
数组的Value
对应Actor Index
,这样通过Actor Index
或Parent Index
就可以反向找到实际的Index
-
Hierarchy Depths
数组:和上面的逻辑类似,建立Point
的Index
和Hierarchy Depth
一一对应关系。
![在这里插入图片描述](https://img-blog.csdnimg.cn/df4ca3f295314156bd45bb7c300c24a8.png)
逐层(Depth)将Relative Transform转换成Point
的Position
、Rotation
、Scale
属性(Property
)上,逻辑有点像“俄罗斯方块”。
Iteration Loop Body
![在这里插入图片描述](https://img-blog.csdnimg.cn/47d4ce62f3da4cc8b2ccb040f59d3431.png)
Point Loop Body
通过Actor Index
或Parent Index
反向找到实际的Index
![在这里插入图片描述](https://img-blog.csdnimg.cn/4be0e9a47c8341e585d0f07a4df058fa.png)
将该层(Depth)的Relative Transform转换成Point
的Position
、Rotation
、Scale
![在这里插入图片描述](https://img-blog.csdnimg.cn/ce4bf3a2ad244769a1f58a9d9b32090c.png)
删除无效的Point
。
![在这里插入图片描述](https://img-blog.csdnimg.cn/0efd6cac4ccf4935913b26d1f68b283e.png)
应用场景
注意:在“组合拳”中使用Transform Points
变换的对象为Relative Transform
![在这里插入图片描述](https://img-blog.csdnimg.cn/d57c88b5ad484d7ea7ed0a5715ccad29.png)
小结
SG_CopyPointsWithHierarchy
构造了一个虚拟的"树形结构",而ApplyHierarchy
是将"树形结构"和层级之间的Relative Transform
应用到Point
的Position
、Rotation
、Scale
属性上。