fix: improve doc link navigation and tree display

- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
This commit is contained in:
2026-03-19 12:44:08 +08:00
parent e003fe6513
commit 58a83f445a
1012 changed files with 56880 additions and 22 deletions

View File

@@ -0,0 +1,151 @@
# Material
**命名空间**: `XCEngine::Resources`
**类型**: `class`
**描述**: 材质资源类,管理渲染所需的着色器和属性参数。
## 概述
`Material` 是 XCEngine 中的材质资源类,继承自 `IResource`。它管理材质关联的着色器和各种属性参数(浮点数、向量、纹理等),并支持将属性数据打包到常量缓冲区。
## 头文件
```cpp
#include <XCEngine/Resources/Material.h>
```
## 枚举类型
### MaterialPropertyType
材质属性类型枚举。
| 值 | 描述 |
|----|------|
| `Float` | 单精度浮点数 |
| `Float2` | 二维浮点向量 |
| `Float3` | 三维浮点向量 |
| `Float4` | 四维浮点向量 |
| `Int` | 整数 |
| `Int2` | 二维整数向量 |
| `Int3` | 三维整数向量 |
| `Int4` | 四维整数向量 |
| `Bool` | 布尔值 |
| `Texture` | 纹理资源 |
| `Cubemap` | 立方体贴图资源 |
## 结构体
### MaterialProperty
材质属性结构体。
| 成员 | 类型 | 描述 |
|------|------|------|
| `name` | `Containers::String` | 属性名称 |
| `type` | `MaterialPropertyType` | 属性类型 |
| `value` | `union` | 属性值float/int/bool |
| `refCount` | `Core::uint32` | 引用计数 |
## 公共方法
### 基础属性
| 方法 | 描述 |
|------|------|
| `ResourceType GetType() const` | 返回 `ResourceType::Material` |
| `const Containers::String& GetName() const` | 获取材质名称 |
| `const Containers::String& GetPath() const` | 获取材质路径 |
| `ResourceGUID GetGUID() const` | 获取全局唯一标识符 |
| `bool IsValid() const` | 检查材质是否有效 |
| `size_t GetMemorySize() const` | 获取内存大小 |
| `void Release()` | 释放材质引用 |
### 着色器管理
| 方法 | 描述 |
|------|------|
| `void SetShader(const ResourceHandle<Shader>& shader)` | 设置材质着色器 |
| `Shader* GetShader() const` | 获取材质着色器 |
### 属性设置
| 方法 | 描述 |
|------|------|
| `void SetFloat(const Containers::String& name, float value)` | 设置浮点属性 |
| `void SetFloat2(const Containers::String& name, const Math::Vector2& value)` | 设置 Vector2 属性 |
| `void SetFloat3(const Containers::String& name, const Math::Vector3& value)` | 设置 Vector3 属性 |
| `void SetFloat4(const Containers::String& name, const Math::Vector4& value)` | 设置 Vector4 属性 |
| `void SetInt(const Containers::String& name, Core::int32 value)` | 设置整数属性 |
| `void SetBool(const Containers::String& name, bool value)` | 设置布尔属性 |
| `void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture)` | 设置纹理属性 |
### 属性获取
| 方法 | 描述 |
|------|------|
| `float GetFloat(const Containers::String& name) const` | 获取浮点属性 |
| `Math::Vector2 GetFloat2(const Containers::String& name) const` | 获取 Vector2 属性 |
| `Math::Vector3 GetFloat3(const Containers::String& name) const` | 获取 Vector3 属性 |
| `Math::Vector4 GetFloat4(const Containers::String& name) const` | 获取 Vector4 属性 |
| `Core::int32 GetInt(const Containers::String& name) const` | 获取整数属性 |
| `bool GetBool(const Containers::String& name) const` | 获取布尔属性 |
| `ResourceHandle<Texture> GetTexture(const Containers::String& name) const` | 获取纹理属性 |
### 常量缓冲区
| 方法 | 描述 |
|------|------|
| `const Containers::Array<Core::uint8>& GetConstantBufferData() const` | 获取常量缓冲区数据 |
| `void UpdateConstantBuffer()` | 更新常量缓冲区数据 |
### 属性管理
| 方法 | 描述 |
|------|------|
| `bool HasProperty(const Containers::String& name) const` | 检查属性是否存在 |
| `void RemoveProperty(const Containers::String& name)` | 移除属性 |
| `void ClearAllProperties()` | 清空所有属性 |
## 实现说明
**注意**: `MaterialLoader::ParseMaterialData()` 为 stub始终返回 true。`MaterialLoader::Load()` 仅为示例实现,未解析材质属性。
## 使用示例
```cpp
// 加载材质
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/player.mat");
// 设置着色器
mat->SetShader(shaderHandle);
// 设置各种属性
mat->SetFloat("roughness", 0.5f);
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->SetTexture("albedoMap", albedoTex);
mat->SetTexture("normalMap", normalTex);
mat->SetInt("normalScale", 1);
// 获取属性
float roughness = mat->GetFloat("roughness");
Math::Vector3 albedo = mat->GetFloat3("albedo");
// 检查属性
if (mat->HasProperty("metallic")) {
float metallic = mat->GetFloat("metallic");
}
// 更新常量缓冲区
mat->UpdateConstantBuffer();
auto cbData = mat->GetConstantBufferData();
```
## 相关文档
- [IResource](../iresource/iresource.md) - 资源基类
- [Shader](../shader/shader.md) - 着色器资源
- [Texture](../texture/texture.md) - 纹理资源
- [Resources 总览](../resources.md) - 返回模块总览

