diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-04-09 12:59:54 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2021-04-12 12:12:40 +0000 |
| commit | 08dd1a975a33aec9dc6f18568b0d014551983b66 (patch) | |
| tree | d80edfa837137e10e3a7ac626cccfc81c650e924 /AssetLoader/include/GLTFLoader.hpp | |
| parent | implement loading GLTF files from memory (diff) | |
| download | DiligentTools-gltf-c-api.tar.gz DiligentTools-gltf-c-api.zip | |
Give access to individual node transformsgltf-c-api
Diffstat (limited to 'AssetLoader/include/GLTFLoader.hpp')
| -rw-r--r-- | AssetLoader/include/GLTFLoader.hpp | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/AssetLoader/include/GLTFLoader.hpp b/AssetLoader/include/GLTFLoader.hpp index 2b9afaf..9f3e10f 100644 --- a/AssetLoader/include/GLTFLoader.hpp +++ b/AssetLoader/include/GLTFLoader.hpp @@ -229,6 +229,16 @@ struct Camera float4x4 matrix; }; +struct GLTF_Transform +{ + float3 Translation; + float _pad0; + float3 Scale = float3{1, 1, 1}; + float _pad1; + Quaternion Rotation; + float4x4 Matrix; +}; + struct Node { std::string Name; @@ -237,14 +247,15 @@ struct Node std::vector<std::unique_ptr<Node>> Children; - float4x4 Matrix; std::unique_ptr<Mesh> pMesh; std::unique_ptr<Camera> pCamera; Skin* pSkin = nullptr; Int32 SkinIndex = -1; - float3 Translation; - float3 Scale = float3{1, 1, 1}; - Quaternion Rotation; + GLTF_Transform Transform; + // float3 Translation; + // float3 Scale = float3{1, 1, 1}; + // Quaternion Rotation; + // float4x4 Matrix; BoundBox BVH; BoundBox AABB; @@ -386,6 +397,41 @@ public: 0; } + virtual bool GetNodeIndex(const char* Name, Uint32* Idx) const override final + { + uint32_t i = 0; + for (auto* node : LinearNodes) + { + if (node->Name.compare(Name) == 0) + { + *Idx = i; + return true; + } + i++; + } + + return false; + } + + virtual void GetNodeTransform(Uint32 Idx, GLTF_Transform* Transform) override final + { + *Transform = LinearNodes[Idx]->Transform; + } + + virtual void SetNodeTransform(Uint32 Idx, GLTF_Transform* Transform) override final + { + LinearNodes[Idx]->Transform = *Transform; + } + + virtual void UpdateTransforms() override final + { + for (auto& root_node : Nodes) + { + root_node->UpdateTransforms(); + } + CalculateSceneDimensions(); + } + private: void LoadFromFile(IRenderDevice* pDevice, IDeviceContext* pContext, |
