2025-07-05 13:28:41 +03:30
|
|
|
#pragma once
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
#include <math/mat4.hpp>
|
|
|
|
#include <math/vec3.hpp>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-11 00:05:48 +03:30
|
|
|
namespace lt {
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
struct TransformComponent
|
|
|
|
{
|
|
|
|
TransformComponent(const TransformComponent &) = default;
|
|
|
|
|
|
|
|
TransformComponent(
|
2025-07-17 10:44:00 +03:30
|
|
|
const math::vec3 &_translation = math::vec3(0.0f, 0.0f, 0.0f),
|
|
|
|
const math::vec3 &_scale = math::vec3(1.0f, 1.0f, 1.0f),
|
|
|
|
const math::vec3 &_rotation = math::vec3(0.0f, 0.0f, 0.0f)
|
2025-07-05 13:28:41 +03:30
|
|
|
)
|
|
|
|
|
|
|
|
: translation(_translation)
|
|
|
|
, scale(_scale)
|
|
|
|
, rotation(_rotation)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
[[nodiscard]] auto get_transform() const -> math::mat4
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-17 10:44:00 +03:30
|
|
|
return math::translate(translation)
|
|
|
|
* math::rotate(rotation.z, math::vec3 { 0.0f, 0.0f, 1.0f }) //
|
|
|
|
* math::scale(scale);
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
operator const math::mat4() const
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 15:36:53 +03:30
|
|
|
return get_transform();
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
math::vec3 translation;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
math::vec3 scale;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
math::vec3 rotation;
|
2025-07-05 13:28:41 +03:30
|
|
|
};
|
|
|
|
|
2025-07-11 00:05:48 +03:30
|
|
|
} // namespace lt
|