1 #include <msp/datafile/collection.h>
11 // Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h
18 void KeyFrame::set_matrix(const Matrix &m)
23 void KeyFrame::set_pose(const Pose &p)
30 KeyFrame::AnimatedUniform::AnimatedUniform(unsigned s, float v0, float v1, float v2, float v3):
40 KeyFrame::Loader::Loader(KeyFrame &k):
41 DataFile::CollectionObjectLoader<KeyFrame>(k, 0)
46 KeyFrame::Loader::Loader(KeyFrame &k, Collection &c):
47 DataFile::CollectionObjectLoader<KeyFrame>(k, &c)
52 void KeyFrame::Loader::init()
54 add("pose", &Loader::pose);
55 add("pose", &Loader::pose_inline);
56 add("transform", &Loader::transform);
57 add("uniforms", &Loader::uniforms);
59 // Deprecated; use the transform statement instead
60 add("position", &Loader::position);
61 add("rotation", &Loader::rotation);
62 add("scaling", &Loader::scaling_uniform);
63 add("scaling", &Loader::scaling);
66 void KeyFrame::Loader::pose(const string &n)
68 obj.pose = &get_collection().get<Pose>(n);
72 void KeyFrame::Loader::pose_inline()
74 RefPtr<Pose> p = new Pose;
75 load_sub(*p, get_collection());
79 void KeyFrame::Loader::position(float x, float y, float z)
81 obj.matrix.translate(x, y, z);
84 void KeyFrame::Loader::rotation(float a, float x, float y, float z)
86 obj.matrix.rotate_deg(a, x, y, z);
89 void KeyFrame::Loader::scaling_uniform(float s)
94 void KeyFrame::Loader::scaling(float x, float y, float z)
96 obj.matrix.scale(x, y, z);
99 void KeyFrame::Loader::transform()
103 obj.matrix = trn.to_matrix();
106 void KeyFrame::Loader::uniforms()
108 UniformsLoader ldr(obj);
113 KeyFrame::UniformsLoader::UniformsLoader(KeyFrame &k):
114 DataFile::ObjectLoader<KeyFrame>(k)
116 add("uniform1f", &UniformsLoader::uniform1f);
117 add("uniform2f", &UniformsLoader::uniform2f);
118 add("uniform3f", &UniformsLoader::uniform3f);
119 add("uniform4f", &UniformsLoader::uniform4f);
122 void KeyFrame::UniformsLoader::uniform1f(const string &n, float v)
124 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(1, v)));
127 void KeyFrame::UniformsLoader::uniform2f(const string &n, float v0, float v1)
129 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(2, v0, v1)));
132 void KeyFrame::UniformsLoader::uniform3f(const string &n, float v0, float v1, float v2)
134 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(3, v0, v1, v2)));
137 void KeyFrame::UniformsLoader::uniform4f(const string &n, float v0, float v1, float v2, float v3)
139 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(4, v0, v1, v2, v3)));