- audio: 更新 audio-mixer, equalizer, fft-filter, hrtf, reverbation 方法文档 - resources: 更新资源管理文档 - debug: 新增 renderdoc-capture 文档
98 lines
3.3 KiB
Markdown
98 lines
3.3 KiB
Markdown
# Resources 模块概览
|
|
|
|
**命名空间**: `XCEngine::Resources`
|
|
|
|
**类型**: `module`
|
|
|
|
**头文件**: `XCEngine/Resources/Resources.h`
|
|
|
|
**描述**: XCEngine 的资源管理系统,提供资源的异步加载、缓存和依赖管理。
|
|
|
|
## 概述
|
|
|
|
Resources 模块提供了一套完整的资源管理解决方案,支持同步和异步加载、资源缓存、依赖图管理等功能。
|
|
|
|
## 模块内容
|
|
|
|
### 核心组件
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|------|------|------|
|
|
| [IResource](iresource/iresource.md) | `IResource.h` | 资源基类 |
|
|
| [ResourceHandle](resourcehandle.md) | `ResourceHandle.h` | 资源句柄模板 |
|
|
| [IResourceLoader](iloader/iloader.md) | `IResourceLoader.h` | 资源加载器接口 |
|
|
| [ResourceManager](resource-manager/resource-manager.md) | `ResourceManager.h` | 资源管理器 |
|
|
| [ResourceCache](resourcecache.md) | `ResourceCache.h` | 资源缓存 |
|
|
| [AsyncLoader](asyncloader/asyncloader.md) | `AsyncLoader.h` | 异步加载器 |
|
|
| [ResourceDependencyGraph](resource-dependency-graph/index.md) | `ResourceDependencyGraph.h` | 依赖图 |
|
|
| [ResourceTypes](resourcetypes/resourcetypes.md) | `ResourceTypes.h` | 资源类型定义 |
|
|
| [ResourcePath](resourcepath/resourcepath.md) | `ResourcePath.h` | 资源路径封装 |
|
|
| [ResourceFileSystem](resource-file-system/index.md) | `ResourceFileSystem.h` | 虚拟文件系统 |
|
|
| [ImportSettings](importsettings/importsettings.md) | `ImportSettings.h` | 导入设置基类 |
|
|
|
|
### 文件与打包
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|------|------|------|
|
|
| [FileArchive](filearchive/filearchive.md) | `FileArchive.h` | 文件归档读取 |
|
|
| [ResourcePackage](resourcepackage/resourcepackage.md) | `ResourcePackage.h` | 资源包打包/读取 |
|
|
|
|
### 具体资源类型
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|------|------|------|
|
|
| [Texture](texture/texture.md) | `Texture.h` | 纹理资源 |
|
|
| [Mesh](mesh/mesh.md) | `Mesh.h` | 网格资源 |
|
|
| [Material](material/material.md) | `Material.h` | 材质资源 |
|
|
| [Shader](shader/shader.md) | `Shader.h` | 着色器资源 |
|
|
| [AudioClip](audioclip/audioclip.md) | `AudioClip.h` | 音频资源 |
|
|
|
|
## 资源类型
|
|
|
|
| 类型 | 描述 |
|
|
|------|------|
|
|
| `Texture` | 纹理资源 |
|
|
| `Mesh` | 网格/模型资源 |
|
|
| `Material` | 材质资源 |
|
|
| `Shader` | 着色器资源 |
|
|
| `AudioClip` | 音频资源 |
|
|
| `Binary` | 二进制数据 |
|
|
| `AnimationClip` | 动画片段 |
|
|
| `Skeleton` | 骨骼 |
|
|
| `Font` | 字体 |
|
|
| `ParticleSystem` | 粒子系统 |
|
|
| `Scene` | 场景 |
|
|
| `Prefab` | 预制体 |
|
|
|
|
## 使用示例
|
|
|
|
```cpp
|
|
#include <XCEngine/Resources/ResourceManager.h>
|
|
|
|
// 初始化资源管理器
|
|
ResourceManager::Get().Initialize();
|
|
ResourceManager::Get().SetResourceRoot("resources/");
|
|
|
|
// 同步加载资源
|
|
ResourceHandle<Texture> tex = ResourceManager::Get().Load<Texture>("textures/player.png");
|
|
ResourceHandle<Mesh> mesh = ResourceManager::Get().Load<Mesh>("models/player.fbx");
|
|
ResourceHandle<Material> mat = ResourceManager::Get().Load<Material>("materials/player.mat");
|
|
|
|
// 异步加载
|
|
ResourceManager::Get().LoadAsync("textures/terrain.png", ResourceType::Texture,
|
|
[](LoadResult result) {
|
|
if (result.success) {
|
|
ResourceHandle<Texture> tex(result.resource);
|
|
// 加载完成回调
|
|
}
|
|
});
|
|
|
|
// 释放资源
|
|
tex.Reset();
|
|
mesh.Reset();
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [RHI 模块](../rhi/rhi.md) - GPU 资源创建
|