]> git.tdb.fi Git - libs/gl.git/blob - source/keyframe.cpp
Force some c'tors and d'tors to be emitted in the library
[libs/gl.git] / source / keyframe.cpp
1 #include <msp/datafile/collection.h>
2 #include "keyframe.h"
3 #include "pose.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace GL {
9
10 // Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h
11 KeyFrame::KeyFrame()
12 { }
13
14 KeyFrame::~KeyFrame()
15 { }
16
17 void KeyFrame::set_matrix(const Matrix &m)
18 {
19         matrix = m;
20 }
21
22 void KeyFrame::set_pose(const Pose &p)
23 {
24         pose = &p;
25         pose.keep();
26 }
27
28
29 KeyFrame::Loader::Loader(KeyFrame &k):
30         DataFile::CollectionObjectLoader<KeyFrame>(k, 0)
31 {
32         init();
33 }
34
35 KeyFrame::Loader::Loader(KeyFrame &k, Collection &c):
36         DataFile::CollectionObjectLoader<KeyFrame>(k, &c)
37 {
38         init();
39 }
40
41 void KeyFrame::Loader::init()
42 {
43         add("pose", &Loader::pose);
44         add("pose", &Loader::pose_inline);
45         add("position", &Loader::position);
46         add("rotation", &Loader::rotation);
47         add("scaling", &Loader::scaling_uniform);
48         add("scaling", &Loader::scaling);
49 }
50
51 void KeyFrame::Loader::pose(const string &n)
52 {
53         obj.pose = &get_collection().get<Pose>(n);
54         obj.pose.keep();
55 }
56
57 void KeyFrame::Loader::pose_inline()
58 {
59         RefPtr<Pose> p = new Pose;
60         load_sub(*p, get_collection());
61         obj.pose = p;
62 }
63
64 void KeyFrame::Loader::position(float x, float y, float z)
65 {
66         obj.matrix.translate(x, y, z);
67 }
68
69 void KeyFrame::Loader::rotation(float a, float x, float y, float z)
70 {
71         obj.matrix.rotate_deg(a, x, y, z);
72 }
73
74 void KeyFrame::Loader::scaling_uniform(float s)
75 {
76         obj.matrix.scale(s);
77 }
78
79 void KeyFrame::Loader::scaling(float x, float y, float z)
80 {
81         obj.matrix.scale(x, y, z);
82 }
83
84 } // namespace GL
85 } // namespace Msp