2 #include <msp/geometry/affinetransform.h>
6 Transform::Transform(Handle<Entity> e):
7 BufferedComponent<TransformData>(e)
10 void Transform::set_values(const TransformValues &v)
15 void Transform::set_position(const LinAl::Vector<float, 3> &p)
17 write().values.position = p;
20 void Transform::set_rotation(const Geometry::Quaternion<float> &r)
22 write().values.rotation = normalize(r);
25 void Transform::set_scale(const LinAl::Vector<float, 3> &s)
27 write().values.scale = s;
30 void Transform::update_world_matrix(const Transform *parent)
32 using Affine = Geometry::AffineTransform<float, 3>;
35 d.local_matrix = Affine::translation(d.values.position)*
36 Affine::rotation(d.values.rotation)*Affine::scaling(d.values.scale);
38 d.world_matrix = parent->get_world_matrix()*d.local_matrix;
40 d.world_matrix = d.local_matrix;
43 } // namespace Msp::Game