X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fkeyframe.cpp;h=dd4adf16611efb7c2c05312d0428d949de7c6df5;hp=e0d35ad80c7546a74f00754657a283a5e4583520;hb=944deb38084e5e5bc82182faab2db2be156b971c;hpb=57fc4142e0b19a21f61c60b00f8310d5d2c27871 diff --git a/source/keyframe.cpp b/source/keyframe.cpp index e0d35ad8..dd4adf16 100644 --- a/source/keyframe.cpp +++ b/source/keyframe.cpp @@ -7,6 +7,13 @@ using namespace std; namespace Msp { namespace GL { +// Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h +KeyFrame::KeyFrame() +{ } + +KeyFrame::~KeyFrame() +{ } + void KeyFrame::set_matrix(const Matrix &m) { matrix = m; @@ -19,6 +26,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) { @@ -39,6 +56,7 @@ void KeyFrame::Loader::init() add("rotation", &Loader::rotation); add("scaling", &Loader::scaling_uniform); add("scaling", &Loader::scaling); + add("uniforms", &Loader::uniforms); } void KeyFrame::Loader::pose(const string &n) @@ -74,5 +92,41 @@ void KeyFrame::Loader::scaling(float x, float y, float z) obj.matrix.scale(x, y, z); } +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