- Rename constructor/destructor files to follow template spec: - ctor.md → constructor.md, dtor.md → destructor.md (audioclip) - texture_constructor.md → constructor.md, texture_destructor.md → destructor.md (texture) - material-loader-constructor.md → constructor.md, material-loader-destructor.md → destructor.md - Create missing constructor/destructor docs: - audio-loader: constructor.md, destructor.md - texture-loader: constructor.md, destructor.md - Fix broken links to ResourceManager: - shader-loader/index.md - material-loader/index.md - Remove duplicate folders (keep hyphenated versions): - Delete shaderloader/ (keep shader-loader/) - Delete resourcepackage/ (keep resource-package/) - Merge textureimportsettings/ into texture-import-settings/ - Rename audio-loader method files: - canload.md → can-load.md - getdefaultsettings.md → get-default-settings.md - getsupportedextensions.md → get-supported-extensions.md - Update overview pages with proper method links and constructor/destructor entries
4.4 KiB
4.4 KiB
TextureImportSettings
命名空间: XCEngine::Resources
类型: class
继承: ImportSettings
头文件: XCEngine/Resources/TextureImportSettings.h
描述: 纹理资源导入设置类,定义从外部图像文件导入纹理时的配置选项。
概述
TextureImportSettings 继承自 ImportSettings,提供纹理导入时的完整配置能力。支持纹理类型、目标格式、Mipmap 生成、各项异性过滤、sRGB 转换、图像翻转、边框颜色、压缩质量、硬件压缩、纹理最大尺寸、法线贴图生成等选项。LoadFromJSON() 和 SaveToJSON() 当前为 stub 实现。
公共方法
| 方法 | 描述 |
|---|---|
TextureImportSettings() |
构造函数 |
virtual ~TextureImportSettings() override |
析构函数 |
| Clone | 克隆设置对象 |
| LoadFromJSON | 从 JSON 加载设置(stub) |
| SaveToJSON | 保存为 JSON(stub) |
| SetTextureType | 设置纹理类型 |
| GetTextureType | 获取纹理类型 |
| SetTargetFormat | 设置目标格式 |
| GetTargetFormat | 获取目标格式 |
| SetGenerateMipmaps | 设置是否生成 Mipmap |
| GetGenerateMipmaps | 获取是否生成 Mipmap |
| SetMipmapFilter | 设置 Mipmap 滤波器 |
| GetMipmapFilter | 获取 Mipmap 滤波器 |
| SetMaxAnisotropy | 设置最大各向异性级别 |
| GetMaxAnisotropy | 获取最大各向异性级别 |
| SetSRGB | 设置是否 sRGB |
| GetSRGB | 获取 sRGB 设置 |
| SetFlipVertical | 设置是否垂直翻转 |
| GetFlipVertical | 获取垂直翻转设置 |
| SetFlipHorizontal | 设置是否水平翻转 |
| GetFlipHorizontal | 获取水平翻转设置 |
| SetBorderColor | 设置边框颜色 |
| GetBorderColor | 获取边框颜色 |
| SetCompressionQuality | 设置压缩质量 |
| GetCompressionQuality | 获取压缩质量 |
| SetUseHardwareCompression | 设置是否使用硬件压缩 |
| GetUseHardwareCompression | 获取硬件压缩设置 |
| SetMaxSize | 设置最大纹理尺寸 |
| GetMaxSize | 获取最大纹理尺寸 |
| SetGenerateNormalMap | 设置是否生成法线贴图 |
| GetGenerateNormalMap | 获取法线贴图生成设置 |
| SetNormalMapStrength | 设置法线贴图强度 |
| GetNormalMapStrength | 获取法线贴图强度 |
MipmapFilter 枚举
| 值 | 描述 |
|---|---|
Box |
Box 滤波器 |
Kaiser |
Kaiser 滤波器 |
CompressionQuality 枚举
| 值 | 描述 |
|---|---|
Low |
低质量 |
Medium |
中等质量 |
High |
高质量 |
Ultra |
超高质量 |
使用示例
#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 - 导入设置基类
- IResourceLoader - 资源加载器接口
- ResourceManager - 资源管理器
- Texture - 纹理资源类
- Resources 总览 - 资源模块总览