X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fkeyframe.cpp;h=f610de2d42afbd08dd118cf97e7f54afa75da7de;hp=dd4adf16611efb7c2c05312d0428d949de7c6df5;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=3f7c493e13b7108098539078b729cffc095c304b diff --git a/source/keyframe.cpp b/source/keyframe.cpp index dd4adf16..f610de2d 100644 --- a/source/keyframe.cpp +++ b/source/keyframe.cpp @@ -14,9 +14,20 @@ KeyFrame::KeyFrame() KeyFrame::~KeyFrame() { } +void KeyFrame::set_transform(const Transform &t) +{ + transform = t; +} + void KeyFrame::set_matrix(const Matrix &m) { - matrix = m; + transform = Transform::from_matrix(m); +} + +void KeyFrame::set_uniform(const string &n, const AnimatedUniform &u) +{ + uniforms.erase(n); + uniforms.insert(UniformMap::value_type(n, u)); } void KeyFrame::set_pose(const Pose &p) @@ -52,11 +63,14 @@ 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); add("scaling", &Loader::scaling); - add("uniforms", &Loader::uniforms); } void KeyFrame::Loader::pose(const string &n) @@ -74,22 +88,27 @@ void KeyFrame::Loader::pose_inline() void KeyFrame::Loader::position(float x, float y, float z) { - obj.matrix.translate(x, y, z); + obj.transform.set_position(Vector3(x, y, z)); } void KeyFrame::Loader::rotation(float a, float x, float y, float z) { - obj.matrix.rotate_deg(a, x, y, z); + obj.transform.set_rotation(Transform::Angle::from_degrees(a), Vector3(x, y, z)); } void KeyFrame::Loader::scaling_uniform(float s) { - obj.matrix.scale(s); + obj.transform.set_scale(s); } void KeyFrame::Loader::scaling(float x, float y, float z) { - obj.matrix.scale(x, y, z); + obj.transform.set_scale(Vector3(x, y, z)); +} + +void KeyFrame::Loader::transform() +{ + load_sub(obj.transform); } void KeyFrame::Loader::uniforms() @@ -102,6 +121,12 @@ void KeyFrame::Loader::uniforms() KeyFrame::UniformsLoader::UniformsLoader(KeyFrame &k): DataFile::ObjectLoader(k) { + add("uniform", &UniformsLoader::uniform1f); + add("uniform", &UniformsLoader::uniform2f); + add("uniform", &UniformsLoader::uniform3f); + add("uniform", &UniformsLoader::uniform4f); + + // Deprecated add("uniform1f", &UniformsLoader::uniform1f); add("uniform2f", &UniformsLoader::uniform2f); add("uniform3f", &UniformsLoader::uniform3f);