From 116f95d84144f3f8c4a4b7c12d9ea68517552755 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 29 Sep 2023 15:00:53 +0100 Subject: [PATCH] Implemented RecordAnimationPathHandler that enables recording and playback of the camera position. --- src/vsg/utils/AnimationPath.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/vsg/utils/AnimationPath.cpp b/src/vsg/utils/AnimationPath.cpp index c6562bd4e..d043742b2 100644 --- a/src/vsg/utils/AnimationPath.cpp +++ b/src/vsg/utils/AnimationPath.cpp @@ -207,31 +207,13 @@ void RecordAnimationPathHandler::apply(Camera& camera) } else if (recording) { -#if 0 - auto lookAt = camera.viewMatrix.cast(); - if (lookAt) + dvec3 position, scale; + dquat orientation; + auto matrix = camera.viewMatrix->inverse(); + if (decompose(matrix, position, orientation, scale)) { - dvec3 position = lookAt->eye; - dvec3 scale(1.0, 1.0, 1.0); - dquat orientation; path->add(time, position, orientation, scale); } - else -#endif - { - dvec3 position, scale; - dquat orientation; - auto matrix = camera.viewMatrix->inverse(); - if (decompose(matrix, position, orientation, scale)) - { - auto result = vsg::translate(position) * vsg::rotate(orientation) * vsg::scale(scale); - - double det = determinant(matrix * inverse(result)); - info("det = ", det, ", matrix = ", matrix, ", decompose results = ", result); - - path->add(time, position, orientation, scale); - } - } } } @@ -243,6 +225,12 @@ void RecordAnimationPathHandler::apply(MatrixTransform& transform) } else if (recording) { + dvec3 position, scale; + dquat orientation; + if (decompose(transform.matrix, position, orientation, scale)) + { + path->add(time, position, orientation, scale); + } } }