70 lines
1.8 KiB
C++
70 lines
1.8 KiB
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/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "MorphableCamera.hpp"
|
|
#include "Controller/CameraController.hpp"
|
|
|
|
namespace OpenVulkano
|
|
{
|
|
namespace Input
|
|
{
|
|
class InputAction;
|
|
}
|
|
|
|
namespace Scene
|
|
{
|
|
class MorphableCameraController final : public CameraController
|
|
{
|
|
double m_animationDuration;
|
|
double m_currentTime;
|
|
bool m_isMorphing;
|
|
bool m_targetMorphStatePerspective; // true for perspective, false for orthographic
|
|
|
|
public:
|
|
MorphableCameraController(MorphableCamera* camera = nullptr);
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
|
void Init(MorphableCamera* camera);
|
|
#pragma clang diagnostic pop
|
|
|
|
void Tick() override;
|
|
|
|
void SetDuration(const double duration) { m_animationDuration = duration; }
|
|
|
|
[[nodiscard]] double GetDuration() const { return m_animationDuration; }
|
|
|
|
void SetTargetState(bool toPerspective);
|
|
|
|
[[nodiscard]] bool IsTargetPerspective() const { return m_targetMorphStatePerspective; }
|
|
|
|
void Reset() { m_currentTime = 0; }
|
|
};
|
|
|
|
class MorphableCameraControllerWithInput final
|
|
{
|
|
MorphableCameraController m_controller;
|
|
Input::InputAction* m_actionMorph;
|
|
|
|
public:
|
|
MorphableCameraControllerWithInput(MorphableCamera* camera = nullptr);
|
|
|
|
void Init(MorphableCamera* camera) { m_controller.Init(camera); }
|
|
|
|
void Tick();
|
|
|
|
void SetDuration(const double duration) { m_controller.SetDuration(duration); }
|
|
|
|
[[nodiscard]] double GetDuration() const { return m_controller.GetDuration(); }
|
|
|
|
void SetTargetState(const bool toPerspective) { m_controller.SetTargetState(toPerspective); }
|
|
|
|
void Reset() { m_controller.Reset(); }
|
|
};
|
|
}
|
|
} |