diff options
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, |
