1 #ifndef MSP_GAME_TRANSFORM_H_
2 #define MSP_GAME_TRANSFORM_H_
4 #include <msp/geometry/quaternion.h>
5 #include <msp/linal/matrix.h>
6 #include <msp/linal/vector.h>
11 struct TransformValues
13 LinAl::Vector<float, 3> position;
14 Geometry::Quaternion<float> rotation = Geometry::Quaternion<float>::one();
15 LinAl::Vector<float, 3> scale = { 1.0f, 1.0f, 1.0f };
17 TransformValues() = default;
18 TransformValues(const LinAl::Vector<float, 3> &p): position(p) { }
19 TransformValues(const LinAl::Vector<float, 3> &p, const Geometry::Quaternion<float> &r,
20 const LinAl::Vector<float, 3> &s = LinAl::Vector<float, 3>(1.0f, 1.0f, 1.0f)):
21 position(p), rotation(r), scale(s)
25 class Transform: public Component
28 TransformValues values;
29 LinAl::Matrix<float, 4, 4> local_matrix;
30 LinAl::Matrix<float, 4, 4> world_matrix;
33 Transform(Handle<Entity>);
35 void set_values(const TransformValues &);
36 void set_position(const LinAl::Vector<float, 3> &);
37 void set_rotation(const Geometry::Quaternion<float> &);
38 void set_scale(const LinAl::Vector<float, 3> &);
39 const TransformValues &get_values() const { return values; }
40 const LinAl::Vector<float, 3> &get_position() const { return values.position; }
41 const Geometry::Quaternion<float> &get_rotation() const { return values.rotation; }
42 const LinAl::Vector<float, 3> &get_scale() const { return values.scale; }
43 const LinAl::Matrix<float, 4, 4> &get_world_matrix() const { return world_matrix; }
45 void update_world_matrix(const Transform *);
48 } // namespace Msp::Game