Move animation related classes
This commit is contained in:
34
openVulkanoCpp/Scene/Animation/SimpleAnimationController.cpp
Normal file
34
openVulkanoCpp/Scene/Animation/SimpleAnimationController.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user