1 #include <msp/datafile/collection.h>
10 // Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h
17 void KeyFrame::set_transform(const Transform &t)
22 void KeyFrame::set_matrix(const Matrix &m)
24 transform = Transform::from_matrix(m);
27 void KeyFrame::set_uniform(const string &n, const AnimatedUniform &u)
30 uniforms.insert(UniformMap::value_type(n, u));
33 void KeyFrame::set_pose(const Pose &p)
40 KeyFrame::AnimatedUniform::AnimatedUniform(unsigned s, float v0, float v1, float v2, float v3):
50 KeyFrame::Loader::Loader(KeyFrame &k):
51 DataFile::CollectionObjectLoader<KeyFrame>(k, 0)
56 KeyFrame::Loader::Loader(KeyFrame &k, Collection &c):
57 DataFile::CollectionObjectLoader<KeyFrame>(k, &c)
62 void KeyFrame::Loader::init()
64 add("pose", &Loader::pose);
65 add("pose", &Loader::pose_inline);
66 add("transform", &Loader::transform);
67 add("uniforms", &Loader::uniforms);
69 // Deprecated; use the transform statement instead
70 add("position", &Loader::position);
71 add("rotation", &Loader::rotation);
72 add("scaling", &Loader::scaling_uniform);
73 add("scaling", &Loader::scaling);
76 void KeyFrame::Loader::pose(const string &n)
78 obj.pose = &get_collection().get<Pose>(n);
82 void KeyFrame::Loader::pose_inline()
84 RefPtr<Pose> p = new Pose;
85 load_sub(*p, get_collection());
89 void KeyFrame::Loader::position(float x, float y, float z)
91 obj.transform.set_position(Vector3(x, y, z));
94 void KeyFrame::Loader::rotation(float a, float x, float y, float z)
96 obj.transform.set_rotation(Transform::Angle::from_degrees(a), Vector3(x, y, z));
99 void KeyFrame::Loader::scaling_uniform(float s)
101 obj.transform.set_scale(s);
104 void KeyFrame::Loader::scaling(float x, float y, float z)
106 obj.transform.set_scale(Vector3(x, y, z));
109 void KeyFrame::Loader::transform()
111 load_sub(obj.transform);
114 void KeyFrame::Loader::uniforms()
116 UniformsLoader ldr(obj);
121 KeyFrame::UniformsLoader::UniformsLoader(KeyFrame &k):
122 DataFile::ObjectLoader<KeyFrame>(k)
124 add("uniform", &UniformsLoader::uniform1f);
125 add("uniform", &UniformsLoader::uniform2f);
126 add("uniform", &UniformsLoader::uniform3f);
127 add("uniform", &UniformsLoader::uniform4f);
130 add("uniform1f", &UniformsLoader::uniform1f);
131 add("uniform2f", &UniformsLoader::uniform2f);
132 add("uniform3f", &UniformsLoader::uniform3f);
133 add("uniform4f", &UniformsLoader::uniform4f);
136 void KeyFrame::UniformsLoader::uniform1f(const string &n, float v)
138 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(1, v)));
141 void KeyFrame::UniformsLoader::uniform2f(const string &n, float v0, float v1)
143 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(2, v0, v1)));
146 void KeyFrame::UniformsLoader::uniform3f(const string &n, float v0, float v1, float v2)
148 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(3, v0, v1, v2)));
151 void KeyFrame::UniformsLoader::uniform4f(const string &n, float v0, float v1, float v2, float v3)
153 obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(4, v0, v1, v2, v3)));