X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fkeyframe.cpp;h=708fa22bc338e25a478ec11ccc969eccccf37589;hp=8e0d79044483f0fac6ba52c64476adb344e5b090;hb=9e384cddaf641f25ce6714327e1b4fadfea4632d;hpb=8b9d1625ac367114612b57a83901033ffc2bc7e0 diff --git a/source/keyframe.cpp b/source/keyframe.cpp index 8e0d7904..708fa22b 100644 --- a/source/keyframe.cpp +++ b/source/keyframe.cpp @@ -1,6 +1,7 @@ #include #include "keyframe.h" #include "pose.h" +#include "transform.h" using namespace std; @@ -26,6 +27,16 @@ void KeyFrame::set_pose(const Pose &p) } +KeyFrame::AnimatedUniform::AnimatedUniform(unsigned s, float v0, float v1, float v2, float v3): + size(s) +{ + values[0] = v0; + values[1] = v1; + values[2] = v2; + values[3] = v3; +} + + KeyFrame::Loader::Loader(KeyFrame &k): DataFile::CollectionObjectLoader(k, 0) { @@ -42,6 +53,10 @@ void KeyFrame::Loader::init() { add("pose", &Loader::pose); add("pose", &Loader::pose_inline); + add("transform", &Loader::transform); + add("uniforms", &Loader::uniforms); + + // Deprecated; use the transform statement instead add("position", &Loader::position); add("rotation", &Loader::rotation); add("scaling", &Loader::scaling_uniform); @@ -81,5 +96,48 @@ void KeyFrame::Loader::scaling(float x, float y, float z) obj.matrix.scale(x, y, z); } +void KeyFrame::Loader::transform() +{ + Transform trn; + load_sub(trn); + obj.matrix = trn.to_matrix(); +} + +void KeyFrame::Loader::uniforms() +{ + UniformsLoader ldr(obj); + load_sub_with(ldr); +} + + +KeyFrame::UniformsLoader::UniformsLoader(KeyFrame &k): + DataFile::ObjectLoader(k) +{ + add("uniform1f", &UniformsLoader::uniform1f); + add("uniform2f", &UniformsLoader::uniform2f); + add("uniform3f", &UniformsLoader::uniform3f); + add("uniform4f", &UniformsLoader::uniform4f); +} + +void KeyFrame::UniformsLoader::uniform1f(const string &n, float v) +{ + obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(1, v))); +} + +void KeyFrame::UniformsLoader::uniform2f(const string &n, float v0, float v1) +{ + obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(2, v0, v1))); +} + +void KeyFrame::UniformsLoader::uniform3f(const string &n, float v0, float v1, float v2) +{ + obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(3, v0, v1, v2))); +} + +void KeyFrame::UniformsLoader::uniform4f(const string &n, float v0, float v1, float v2, float v3) +{ + obj.uniforms.insert(UniformMap::value_type(n, AnimatedUniform(4, v0, v1, v2, v3))); +} + } // namespace GL } // namespace Msp