Procedural mesh的createMeshSection里 SectionIndex参数的作用
时间: 2024-03-16 22:41:50 浏览: 18
`CreateMeshSection` 函数是 `ProceduralMeshComponent` 类中用于创建程序化网格的函数之一。它的原型如下:
```c++
bool CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals, const TArray<FVector2D>& UVs, const TArray<FColor>& VertexColors, const TArray<FProcMeshTangent>& Tangents, bool bCreateCollision, EUpdateFrequency UpdateFrequency, ESectionUpdateFlags UpdateFlags, int32 MaterialIndex);
```
其中,`SectionIndex` 参数表示要创建的网格体的索引号。在一个 `ProceduralMeshComponent` 中,可以包含多个网格体,每个网格体都有一个独立的索引号,用于标识该网格体。如果 `SectionIndex` 参数的值已经被占用,则会更新该索引对应的网格体的顶点、三角形、法线、UV、颜色、切线等信息,从而修改该网格体的形状与外观。如果 `SectionIndex` 参数的值未被占用,则会创建一个新的网格体,并将其添加到 `ProceduralMeshComponent` 中。
需要注意的是,`SectionIndex` 参数的取值范围应该在 `0` 到 `MaxSectionsAllowed - 1` 之间,其中 `MaxSectionsAllowed` 是 `ProceduralMeshComponent` 中可以创建的最大网格体数量。默认情况下,`MaxSectionsAllowed` 的值为 `16`,但可以通过调用 `SetMeshSectionCount` 函数来修改该值。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)