36 lines
863 B
C++
36 lines
863 B
C++
/*
|
|
* 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 <utility>
|
|
|
|
#include "SimpleAnimationController.hpp"
|
|
#include "Base/FrameMetadata.hpp"
|
|
|
|
namespace OpenVulkano::Scene
|
|
{
|
|
void SimpleAnimationController::OnAnimationCompleted()
|
|
{
|
|
std::swap(m_targetPose, m_initialPose);
|
|
m_elapsed = 0;
|
|
}
|
|
|
|
void SimpleAnimationController::Tick()
|
|
{
|
|
if(!m_node || m_duration <= 0)
|
|
return;
|
|
|
|
m_elapsed += OpenVulkano::CURRENT_FRAME.frameTime;
|
|
float progress = m_elapsed / m_duration;
|
|
if(progress >= 1.0)
|
|
{
|
|
progress = 1;
|
|
m_event.NotifyAll();
|
|
}
|
|
|
|
OpenVulkano::Math::Pose<float> currentPose = m_initialPose.Interpolate(m_targetPose, progress);
|
|
m_node->SetMatrix(currentPose.ToMatrix());
|
|
}
|
|
} |