- audio: 更新 audio-system 方法文档 - components: 新增 audio-listener/audio-source 组件方法文档,新增 remove-component 方法 - core: 更新 filewriter, types 文档 - math: 更新 box 方法文档 - memory: 更新 proxy-allocator 文档 - resources: 更新 loader 和 texture 文档 - rhi: 更新 opengl 设备、shader、swap-chain 文档 - threading: 更新 mutex 和 task-system 文档
120 lines
4.4 KiB
Markdown
120 lines
4.4 KiB
Markdown
# TextureImportSettings
|
||
|
||
**命名空间**: `XCEngine::Resources`
|
||
|
||
**类型**: `class`
|
||
|
||
**继承**: `ImportSettings`
|
||
|
||
**头文件**: `XCEngine/Resources/TextureImportSettings.h`
|
||
|
||
**描述**: 纹理资源导入设置类,定义从外部图像文件导入纹理时的配置选项。
|
||
|
||
---
|
||
|
||
## 概述
|
||
|
||
`TextureImportSettings` 继承自 `ImportSettings`,提供纹理导入时的完整配置能力。支持纹理类型、目标格式、Mipmap 生成、各项异性过滤、sRGB 转换、图像翻转、边框颜色、压缩质量、硬件压缩、纹理最大尺寸、法线贴图生成等选项。`LoadFromJSON()` 和 `SaveToJSON()` 当前为 stub 实现。
|
||
|
||
---
|
||
|
||
## 公共方法
|
||
|
||
| 方法 | 描述 |
|
||
|------|------|
|
||
| `TextureImportSettings()` | 构造函数 |
|
||
| `virtual ~TextureImportSettings() override` | 析构函数 |
|
||
| [Clone](clone.md) | 克隆设置对象 |
|
||
| [LoadFromJSON](loadfromjson.md) | 从 JSON 加载设置(stub) |
|
||
| [SaveToJSON](savetojson.md) | 保存为 JSON(stub) |
|
||
| [SetTextureType](settexturetype.md) | 设置纹理类型 |
|
||
| [GetTextureType](gettexturetype.md) | 获取纹理类型 |
|
||
| [SetTargetFormat](settargetformat.md) | 设置目标格式 |
|
||
| [GetTargetFormat](gettargetformat.md) | 获取目标格式 |
|
||
| [SetGenerateMipmaps](setgeneratemipmaps.md) | 设置是否生成 Mipmap |
|
||
| [GetGenerateMipmaps](getgeneratemipmaps.md) | 获取是否生成 Mipmap |
|
||
| [SetMipmapFilter](setmipmapfilter.md) | 设置 Mipmap 滤波器 |
|
||
| [GetMipmapFilter](getmipmapfilter.md) | 获取 Mipmap 滤波器 |
|
||
| [SetMaxAnisotropy](setmaxanisotropy.md) | 设置最大各向异性级别 |
|
||
| [GetMaxAnisotropy](getmaxanisotropy.md) | 获取最大各向异性级别 |
|
||
| [SetSRGB](setsrgb.md) | 设置是否 sRGB |
|
||
| [GetSRGB](getsrgb.md) | 获取 sRGB 设置 |
|
||
| [SetFlipVertical](setflipvertical.md) | 设置是否垂直翻转 |
|
||
| [GetFlipVertical](getflipvertical.md) | 获取垂直翻转设置 |
|
||
| [SetFlipHorizontal](setfliphhorizontal.md) | 设置是否水平翻转 |
|
||
| [GetFlipHorizontal](getfliphhorizontal.md) | 获取水平翻转设置 |
|
||
| [SetBorderColor](setbordercolor.md) | 设置边框颜色 |
|
||
| [GetBorderColor](getbordercolor.md) | 获取边框颜色 |
|
||
| [SetCompressionQuality](setcompressionquality.md) | 设置压缩质量 |
|
||
| [GetCompressionQuality](getcompressionquality.md) | 获取压缩质量 |
|
||
| [SetUseHardwareCompression](setusehardwarecompression.md) | 设置是否使用硬件压缩 |
|
||
| [GetUseHardwareCompression](getusehardwarecompression.md) | 获取硬件压缩设置 |
|
||
| [SetMaxSize](setmaxsize.md) | 设置最大纹理尺寸 |
|
||
| [GetMaxSize](getmaxsize.md) | 获取最大纹理尺寸 |
|
||
| [SetGenerateNormalMap](setgeneratenormalmap.md) | 设置是否生成法线贴图 |
|
||
| [GetGenerateNormalMap](getgeneratenormalmap.md) | 获取法线贴图生成设置 |
|
||
| [SetNormalMapStrength](setnormalmapstrength.md) | 设置法线贴图强度 |
|
||
| [GetNormalMapStrength](getnormalmapstrength.md) | 获取法线贴图强度 |
|
||
|
||
---
|
||
|
||
## MipmapFilter 枚举
|
||
|
||
| 值 | 描述 |
|
||
|------|------|
|
||
| `Box` | Box 滤波器 |
|
||
| `Kaiser` | Kaiser 滤波器 |
|
||
|
||
---
|
||
|
||
## CompressionQuality 枚举
|
||
|
||
| 值 | 描述 |
|
||
|------|------|
|
||
| `Low` | 低质量 |
|
||
| `Medium` | 中等质量 |
|
||
| `High` | 高质量 |
|
||
| `Ultra` | 超高质量 |
|
||
|
||
---
|
||
|
||
## 使用示例
|
||
|
||
```cpp
|
||
#include <XCEngine/Resources/TextureImportSettings.h>
|
||
#include <XCEngine/Resources/ResourceManager.h>
|
||
|
||
// 创建导入设置
|
||
TextureImportSettings settings;
|
||
settings.SetTextureType(TextureType::Texture2D);
|
||
settings.SetTargetFormat(TextureFormat::RGBA8);
|
||
settings.SetGenerateMipmaps(true);
|
||
settings.SetMipmapFilter(MipmapFilter::Kaiser);
|
||
settings.SetMaxAnisotropy(16);
|
||
settings.SetSRGB(true);
|
||
settings.SetFlipVertical(false);
|
||
settings.SetFlipHorizontal(false);
|
||
settings.SetBorderColor(Math::Vector3::Zero());
|
||
settings.SetCompressionQuality(CompressionQuality::High);
|
||
settings.SetUseHardwareCompression(true);
|
||
settings.SetMaxSize(2048);
|
||
settings.SetGenerateNormalMap(false);
|
||
settings.SetNormalMapStrength(1.0f);
|
||
|
||
// 克隆设置
|
||
auto cloned = settings.Clone();
|
||
|
||
// 加载纹理资源
|
||
ResourceHandle<Texture> tex = ResourceManager::Get().Load<Texture>("textures/diffuse.png", &settings);
|
||
```
|
||
|
||
---
|
||
|
||
## 相关文档
|
||
|
||
- [ImportSettings](../importsettings/importsettings.md) - 导入设置基类
|
||
- [IResourceLoader](../iloader/iloader.md) - 资源加载器接口
|
||
- [ResourceManager](../resource-manager/resource-manager.md) - 资源管理器
|
||
- [Texture](../texture/texture.md) - 纹理资源类
|
||
- [Resources 总览](../resources.md) - 资源模块总览
|