1 #include <msp/datafile/collection.h>
10 // Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h
17 void KeyFrame::set_matrix(const Matrix &m)
22 void KeyFrame::set_pose(const Pose &p)
29 KeyFrame::AnimatedUniform::AnimatedUniform(unsigned s, float v0, float v1, float v2, float v3):
39 KeyFrame::Loader::Loader(KeyFrame &k):
40 DataFile::CollectionObjectLoader<KeyFrame>(k, 0)
45 KeyFrame::Loader::Loader(KeyFrame &k, Collection &c):
46 DataFile::CollectionObjectLoader<KeyFrame>(k, &c)
51 void KeyFrame::Loader::init()
53 add("pose", &Loader::pose);
54 add("pose", &Loader::pose_inline);
55 add("position", &Loader::position);
56 add("rotation", &Loader::rotation);
57 add("scaling", &Loader::scaling_uniform);
58 add("scaling", &Loader::scaling);
59 add("uniforms", &Loader::uniforms);
62 void KeyFrame::Loader::pose(const string &n)
64 obj.pose = &get_collection().get<Pose>(n);
68 void KeyFrame::Loader::pose_inline()
70 RefPtr<Pose> p = new Pose;
71 load_sub(*p, get_collection());
75 void KeyFrame::Loader::position(float x, float y, float z)
77 obj.matrix.translate(x, y, z);
80 void KeyFrame::Loader::rotation(float a, float x, float y, float z)
82 obj.matrix.rotate_deg(a, x, y, z);
85 void KeyFrame::Loader::scaling_uniform(float s)
90 void KeyFrame::Loader::scaling(float x, float y, float z)
92 obj.matrix.scale(x, y, z);
95 void KeyFrame::Loader::uniforms()
97 UniformsLoader ldr(obj);
102 KeyFrame::UniformsLoader::UniformsLoader(KeyFrame &k):
103 DataFile::ObjectLoader<KeyFrame>(k)
105 add("uniform1f", &UniformsLoader::uniform1f);
106 add("uniform2f", &UniformsLoader::uniform2f);
107 add("uniform3f", &UniformsLoader::uniform3f);
108 add("uniform4f", &UniformsLoader::uniform4f);
111 void KeyFrame::UniformsLoader::uniform1f(const string &n, float v)
113 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(1, v)));
116 void KeyFrame::UniformsLoader::uniform2f(const string &n, float v0, float v1)
118 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(2, v0, v1)));
121 void KeyFrame::UniformsLoader::uniform3f(const string &n, float v0, float v1, float v2)
123 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(3, v0, v1, v2)));
126 void KeyFrame::UniformsLoader::uniform4f(const string &n, float v0, float v1, float v2, float v3)
128 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(4, v0, v1, v2, v3)));