Skip to content

Commit

Permalink
Implemented RecordAnimationPathHandler that enables recording and pla…
Browse files Browse the repository at this point in the history
…yback of the camera position.
  • Loading branch information
robertosfield committed Sep 29, 2023
1 parent 8c10185 commit 13a6424
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/vsg/utils/AnimationPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,31 +207,13 @@ void RecordAnimationPathHandler::apply(Camera& camera)
}
else if (recording)
{
#if 0
auto lookAt = camera.viewMatrix.cast<LookAt>();
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);
}
}
}
}

Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit 13a6424

Please sign in to comment.