Move free cam camera controlls into it's own class

This commit is contained in:
2021-05-29 15:26:23 +02:00
parent d80249cd1c
commit a5d5f53ae7
5 changed files with 167 additions and 36 deletions

View File

@@ -0,0 +1,62 @@
/*
* 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 "Base/ITickable.hpp"
#include "Base/ICloseable.hpp"
#include "Math/Math.hpp"
namespace openVulkanoCpp
{
namespace Scene
{
class Camera;
}
namespace Input
{
class InputAction;
}
class FreeCamCameraController final : public ITickable, public ICloseable
{
Scene::Camera* m_camera = nullptr;
float m_yaw = 0, m_pitch = 0, m_boostFactor = 2;
Math::Vector3f_SIMD m_position = { 0, 0, 0 };
Input::InputAction* m_actionForward;
Input::InputAction* m_actionSide;
Input::InputAction* m_actionUp;
Input::InputAction* m_actionLookUp;
Input::InputAction* m_actionLookSide;
Input::InputAction* m_actionBoost;
public:
FreeCamCameraController(Scene::Camera* camera = nullptr);
~FreeCamCameraController() override = default;
void Init(Scene::Camera* camera) { m_camera = camera; ResetPose(); }
void SetCamera(Scene::Camera* camera) { m_camera = camera; }
void ResetPose() { m_yaw = m_pitch = 0; m_position = { 0, 0, 0 }; }
void SetPosition(const Math::Vector3f_SIMD& position) { m_position = position; }
void SetOrientation(float yaw, float pitch) { m_yaw = yaw; m_pitch = pitch; }
void SetBoostFactor(float factor = 2) { m_boostFactor = factor; }
void Tick() override;
void Close() override { m_camera = nullptr; }
void SetDefaultKeybindings();
};
}