]> git.tdb.fi Git - libs/gl.git/blob - source/keyframe.h
Add getters for RenderTarget width and height
[libs/gl.git] / source / keyframe.h
1 #ifndef MSP_GL_KEYFRAME_H_
2 #define MSP_GL_KEYFRAME_H_
3
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
6 #include "matrix.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Pose;
12
13 /**
14 Keyframes are used to encapsulate object state for animation.
15 */
16 class KeyFrame
17 {
18 public:
19         class Loader: public DataFile::CollectionObjectLoader<KeyFrame>
20         {
21         public:
22                 Loader(KeyFrame &);
23                 Loader(KeyFrame &, Collection &);
24         private:
25                 void init();
26
27                 void pose(const std::string &);
28                 void pose_inline();
29                 void position(float, float, float);
30                 void rotation(float, float, float, float);
31                 void scaling_uniform(float);
32                 void scaling(float, float, float);
33                 void uniforms();
34         };
35
36         class UniformsLoader: public DataFile::ObjectLoader<KeyFrame>
37         {
38         public:
39                 UniformsLoader(KeyFrame &);
40
41         private:
42                 void uniform1f(const std::string &, float);
43                 void uniform2f(const std::string &, float, float);
44                 void uniform3f(const std::string &, float, float, float);
45                 void uniform4f(const std::string &, float, float, float, float);
46         };
47
48         struct AnimatedUniform
49         {
50                 unsigned size;
51                 float values[4];
52
53                 AnimatedUniform(unsigned, float, float = 0.0f, float = 0.0f, float = 0.0f);
54         };
55
56         typedef std::map<std::string, AnimatedUniform> UniformMap;
57
58 private:
59         Matrix matrix;
60         UniformMap uniforms;
61         RefPtr<const Pose> pose;
62
63 public:
64         KeyFrame();
65         ~KeyFrame();
66
67         void set_matrix(const Matrix &);
68         void set_pose(const Pose &);
69         const Matrix &get_matrix() const { return matrix; }
70         const UniformMap &get_uniforms() const { return uniforms; }
71         const Pose *get_pose() const { return pose.get(); }
72 };
73
74 } // namespace GL
75 } // namespace Msp
76
77 #endif