From 3725eda0af93bd59408f7dcd5ac1349045438c38 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 10 Dec 2020 13:06:36 -0800 Subject: GLTFLoader: updated model initialization API; few minor improvements to loading --- AssetLoader/interface/GLTFLoader.hpp | 40 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'AssetLoader/interface') diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp index 2976210..604c838 100644 --- a/AssetLoader/interface/GLTFLoader.hpp +++ b/AssetLoader/interface/GLTFLoader.hpp @@ -54,7 +54,7 @@ namespace Diligent namespace GLTF { -struct GLTFCacheInfo +struct ResourceCacheUseInfo { ResourceManager* pResourceMgr = nullptr; @@ -335,11 +335,26 @@ struct Model std::unordered_map> Textures; }; - Model(IRenderDevice* pDevice, - IDeviceContext* pContext, - const std::string& filename, - TextureCacheType* pTextureCache = nullptr, - GLTFCacheInfo* pCache = nullptr); + /// Model create information + struct CreateInfo + { + /// File name + const char* FileName = nullptr; + + /// Optional texture cache to use when loading the model. + /// The loader will try to find all the textures in the cache + /// and add all new textures to the cache. + TextureCacheType* pTextureCache = nullptr; + + /// Optional resource cache usage info. + ResourceCacheUseInfo* pCacheInfo = nullptr; + + /// Optional transform to apply to the model + const float4x4* pTransform = nullptr; + }; + Model(IRenderDevice* pDevice, + IDeviceContext* pContext, + const CreateInfo& CI); ~Model(); @@ -378,11 +393,9 @@ struct Model } private: - void LoadFromFile(IRenderDevice* pDevice, - IDeviceContext* pContext, - const std::string& filename, - TextureCacheType* pTextureCache, - GLTFCacheInfo* pCache); + void LoadFromFile(IRenderDevice* pDevice, + IDeviceContext* pContext, + const CreateInfo& CI); void LoadNode(IRenderDevice* pDevice, Node* parent, @@ -395,7 +408,8 @@ private: void LoadTextures(IRenderDevice* pDevice, const tinygltf::Model& gltf_model, const std::string& BaseDir, - TextureCacheType* pTextureCache); + TextureCacheType* pTextureCache, + ResourceManager* pResourceMgr); void LoadTextureSamplers(IRenderDevice* pDevice, const tinygltf::Model& gltf_model); void LoadMaterials(const tinygltf::Model& gltf_model); @@ -405,8 +419,6 @@ private: Node* FindNode(Node* parent, Uint32 index); Node* NodeFromIndex(uint32_t index); - GLTFCacheInfo CacheInfo; - struct ResourceInitData; std::unique_ptr InitData; -- cgit v1.2.3