docs: update resources API docs
This commit is contained in:
52
docs/api/resources/mesh/add-section.md
Normal file
52
docs/api/resources/mesh/add-section.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# 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) - 返回类总览
|
||||
@@ -1,30 +0,0 @@
|
||||
# Mesh::AddSection
|
||||
|
||||
```cpp
|
||||
void AddSection(const MeshSection& section)
|
||||
```
|
||||
|
||||
添加网格分段(Submesh)。一个 Mesh 可以包含多个分段,每个分段对应一组索引和不同的材质。
|
||||
|
||||
**参数:**
|
||||
- `section` - 网格分段描述结构体
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
MeshSection section;
|
||||
section.baseVertex = 0;
|
||||
section.vertexCount = 1000;
|
||||
section.startIndex = 0;
|
||||
section.indexCount = 3000;
|
||||
section.materialID = 0;
|
||||
mesh->AddSection(section);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Mesh 总览](mesh.md) - 返回类总览
|
||||
31
docs/api/resources/mesh/constructor.md
Normal file
31
docs/api/resources/mesh/constructor.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Mesh::Mesh
|
||||
|
||||
```cpp
|
||||
Mesh();
|
||||
```
|
||||
|
||||
构造一个新的 Mesh 实例。初始化所有成员变量为默认值,顶点计数、索引计数均为 0,不持有任何数据。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
35
docs/api/resources/mesh/destructor.md
Normal file
35
docs/api/resources/mesh/destructor.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Mesh::~Mesh
|
||||
|
||||
```cpp
|
||||
virtual ~Mesh() override;
|
||||
```
|
||||
|
||||
销毁 Mesh 实例。如果资源已加载,会释放所有持有的顶点数据、索引数据和网格分段信息。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
{
|
||||
Mesh mesh;
|
||||
// 使用 mesh...
|
||||
}
|
||||
// mesh 在此处自动销毁
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
41
docs/api/resources/mesh/get-guid.md
Normal file
41
docs/api/resources/mesh/get-guid.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Mesh::GetGUID
|
||||
|
||||
```cpp
|
||||
ResourceGUID GetGUID() const override;
|
||||
```
|
||||
|
||||
返回网格资源的全局唯一标识符(GUID)。GUID 在资源创建时分配,用于资源系统的唯一标识和查找。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `ResourceGUID` - 资源的全局唯一标识符
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
IResource::ConstructParams params;
|
||||
params.name = "Character_Hero";
|
||||
params.path = "assets/meshes/hero.mesh";
|
||||
params.guid = ResourceGUID::Generate(params.path);
|
||||
mesh.Initialize(params);
|
||||
|
||||
ResourceGUID guid = mesh.GetGUID();
|
||||
if (guid.IsValid()) {
|
||||
// GUID 有效
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
34
docs/api/resources/mesh/get-index-count.md
Normal file
34
docs/api/resources/mesh/get-index-count.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Mesh::GetIndexCount
|
||||
|
||||
```cpp
|
||||
Core::uint32 GetIndexCount() const;
|
||||
```
|
||||
|
||||
获取网格的索引数量。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `Core::uint32` - 索引数量
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetIndexData(...);
|
||||
|
||||
uint32_t indexCount = mesh.GetIndexCount();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
34
docs/api/resources/mesh/get-index-data-size.md
Normal file
34
docs/api/resources/mesh/get-index-data-size.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Mesh::GetIndexDataSize
|
||||
|
||||
```cpp
|
||||
size_t GetIndexDataSize() const;
|
||||
```
|
||||
|
||||
获取网格索引数据的总字节数。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `size_t` - 索引数据字节数
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetIndexData(...);
|
||||
|
||||
size_t dataSize = mesh.GetIndexDataSize();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
37
docs/api/resources/mesh/get-index-data.md
Normal file
37
docs/api/resources/mesh/get-index-data.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Mesh::GetIndexData
|
||||
|
||||
```cpp
|
||||
const void* GetIndexData() const;
|
||||
```
|
||||
|
||||
获取网格索引数据的只读指针。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `const void*` - 索引数据指针,如果没有设置则返回 nullptr
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetIndexData(...);
|
||||
|
||||
const void* indexData = mesh.GetIndexData();
|
||||
if (indexData != nullptr) {
|
||||
// 安全访问索引数据
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
33
docs/api/resources/mesh/get-memory-size.md
Normal file
33
docs/api/resources/mesh/get-memory-size.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Mesh::GetMemorySize
|
||||
|
||||
```cpp
|
||||
size_t GetMemorySize() const override;
|
||||
```
|
||||
|
||||
返回网格资源占用的内存大小。包含顶点数据和索引数据的总字节数。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `size_t` - 内存大小(字节)
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
// 设置数据...
|
||||
size_t memSize = mesh.GetMemorySize();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
38
docs/api/resources/mesh/get-name.md
Normal file
38
docs/api/resources/mesh/get-name.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Mesh::GetName
|
||||
|
||||
```cpp
|
||||
const Containers::String& GetName() const override;
|
||||
```
|
||||
|
||||
返回网格资源的名称。名称在资源创建时通过 `IResource::Initialize` 方法设置。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `const Containers::String&` - 资源名称的引用
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
IResource::ConstructParams params;
|
||||
params.name = "Character_Hero";
|
||||
params.path = "assets/meshes/hero.mesh";
|
||||
params.guid = ResourceGUID::Generate(params.path);
|
||||
mesh.Initialize(params);
|
||||
|
||||
const String& name = mesh.GetName();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
38
docs/api/resources/mesh/get-path.md
Normal file
38
docs/api/resources/mesh/get-path.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Mesh::GetPath
|
||||
|
||||
```cpp
|
||||
const Containers::String& GetPath() const override;
|
||||
```
|
||||
|
||||
返回网格资源的路径。路径用于资源定位和唯一标识。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `const Containers::String&` - 资源路径的引用
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
IResource::ConstructParams params;
|
||||
params.name = "Character_Hero";
|
||||
params.path = "assets/meshes/hero.mesh";
|
||||
params.guid = ResourceGUID::Generate(params.path);
|
||||
mesh.Initialize(params);
|
||||
|
||||
const String& path = mesh.GetPath();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
40
docs/api/resources/mesh/get-sections.md
Normal file
40
docs/api/resources/mesh/get-sections.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Mesh::GetSections
|
||||
|
||||
```cpp
|
||||
const Containers::Array<MeshSection>& GetSections() const;
|
||||
```
|
||||
|
||||
获取网格的所有分段信息。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `const Containers::Array<MeshSection>&` - 分段数组的只读引用
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
mesh.SetIndexData(...);
|
||||
mesh.AddSection(...);
|
||||
|
||||
const auto& sections = mesh.GetSections();
|
||||
for (size_t i = 0; i < sections.Size(); ++i) {
|
||||
const MeshSection& section = sections[i];
|
||||
// 处理每个分段
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
34
docs/api/resources/mesh/get-type.md
Normal file
34
docs/api/resources/mesh/get-type.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Mesh::GetType
|
||||
|
||||
```cpp
|
||||
ResourceType GetType() const override;
|
||||
```
|
||||
|
||||
返回资源的类型标识符。对于 Mesh 类,返回值为 `ResourceType::Mesh`。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `ResourceType` - 资源类型,恒定为 `ResourceType::Mesh`
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
if (mesh.GetType() == ResourceType::Mesh) {
|
||||
// 这是一个网格资源
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
43
docs/api/resources/mesh/get-vertex-attributes.md
Normal file
43
docs/api/resources/mesh/get-vertex-attributes.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Mesh::GetVertexAttributes
|
||||
|
||||
```cpp
|
||||
VertexAttribute GetVertexAttributes() const;
|
||||
```
|
||||
|
||||
获取网格的顶点属性标志,表示网格包含哪些顶点数据通道。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `VertexAttribute` - 顶点属性标志,可通过按位与检查特定属性
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(
|
||||
...,
|
||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0
|
||||
);
|
||||
|
||||
VertexAttribute attrs = mesh.GetVertexAttributes();
|
||||
if (attrs & VertexAttribute::Normal) {
|
||||
// 网格包含法线数据
|
||||
}
|
||||
if (attrs & VertexAttribute::UV0) {
|
||||
// 网格包含第一组 UV 坐标
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
34
docs/api/resources/mesh/get-vertex-count.md
Normal file
34
docs/api/resources/mesh/get-vertex-count.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Mesh::GetVertexCount
|
||||
|
||||
```cpp
|
||||
Core::uint32 GetVertexCount() const;
|
||||
```
|
||||
|
||||
获取网格的顶点数量。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `Core::uint32` - 顶点数量
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
|
||||
uint32_t vertexCount = mesh.GetVertexCount();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
34
docs/api/resources/mesh/get-vertex-data-size.md
Normal file
34
docs/api/resources/mesh/get-vertex-data-size.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Mesh::GetVertexDataSize
|
||||
|
||||
```cpp
|
||||
size_t GetVertexDataSize() const;
|
||||
```
|
||||
|
||||
获取网格顶点数据的总字节数。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `size_t` - 顶点数据字节数
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
|
||||
size_t dataSize = mesh.GetVertexDataSize();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
37
docs/api/resources/mesh/get-vertex-data.md
Normal file
37
docs/api/resources/mesh/get-vertex-data.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Mesh::GetVertexData
|
||||
|
||||
```cpp
|
||||
const void* GetVertexData() const;
|
||||
```
|
||||
|
||||
获取网格顶点数据的只读指针。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `const void*` - 顶点数据指针,如果没有设置则返回 nullptr
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
|
||||
const void* vertexData = mesh.GetVertexData();
|
||||
if (vertexData != nullptr) {
|
||||
// 安全访问顶点数据
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
41
docs/api/resources/mesh/get-vertex-stride.md
Normal file
41
docs/api/resources/mesh/get-vertex-stride.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Mesh::GetVertexStride
|
||||
|
||||
```cpp
|
||||
Core::uint32 GetVertexStride() const;
|
||||
```
|
||||
|
||||
获取单个顶点的字节大小(步长)。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `Core::uint32` - 顶点步长(字节)
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
struct Vertex {
|
||||
float position[3];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(..., sizeof(Vertex), ...);
|
||||
|
||||
uint32_t stride = mesh.GetVertexStride();
|
||||
// stride == sizeof(Vertex)
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
40
docs/api/resources/mesh/is-use-32bit-index.md
Normal file
40
docs/api/resources/mesh/is-use-32bit-index.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Mesh::IsUse32BitIndex
|
||||
|
||||
```cpp
|
||||
bool IsUse32BitIndex() const;
|
||||
```
|
||||
|
||||
检查网格是否使用 32 位索引格式。如果返回 false,则表示使用 16 位索引格式。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `bool` - true 表示使用 32 位索引,false 表示使用 16 位索引
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetIndexData(..., 6, true); // 32 位索引
|
||||
|
||||
if (mesh.IsUse32BitIndex()) {
|
||||
// 使用 32 位索引访问
|
||||
const uint32_t* indices = static_cast<const uint32_t*>(mesh.GetIndexData());
|
||||
} else {
|
||||
// 使用 16 位索引访问
|
||||
const uint16_t* indices = static_cast<const uint16_t*>(mesh.GetIndexData());
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
44
docs/api/resources/mesh/is-valid.md
Normal file
44
docs/api/resources/mesh/is-valid.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Mesh::IsValid
|
||||
|
||||
```cpp
|
||||
bool IsValid() const override;
|
||||
```
|
||||
|
||||
检查网格资源是否有效。资源在调用 `Initialize` 后变为有效,调用 `SetInvalid` 或 `Release` 后变为无效。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `bool` - 资源是否有效
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
if (!mesh.IsValid()) {
|
||||
// 资源尚未初始化
|
||||
}
|
||||
|
||||
IResource::ConstructParams params;
|
||||
params.name = "Cube";
|
||||
params.path = "assets/meshes/cube.mesh";
|
||||
params.guid = ResourceGUID::Generate(params.path);
|
||||
mesh.Initialize(params);
|
||||
|
||||
if (mesh.IsValid()) {
|
||||
// 资源已初始化
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
@@ -2,149 +2,120 @@
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `class`
|
||||
**类型**: `class` (inherits from `IResource`)
|
||||
|
||||
**描述**: 网格资源类,管理 3D 模型的顶点数据、索引数据和网格分段信息。
|
||||
**头文件**: `XCEngine/Resources/Mesh.h`
|
||||
|
||||
**描述**: 网格资源类,用于存储和管理 3D 网格数据,包括顶点数据、索引数据和网格分段信息
|
||||
|
||||
## 概述
|
||||
|
||||
`Mesh` 是 XCEngine 中的网格资源类,继承自 `IResource`。它管理网格的顶点数据(位置、法线、UV、切线、颜色、骨骼权重等)、索引数据和网格分段(submesh)。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Resources/Mesh.h>
|
||||
```
|
||||
|
||||
## 枚举类型
|
||||
|
||||
### VertexAttribute
|
||||
|
||||
顶点属性标志枚举(可组合)。
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Position` | 位置坐标 |
|
||||
| `Normal` | 法线 |
|
||||
| `Tangent` | 切线 |
|
||||
| `Color` | 顶点颜色 |
|
||||
| `UV0` | 第一组纹理坐标 |
|
||||
| `UV1` | 第二组纹理坐标 |
|
||||
| `UV2` | 第三组纹理坐标 |
|
||||
| `UV3` | 第四组纹理坐标 |
|
||||
| `BoneWeights` | 骨骼权重 |
|
||||
| `BoneIndices` | 骨骼索引 |
|
||||
|
||||
## MeshSection 结构体
|
||||
|
||||
网格分段(Submesh)描述。
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `baseVertex` | `Core::uint32` | 基础顶点索引 |
|
||||
| `vertexCount` | `Core::uint32` | 顶点数量 |
|
||||
| `startIndex` | `Core::uint32` | 起始索引 |
|
||||
| `indexCount` | `Core::uint32` | 索引数量 |
|
||||
| `materialID` | `Core::uint32` | 对应材质 ID |
|
||||
Mesh 类是 XCEngine 引擎中的核心资源类型之一,负责管理 3D 模型的网格数据。它存储顶点属性(位置、法线、切线、UV 坐标、骨骼权重等)、索引数据以及网格分段(MeshSection)信息。Mesh 资源通常由资源加载器从外部文件(如 .obj、.fbx 等格式)加载,或通过程序化方式生成。
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 基础属性
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `ResourceType GetType() const` | 返回 `ResourceType::Mesh` |
|
||||
| `const Containers::String& GetName() const` | 获取网格名称 |
|
||||
| `const Containers::String& GetPath() const` | 获取网格路径 |
|
||||
| `ResourceGUID GetGUID() const` | 获取全局唯一标识符 |
|
||||
| `bool IsValid() const` | 检查网格是否有效 |
|
||||
| `size_t GetMemorySize() const` | 获取内存大小 |
|
||||
| `void Release()` | 释放网格引用 |
|
||||
| [`Mesh`](constructor.md) | 构造函数 |
|
||||
| [`~Mesh`](destructor.md) | 析构函数 |
|
||||
| [`GetType`](get-type.md) | 获取资源类型 |
|
||||
| [`GetName`](get-name.md) | 获取资源名称 |
|
||||
| [`GetPath`](get-path.md) | 获取资源路径 |
|
||||
| [`GetGUID`](get-guid.md) | 获取资源全局唯一标识符 |
|
||||
| [`IsValid`](is-valid.md) | 检查资源是否有效 |
|
||||
| [`GetMemorySize`](get-memory-size.md) | 获取资源内存大小 |
|
||||
| [`Release`](release.md) | 释放资源 |
|
||||
| [`SetVertexData`](set-vertex-data.md) | 设置顶点数据 |
|
||||
| [`GetVertexData`](get-vertex-data.md) | 获取顶点数据指针 |
|
||||
| [`GetVertexDataSize`](get-vertex-data-size.md) | 获取顶点数据大小 |
|
||||
| [`GetVertexCount`](get-vertex-count.md) | 获取顶点数量 |
|
||||
| [`GetVertexStride`](get-vertex-stride.md) | 获取顶点步长 |
|
||||
| [`GetVertexAttributes`](get-vertex-attributes.md) | 获取顶点属性 |
|
||||
| [`SetIndexData`](set-index-data.md) | 设置索引数据 |
|
||||
| [`GetIndexData`](get-index-data.md) | 获取索引数据指针 |
|
||||
| [`GetIndexDataSize`](get-index-data-size.md) | 获取索引数据大小 |
|
||||
| [`GetIndexCount`](get-index-count.md) | 获取索引数量 |
|
||||
| [`IsUse32BitIndex`](is-use-32bit-index.md) | 是否使用 32 位索引 |
|
||||
| [`AddSection`](add-section.md) | 添加网格分段 |
|
||||
| [`GetSections`](get-sections.md) | 获取所有网格分段 |
|
||||
|
||||
### 顶点数据
|
||||
## 相关类型
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `void SetVertexData(const void* data, size_t size, Core::uint32 vertexCount, Core::uint32 vertexStride, VertexAttribute attributes)` | 设置顶点数据 |
|
||||
| `const void* GetVertexData() const` | 获取顶点数据指针 |
|
||||
| `size_t GetVertexDataSize() const` | 获取顶点数据大小 |
|
||||
| `Core::uint32 GetVertexCount() const` | 获取顶点数量 |
|
||||
| `Core::uint32 GetVertexStride() const` | 获取顶点结构体大小(字节) |
|
||||
| `VertexAttribute GetVertexAttributes() const` | 获取顶点属性标志 |
|
||||
### VertexAttribute
|
||||
|
||||
### 索引数据
|
||||
```cpp
|
||||
enum class VertexAttribute : Core::uint32 {
|
||||
Position = 1 << 0,
|
||||
Normal = 1 << 1,
|
||||
Tangent = 1 << 2,
|
||||
Color = 1 << 3,
|
||||
UV0 = 1 << 4,
|
||||
UV1 = 1 << 5,
|
||||
UV2 = 1 << 6,
|
||||
UV3 = 1 << 7,
|
||||
BoneWeights = 1 << 8,
|
||||
BoneIndices = 1 << 9
|
||||
};
|
||||
```
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `void SetIndexData(const void* data, size_t size, Core::uint32 indexCount, bool use32Bit)` | 设置索引数据 |
|
||||
| `const void* GetIndexData() const` | 获取索引数据指针 |
|
||||
| `size_t GetIndexDataSize() const` | 获取索引数据大小 |
|
||||
| `Core::uint32 GetIndexCount() const` | 获取索引数量 |
|
||||
| `bool IsUse32BitIndex() const` | 是否使用 32 位索引 |
|
||||
顶点属性枚举,用于指定网格包含哪些顶点数据通道。多个属性可以通过按位或组合使用。
|
||||
|
||||
### 网格分段
|
||||
### MeshSection
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `void AddSection(const MeshSection& section)` | 添加网格分段 |
|
||||
| `const Containers::Array<MeshSection>& GetSections() const` | 获取所有分段 |
|
||||
```cpp
|
||||
struct MeshSection {
|
||||
Core::uint32 baseVertex;
|
||||
Core::uint32 vertexCount;
|
||||
Core::uint32 startIndex;
|
||||
Core::uint32 indexCount;
|
||||
Core::uint32 materialID;
|
||||
};
|
||||
```
|
||||
|
||||
网格分段结构,描述网格中某个子网格的区域信息,包括顶点范围、索引范围和材质 ID。
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// 加载网格
|
||||
ResourceHandle<Mesh> mesh = ResourceManager::Get().Load<Mesh>("models/player.fbx");
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
#include "XCEngine/Containers/Array.h"
|
||||
|
||||
// 手动设置顶点数据
|
||||
struct Vertex {
|
||||
float position[3];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
using namespace XCEngine;
|
||||
using namespace Resources;
|
||||
|
||||
Containers::Array<Vertex> vertices;
|
||||
vertices.Resize(vertexCount);
|
||||
// ... 填充顶点数据 ...
|
||||
void CreateQuadMesh(Mesh* outMesh) {
|
||||
struct Vertex {
|
||||
float position[3];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
|
||||
mesh->SetVertexData(
|
||||
vertices.Data(),
|
||||
vertices.Size() * sizeof(Vertex),
|
||||
vertexCount,
|
||||
sizeof(Vertex),
|
||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0
|
||||
);
|
||||
Vertex vertices[4] = {
|
||||
{{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
|
||||
{{ 0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{ 0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}}
|
||||
};
|
||||
|
||||
// 设置索引数据
|
||||
Containers::Array<uint32_t> indices;
|
||||
indices.Resize(indexCount);
|
||||
// ... 填充索引数据 ...
|
||||
uint32_t indices[6] = {0, 1, 2, 0, 2, 3};
|
||||
|
||||
mesh->SetIndexData(
|
||||
indices.Data(),
|
||||
indices.Size() * sizeof(uint32_t),
|
||||
indexCount,
|
||||
true // 32 位索引
|
||||
);
|
||||
VertexAttribute attributes = VertexAttribute::Position |
|
||||
VertexAttribute::Normal |
|
||||
VertexAttribute::UV0;
|
||||
|
||||
// 添加分段(一个网格可能有多个材质)
|
||||
MeshSection section;
|
||||
section.baseVertex = 0;
|
||||
section.vertexCount = vertexCount;
|
||||
section.startIndex = 0;
|
||||
section.indexCount = indexCount;
|
||||
section.materialID = 0;
|
||||
mesh->AddSection(section);
|
||||
outMesh->SetVertexData(vertices, sizeof(vertices), 4, sizeof(Vertex), attributes);
|
||||
outMesh->SetIndexData(indices, sizeof(indices), 6, false);
|
||||
|
||||
// 访问数据
|
||||
uint32_t vCount = mesh->GetVertexCount();
|
||||
uint32_t iCount = mesh->GetIndexCount();
|
||||
auto sections = mesh->GetSections();
|
||||
MeshSection section;
|
||||
section.baseVertex = 0;
|
||||
section.vertexCount = 4;
|
||||
section.startIndex = 0;
|
||||
section.indexCount = 6;
|
||||
section.materialID = 0;
|
||||
outMesh->AddSection(section);
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [IResource](../iresource/iresource.md) - 资源基类
|
||||
- [Material](../material/material.md) - 材质资源
|
||||
- [ResourceManager](../resourcemanager/resourcemanager.md) - 资源管理器
|
||||
- [Resources 总览](../resources.md) - 返回模块总览
|
||||
- **实现说明**: `MeshLoader::Load()` 仅为示例实现,不解析 FBX/OBJ 等格式的实际网格数据
|
||||
|
||||
38
docs/api/resources/mesh/meshsection.md
Normal file
38
docs/api/resources/mesh/meshsection.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# MeshSection
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `struct`
|
||||
|
||||
**描述**: 网格分段结构体,用于描述网格的一部分,支持多材质渲染。
|
||||
|
||||
## 概述
|
||||
|
||||
MeshSection 定义了网格的一个连续区域,每个区域可以有不同的材质。网格分段包含顶点和索引范围信息,以及关联的材质 ID。
|
||||
|
||||
## 成员变量
|
||||
|
||||
| 变量 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `baseVertex` | `Core::uint32` | 基准顶点偏移 |
|
||||
| `vertexCount` | `Core::uint32` | 顶点数量 |
|
||||
| `startIndex` | `Core::uint32` | 起始索引 |
|
||||
| `indexCount` | `Core::uint32` | 索引数量 |
|
||||
| `materialID` | `Core::uint32` | 材质 ID |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
MeshSection section;
|
||||
section.baseVertex = 0;
|
||||
section.vertexCount = 4;
|
||||
section.startIndex = 0;
|
||||
section.indexCount = 6;
|
||||
section.materialID = 0;
|
||||
mesh.AddSection(section);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Mesh 类总览](mesh.md) - 返回类总览
|
||||
- [AddSection](./addsection.md) - 添加网格分段
|
||||
41
docs/api/resources/mesh/release.md
Normal file
41
docs/api/resources/mesh/release.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Mesh::Release
|
||||
|
||||
```cpp
|
||||
void Release() override;
|
||||
```
|
||||
|
||||
释放网格资源持有的所有数据。将清空顶点数据、索引数据和所有网格分段信息,并将相关计数重置为 0。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(n) - n 为数据大小
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
mesh.SetIndexData(...);
|
||||
mesh.AddSection(...);
|
||||
|
||||
// 使用完毕,释放数据
|
||||
mesh.Release();
|
||||
|
||||
// 释放后所有数据清空
|
||||
assert(mesh.GetVertexCount() == 0);
|
||||
assert(mesh.GetIndexCount() == 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
44
docs/api/resources/mesh/set-index-data.md
Normal file
44
docs/api/resources/mesh/set-index-data.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Mesh::SetIndexData
|
||||
|
||||
```cpp
|
||||
void SetIndexData(const void* data, size_t size, Core::uint32 indexCount, bool use32Bit);
|
||||
```
|
||||
|
||||
设置网格的索引数据。此方法会复制传入的数据到内部缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `data` - 索引数据指针,不能为 nullptr
|
||||
- `size` - 索引数据总字节数
|
||||
- `indexCount` - 索引数量
|
||||
- `use32Bit` - 是否使用 32 位索引,false 则使用 16 位索引
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(n) - n 为索引数据大小
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(...);
|
||||
|
||||
// 使用 16 位索引(最多 65536 个顶点)
|
||||
uint16_t indices16[6] = {0, 1, 2, 0, 2, 3};
|
||||
mesh.SetIndexData(indices16, sizeof(indices16), 6, false);
|
||||
|
||||
// 或使用 32 位索引
|
||||
uint32_t indices32[6] = {0, 1, 2, 0, 2, 3};
|
||||
mesh.SetIndexData(indices32, sizeof(indices32), 6, true);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
57
docs/api/resources/mesh/set-vertex-data.md
Normal file
57
docs/api/resources/mesh/set-vertex-data.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Mesh::SetVertexData
|
||||
|
||||
```cpp
|
||||
void SetVertexData(const void* data, size_t size, Core::uint32 vertexCount,
|
||||
Core::uint32 vertexStride, VertexAttribute attributes);
|
||||
```
|
||||
|
||||
设置网格的顶点数据。此方法会复制传入的数据到内部缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `data` - 顶点数据指针,不能为 nullptr
|
||||
- `size` - 顶点数据总字节数
|
||||
- `vertexCount` - 顶点数量
|
||||
- `vertexStride` - 单个顶点的字节大小
|
||||
- `attributes` - 顶点属性标志,指定数据包含哪些顶点通道
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(n) - n 为顶点数据大小
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Resources/Mesh.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
struct Vertex {
|
||||
float position[3];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
|
||||
Vertex vertices[4] = {
|
||||
{{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
|
||||
{{ 0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
{{ 0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}}
|
||||
};
|
||||
|
||||
Mesh mesh;
|
||||
mesh.SetVertexData(
|
||||
vertices,
|
||||
sizeof(vertices),
|
||||
4,
|
||||
sizeof(Vertex),
|
||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0
|
||||
);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [类总览](mesh.md) - 返回类总览
|
||||
@@ -1,30 +0,0 @@
|
||||
# Mesh::SetIndexData
|
||||
|
||||
```cpp
|
||||
void SetIndexData(const void* data, size_t size, Core::uint32 indexCount, bool use32Bit)
|
||||
```
|
||||
|
||||
设置网格索引数据。复制索引缓冲数据到内部存储。
|
||||
|
||||
**参数:**
|
||||
- `data` - 索引数据指针
|
||||
- `size` - 数据大小(字节)
|
||||
- `indexCount` - 索引数量
|
||||
- `use32Bit` - 是否使用 32 位索引(否则使用 16 位)
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n),n 为索引数据大小
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Containers::Array<uint32_t> indices;
|
||||
// ... 填充索引数据 ...
|
||||
mesh->SetIndexData(indices.Data(), indices.Size() * sizeof(uint32_t),
|
||||
indices.Size(), true);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Mesh 总览](mesh.md) - 返回类总览
|
||||
@@ -1,37 +0,0 @@
|
||||
# Mesh::SetVertexData
|
||||
|
||||
```cpp
|
||||
void SetVertexData(const void* data, size_t size, Core::uint32 vertexCount,
|
||||
Core::uint32 vertexStride, VertexAttribute attributes)
|
||||
```
|
||||
|
||||
设置网格顶点数据。复制顶点缓冲数据到内部存储。
|
||||
|
||||
**参数:**
|
||||
- `data` - 顶点数据指针
|
||||
- `size` - 数据大小(字节)
|
||||
- `vertexCount` - 顶点数量
|
||||
- `vertexStride` - 单个顶点结构体大小(字节)
|
||||
- `attributes` - 顶点属性标志组合
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n),n 为顶点数据大小
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
struct Vertex {
|
||||
float position[3];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
|
||||
mesh->SetVertexData(vertices.Data(), vertices.Size() * sizeof(Vertex),
|
||||
vertexCount, sizeof(Vertex),
|
||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Mesh 总览](mesh.md) - 返回类总览
|
||||
37
docs/api/resources/mesh/vertexattribute.md
Normal file
37
docs/api/resources/mesh/vertexattribute.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# VertexAttribute
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `enum class`
|
||||
|
||||
**描述**: 顶点属性标志枚举,用于指定网格顶点包含哪些属性。
|
||||
|
||||
## 概述
|
||||
|
||||
VertexAttribute 是位标志枚举,用于描述顶点缓冲中包含的顶点属性类型。每种属性对应一个比特位,可以组合使用。
|
||||
|
||||
## 枚举值
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Position` | 顶点位置 (x, y, z) |
|
||||
| `Normal` | 法线向量 (x, y, z) |
|
||||
| `Tangent` | 切线向量 (x, y, z) |
|
||||
| `Color` | 顶点颜色 (r, g, b, a) |
|
||||
| `UV0` | 第一组 UV 坐标 |
|
||||
| `UV1` | 第二组 UV 坐标 |
|
||||
| `UV2` | 第三组 UV 坐标 |
|
||||
| `UV3` | 第四组 UV 坐标 |
|
||||
| `BoneWeights` | 骨骼权重 |
|
||||
| `BoneIndices` | 骨骼索引 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
VertexAttribute attributes = VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Mesh 类总览](mesh.md) - 返回类总览
|
||||
- [SetVertexData](./setvertexdata.md) - 设置顶点数据
|
||||
Reference in New Issue
Block a user