]> git.tdb.fi Git - libs/gl.git/blob - source/animatedobject.h
Remove dynamic allocation from VertexFormat
[libs/gl.git] / source / animatedobject.h
1 #ifndef MSP_GL_ANIMATEDOBJECT_H_
2 #define MSP_GL_ANIMATEDOBJECT_H_
3
4 #include <vector>
5 #include <msp/datafile/objectloader.h>
6 #include "keyframe.h"
7 #include "matrix.h"
8 #include "objectinstance.h"
9
10 namespace Msp {
11 namespace GL {
12
13 /**
14 An object instance that can be animated.  Despite the name, this can also be
15 useful for displaying objects at a static position.
16 */
17 class AnimatedObject: public ObjectInstance
18 {
19 public:
20         class Loader: public DataFile::ObjectLoader<AnimatedObject>
21         {
22         public:
23                 Loader(AnimatedObject &);
24
25         private:
26                 void position(float, float, float);
27                 void rotation(float, float, float, float);
28                 void scale(float, float, float);
29                 void scale_uniform(float);
30         };
31
32 private:
33         Matrix matrix;
34         std::vector<float> pose_data;
35         ProgramData *shdata;
36
37 public:
38         AnimatedObject(const Object &);
39         ~AnimatedObject();
40
41         void set_matrix(const Matrix &);
42         void set_pose_matrix(unsigned, const Matrix &);
43         void set_uniform(const std::string &, const KeyFrame::AnimatedUniform &);
44
45         virtual const Matrix *get_matrix() const { return &matrix; }
46
47         virtual void setup_render(Renderer &, const Tag &) const;
48 };
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif