~thestr4ng3r/lavos

1a8d3c777a3ff368df1e1f4486b537afe0483b99 — Florian Märkl 3 years ago 1264051 master
Contruct Transform like glTF
1 files changed, 5 insertions(+), 4 deletions(-)

M lavos/include/lavos/component/transform_component.h
M lavos/include/lavos/component/transform_component.h => lavos/include/lavos/component/transform_component.h +5 -4
@@ 22,7 22,9 @@ class TransformComp: public Component

		glm::mat4 GetMatrix()
		{
			return glm::scale(glm::translate(glm::mat4(1.0f), translation), scale) * glm::toMat4(rotation);
			return glm::translate(glm::mat4(1.0f), translation)
				* glm::toMat4(rotation)
				* glm::scale(glm::mat4(1.0f), scale);
		}

		glm::mat4 GetMatrixWorld()


@@ 30,11 32,10 @@ class TransformComp: public Component
			glm::mat4 m = GetMatrix();

			Node *parent = GetNode()->GetParent();
			if(parent == nullptr)
			if(!parent)
				return m;

			TransformComp *parent_transform = parent->GetTransformComp();
			if(parent_transform == nullptr)
			if(!parent_transform)
				return m;

			return parent_transform->GetMatrixWorld() * m;