Move animation related classes

This commit is contained in:
Georg Hagen
2025-01-26 18:51:34 +01:00
parent 44f12cf01e
commit dd866cd122
5 changed files with 29 additions and 31 deletions

View File

@@ -0,0 +1,34 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "SimpleAnimationController.hpp"
#include "Base/FrameMetadata.hpp"
namespace OpenVulkano::Scene
{
double SimpleAnimationController::GetProgress()
{
double progress = m_elapsed / m_duration;
if(progress >= 1.0)
progress = 1;
return progress;
}
void SimpleAnimationController::Tick()
{
if(!m_node || m_duration <= 0 || m_elapsed > m_duration)
return;
m_elapsed += CURRENT_FRAME.frameTime;
double progress = GetProgress();
Math::Pose<float> currentPose = m_initialPose.Interpolate(m_targetPose, progress);
m_node->SetMatrix(currentPose.ToMatrix());
if(m_elapsed > m_duration)
OnCompletion(this);
}
}