Files
XCEngine/docs/api/resources/mesh-import-settings/mesh-import-settings.md

102 lines
3.7 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.
# MeshImportSettings
**命名空间**: `XCEngine::Resources`
**类型**: `class`
**继承**: `ImportSettings`
**头文件**: `XCEngine/Resources/MeshImportSettings.h`
**描述**: 网格资源导入设置类,定义从外部模型文件导入网格时的配置选项。
---
## 概述
`MeshImportSettings` 继承自 `ImportSettings`,提供网格导入时的完整配置能力。支持导入标志位操作、缩放、偏移、轴转换、网格合并等选项。`LoadFromJSON()``SaveToJSON()` 当前为 stub 实现。
---
## 公共方法
| 方法 | 描述 |
|------|------|
| `MeshImportSettings()` | 构造函数 |
| `virtual ~MeshImportSettings() override` | 析构函数 |
| `Core::UniqueRef<ImportSettings> Clone() const override` | 克隆设置对象 |
| `bool LoadFromJSON(const Containers::String& json) override` | 从 JSON 加载设置stub |
| `Containers::String SaveToJSON() const override` | 保存为 JSONstub |
| `void SetImportFlags(MeshImportFlags flags)` | 设置导入标志 |
| `MeshImportFlags GetImportFlags() const` | 获取导入标志 |
| `void AddImportFlag(MeshImportFlags flag)` | 添加导入标志 |
| `void RemoveImportFlag(MeshImportFlags flag)` | 移除导入标志 |
| `bool HasImportFlag(MeshImportFlags flag) const` | 检查是否包含标志 |
| `void SetScale(float scale)` | 设置缩放 |
| `float GetScale() const` | 获取缩放 |
| `void SetOffset(const Math::Vector3& offset)` | 设置偏移 |
| `const Math::Vector3& GetOffset() const` | 获取偏移 |
| `void SetAxisConversion(bool convert)` | 设置轴转换 |
| `bool GetAxisConversion() const` | 获取轴转换设置 |
| `void SetMergeMeshes(bool merge)` | 设置是否合并网格 |
| `bool GetMergeMeshes() const` | 获取合并网格设置 |
| `void SetOptimizeThreshold(float threshold)` | 设置优化阈值 |
| `float GetOptimizeThreshold() const` | 获取优化阈值 |
| `void SetImportScale(float scale)` | 设置导入缩放 |
| `float GetImportScale() const` | 获取导入缩放 |
| `void SetThreshold(float threshold)` | 设置阈值 |
| `float GetThreshold() const` | 获取阈值 |
---
## MeshImportFlags 枚举
| 标志 | 值 | 描述 |
|------|------|------|
| `None` | `0` | 无特殊标志 |
| `FlipUVs` | `1 << 0` | 翻转 UV 坐标 |
| `FlipWindingOrder` | `1 << 1` | 翻转顶点绕序 |
| `GenerateNormals` | `1 << 2` | 生成法线 |
| `GenerateTangents` | `1 << 3` | 生成切线 |
| `OptimizeMesh` | `1 << 4` | 优化网格 |
| `ImportSkinning` | `1 << 5` | 导入骨骼蒙皮数据 |
| `ImportAnimations` | `1 << 6` | 导入动画数据 |
| `ImportMaterials` | `1 << 7` | 导入材质 |
| `ImportCameras` | `1 << 8` | 导入相机 |
| `ImportLights` | `1 << 9` | 导入灯光 |
支持位运算组合:`operator|``operator&``operator~`
---
## 使用示例
```cpp
#include <XCEngine/Resources/MeshImportSettings.h>
#include <XCEngine/Resources/ResourceManager.h>
// 创建导入设置
MeshImportSettings settings;
settings.SetImportFlags(MeshImportFlags::FlipUVs | MeshImportFlags::GenerateNormals | MeshImportFlags::OptimizeMesh);
settings.SetScale(1.0f);
settings.SetOffset(Math::Vector3::Zero());
settings.SetAxisConversion(true);
settings.SetMergeMeshes(false);
settings.SetOptimizeThreshold(0.3f);
// 克隆设置
auto cloned = settings.Clone();
// 加载网格资源
ResourceHandle<Mesh> mesh = ResourceManager::Get().Load<Mesh>("models/player.fbx", &settings);
```
---
## 相关文档
- [ImportSettings](../importsettings/importsettings.md) - 导入设置基类
- [IResourceLoader](../iloader/iloader.md) - 资源加载器接口
- [ResourceManager](../resourcemanager/resourcemanager.md) - 资源管理器
- [Resources 总览](../resources.md) - 资源模块总览