//
// Created by sebastian on 29.07.26.
//

#ifndef COLORRACE_TRANSFORMCOMPONENT_H
#define COLORRACE_TRANSFORMCOMPONENT_H
#include "glm/glm.hpp"
#include <glm/gtc/matrix_transform.hpp>

namespace engine {
    struct TransformComponent {
        glm::vec3 m_position;
        glm::vec3 m_rotation;
        glm::vec3 m_scale;

        [[nodiscard]] glm::mat4 computeModelMatrix() const {
            auto modelMatrix = glm::mat4(1.0f);
            modelMatrix = glm::translate(modelMatrix, m_position);
            modelMatrix = glm::rotate(modelMatrix, glm::radians(m_rotation.x), {1.0f, 0.0f, 0.0f});
            modelMatrix = glm::rotate(modelMatrix, glm::radians(m_rotation.y), {0.0f, 1.0f, 0.0f});
            modelMatrix = glm::rotate(modelMatrix, glm::radians(m_rotation.z), {0.0f, 0.0f, 1.0f});
            modelMatrix = glm::scale(modelMatrix, m_scale);
            return modelMatrix;
        }
    };

}
#endif //COLORRACE_TRANSFORMCOMPONENT_H
