Summary:
- In MovingCubeApp animations are now allocated on stack - m_sequenceAnimationController now uses SetAnimationPoseResetTime() - Removed OnSequenceAnimationCompleted() - Pose::GetOrientation() now returns by value(without it my code doesn't compile) - GetStep() getter - In if(m_loop) checking for m_resetTime to be zero or last step to be equal to the first - Tick now ticks only if there are at least one element in m_steps - IsFinished() function - AddAnimationSteps() functions that take initializer_lists - Getters in SimpleAnimationController are now const
This commit is contained in:
@@ -40,8 +40,8 @@ namespace OpenVulkano
|
||||
Scene::Material m_material;
|
||||
Scene::Shader m_shader;
|
||||
|
||||
std::unique_ptr<Scene::SimpleAnimationController> m_simpleAnimationController;
|
||||
std::unique_ptr<Scene::SequenceAnimationController> m_sequenceAnimationController;
|
||||
Scene::SimpleAnimationController m_simpleAnimationController;
|
||||
Scene::SequenceAnimationController m_sequenceAnimationController;
|
||||
|
||||
SceneElement m_whiteBox;
|
||||
SceneElement m_redBox;
|
||||
@@ -79,24 +79,22 @@ namespace OpenVulkano
|
||||
CreateSceneElement(&m_whiteBox, Math::Vector4f(1, 1, 1, 1), 1);
|
||||
CreateSceneElement(&m_redBox, Math::Vector4f(1, 0.2, 0.2, 1.0), 0.3);
|
||||
|
||||
m_simpleAnimationController = std::make_unique<Scene::SimpleAnimationController>();
|
||||
m_simpleAnimationController->SetNode(&m_whiteBox.m_node);
|
||||
m_simpleAnimationController->SetDuration(3);
|
||||
m_simpleAnimationController.SetNode(&m_whiteBox.m_node);
|
||||
m_simpleAnimationController.SetDuration(3);
|
||||
Math::Pose srcPose(Math::Quaternion<float>(), Math::Vector3f_SIMD(-3, 0, 0));
|
||||
Math::Pose destPose(Math::Quaternion<float>(), Math::Vector3f_SIMD(3, 0, 0));
|
||||
m_simpleAnimationController->SetPoses(srcPose, destPose);
|
||||
m_simpleAnimationController->m_completionEvent += EventHandler(this, &MovingCubeAppImpl::OnSimpleAnimationCompleted);
|
||||
m_simpleAnimationController.SetPoses(srcPose, destPose);
|
||||
m_simpleAnimationController.m_completionEvent += EventHandler(this, &MovingCubeAppImpl::OnSimpleAnimationCompleted);
|
||||
|
||||
m_sequenceAnimationController = std::make_unique<Scene::SequenceAnimationController>();
|
||||
m_sequenceAnimationController->EnableLoop(false);
|
||||
m_sequenceAnimationController->SetNode(&m_redBox.m_node);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(1, 0, 0, 1)), Math::Vector3f_SIMD(0, 0, 1)), 5);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(2, 1, 0, 1)), Math::Vector3f_SIMD(1, 1, -1)), 3);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(1, 1, 1, 1)), Math::Vector3f_SIMD(2, 1, -2)), 3);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(0, 1, 1, 0)), Math::Vector3f_SIMD(2, 1, -1)), 3);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(3, 2, 1, 1)), Math::Vector3f_SIMD(1, 1, -1)), 3);
|
||||
m_sequenceAnimationController->AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(0, 0, 1, 1)), Math::Vector3f_SIMD(0, 1, 0)), 1);
|
||||
m_sequenceAnimationController->m_sequenceCompletionEvent += EventHandler(this, &MovingCubeAppImpl::OnSequenceAnimationCompleted);
|
||||
m_sequenceAnimationController.EnableLoop(true);
|
||||
m_sequenceAnimationController.SetNode(&m_redBox.m_node);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(1, 0, 0, 1)), Math::Vector3f_SIMD(0, 0, 1)), 5);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(2, 1, 0, 1)), Math::Vector3f_SIMD(1, 1, -1)), 3);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(1, 1, 1, 1)), Math::Vector3f_SIMD(2, 1, -2)), 3);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(0, 1, 1, 0)), Math::Vector3f_SIMD(2, 1, -1)), 3);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(3, 2, 1, 1)), Math::Vector3f_SIMD(1, 1, -1)), 3);
|
||||
m_sequenceAnimationController.AddAnimationStep(Math::PoseF(Math::Utils::normalize(Math::QuaternionF(0, 0, 1, 1)), Math::Vector3f_SIMD(0, 1, 0)), 1);
|
||||
m_sequenceAnimationController.SetAnimationPoseResetTime(10);
|
||||
}
|
||||
|
||||
void OnSimpleAnimationCompleted(Scene::SimpleAnimationController *anim)
|
||||
@@ -105,17 +103,11 @@ namespace OpenVulkano
|
||||
anim->Reset();
|
||||
}
|
||||
|
||||
void OnSequenceAnimationCompleted(Scene::SequenceAnimationController *anim)
|
||||
{
|
||||
Logger::APP->info("Animation sequence completed - restarting...");
|
||||
m_sequenceAnimationController->Restart();
|
||||
}
|
||||
|
||||
void Tick() override
|
||||
{
|
||||
m_cameraControl.Tick();
|
||||
m_simpleAnimationController->Tick();
|
||||
m_sequenceAnimationController->Tick();
|
||||
m_simpleAnimationController.Tick();
|
||||
m_sequenceAnimationController.Tick();
|
||||
}
|
||||
|
||||
void Close() override
|
||||
|
||||
Reference in New Issue
Block a user