View File

@@ -0,0 +1,27 @@
# Material::SetFloat
```cpp
void SetFloat(const Containers::String& name, float value)
```
设置材质浮点属性。
**参数:**
- `name` - 属性名称
- `value` - 属性值
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat("metallic", 0.0f);
mat->SetFloat("emissionStrength", 2.0f);
```
## 相关文档
- [Material 总览](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::SetShader
```cpp
void SetShader(const ResourceHandle<Shader>& shader)
```
设置材质使用的着色器。
**参数:**
- `shader` - 着色器资源句柄
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Shader> vs = ResourceManager::Get().Load<Shader>("shaders/vertex.glsl");
ResourceHandle<Shader> fs = ResourceManager::Get().Load<Shader>("shaders/fragment.glsl");
mat->SetShader(vs);
```
## 相关文档
- [Material 总览](material.md) - 返回类总览

View File

@@ -0,0 +1,28 @@
# Material::SetTexture
```cpp
void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture)
```
设置材质纹理属性。
**参数:**
- `name` - 属性名称
- `texture` - 纹理资源句柄
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceHandle<Texture> albedoTex = ResourceManager::Get().Load<Texture>("textures/albedo.png");
ResourceHandle<Texture> normalTex = ResourceManager::Get().Load<Texture>("textures/normal.png");
mat->SetTexture("albedoMap", albedoTex);
mat->SetTexture("normalMap", normalTex);
```
## 相关文档
- [Material 总览](material.md) - 返回类总览

View File

@@ -0,0 +1,26 @@
# Material::UpdateConstantBuffer
```cpp
void UpdateConstantBuffer()
```
更新材质常量缓冲区。将所有属性值打包到常量缓冲区的二进制数据中,供 GPU 着色器使用。
**参数:**
**返回:**
**复杂度:** O(n)n 为属性数量
**示例:**
```cpp
mat->SetFloat("roughness", 0.5f);
mat->SetFloat3("albedo", Math::Vector3(1.0f, 0.8f, 0.6f));
mat->UpdateConstantBuffer();
auto cbData = mat->GetConstantBufferData();
```
## 相关文档
- [Material 总览](material.md) - 返回类总览