Files
XCEngine/docs/api/resources/mesh/add-section.md

53 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Mesh::AddSection
```cpp
void AddSection(const MeshSection& section);
```
添加一个网格分段Submesh。网格分段用于将一个网格分割成多个部分每个部分可以有不同的材质。
**参数:**
- `section` - 网格分段结构,包含顶点和索引范围以及材质 ID
**返回:**
**异常:**
**线程安全:**
**复杂度:** O(1) 均摊
**示例:**
```cpp
#include "XCEngine/Resources/Mesh.h"
using namespace XCEngine::Resources;
Mesh mesh;
mesh.SetVertexData(...);
mesh.SetIndexData(...);
// 添加第一个分段(使用材质 0
MeshSection section1;
section1.baseVertex = 0;
section1.vertexCount = 4;
section1.startIndex = 0;
section1.indexCount = 6;
section1.materialID = 0;
mesh.AddSection(section1);
// 添加第二个分段(使用材质 1
MeshSection section2;
section2.baseVertex = 4;
section2.vertexCount = 4;
section2.startIndex = 6;
section2.indexCount = 6;
section2.materialID = 1;
mesh.AddSection(section2);
```
## 相关文档
- [类总览](mesh.md) - 返回类总览