]> git.tdb.fi Git - libs/gl.git/blob - source/transform.h
Check for armature mismatches in Animation
[libs/gl.git] / source / transform.h
1 #ifndef MSP_GL_TRANSFORM_H_
2 #define MSP_GL_TRANSFORM_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include "matrix.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
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.
14 */
15 class Transform
16 {
17 public:
18         class Loader: public DataFile::ObjectLoader<Transform>
19         {
20         public:
21                 Loader(Transform &);
22
23         private:
24                 void position(float, float, float);
25                 void euler(float, float, float);
26                 void rotation(float, float, float, float);
27                 void scale_uniform(float);
28                 void scale(float, float, float);
29         };
30
31         typedef Geometry::Angle<float> Angle;
32         typedef LinAl::Vector<Angle, 3> AngleVector3;
33
34 private:
35         Vector3 position;
36         AngleVector3 euler;
37         Vector3 scale;
38
39 public:
40         Transform();
41
42         static Transform from_matrix(const Matrix &);
43
44         void set_position(const Vector3 &);
45         void set_euler(const AngleVector3 &);
46         void set_rotation(const Angle &, const Vector3 &);
47         void set_scale(float);
48         void set_scale(const Vector3 &);
49         const Vector3 &get_position() const { return position; }
50         const AngleVector3 &get_euler() const { return euler; }
51         const Vector3 &get_scale() const { return scale; }
52
53         Matrix to_matrix() const;
54 };
55
56 } // namespace GL
57 } // namespace Msp
58
59 #endif