1 #ifndef MSP_GL_TRANSFORM_H_
2 #define MSP_GL_TRANSFORM_H_
4 #include <msp/datafile/objectloader.h>
11 Stores a coordinate space transform as individual components. Primarily
12 intended for loading data from external sources. At runtime transforms
13 should generally be stored as matrices.
18 class Loader: public DataFile::ObjectLoader<Transform>
24 void position_x(float);
25 void position_y(float);
26 void position_z(float);
27 void position(float, float, float);
31 void euler(float, float, float);
32 void rotation(float, float, float, float);
36 void scale_uniform(float);
37 void scale(float, float, float);
46 POSITION = POSITION_X|POSITION_Y|POSITION_Z,
50 EULER = EULER_X|EULER_Y|EULER_Z,
54 SCALE = SCALE_X|SCALE_Y|SCALE_Z
57 typedef Geometry::Angle<float> Angle;
58 typedef LinAl::Vector<Angle, 3> AngleVector3;
63 Vector3 scale = { 1.0f, 1.0f, 1.0f };
64 ComponentMask mask = NONE;
67 static Transform from_matrix(const Matrix &);
69 void set_position(const Vector3 &);
70 void set_euler(const AngleVector3 &);
71 void set_rotation(const Angle &, const Vector3 &);
72 void set_scale(float);
73 void set_scale(const Vector3 &);
74 const Vector3 &get_position() const { return position; }
75 const AngleVector3 &get_euler() const { return euler; }
76 const Vector3 &get_scale() const { return scale; }
77 ComponentMask get_mask() const { return mask; }
79 Matrix to_matrix() const;
82 inline Transform::ComponentMask operator&(Transform::ComponentMask m1, Transform::ComponentMask m2)
83 { return static_cast<Transform::ComponentMask>(static_cast<int>(m1)&static_cast<int>(m2)); }
85 inline Transform::ComponentMask operator|(Transform::ComponentMask m1, Transform::ComponentMask m2)
86 { return static_cast<Transform::ComponentMask>(static_cast<int>(m1)|static_cast<int>(m2)); }
88 inline Transform::ComponentMask operator^(Transform::ComponentMask m1, Transform::ComponentMask m2)
89 { return static_cast<Transform::ComponentMask>(static_cast<int>(m1)^static_cast<int>(m2)); }
91 inline Transform::ComponentMask operator~(Transform::ComponentMask m)
92 { return static_cast<Transform::ComponentMask>(~static_cast<int>(m)); }