2020-04-26 15:37:49 -06:00
|
|
|
// Copyright 2020 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include "Common/Matrix.h"
|
2020-06-18 22:44:17 -06:00
|
|
|
#include "Core/FreeLookConfig.h"
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
class PointerWrap;
|
|
|
|
|
|
|
|
class CameraController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CameraController() = default;
|
|
|
|
virtual ~CameraController() = default;
|
|
|
|
|
|
|
|
CameraController(const CameraController&) = delete;
|
|
|
|
CameraController& operator=(const CameraController&) = delete;
|
|
|
|
|
|
|
|
CameraController(CameraController&&) = delete;
|
|
|
|
CameraController& operator=(CameraController&&) = delete;
|
|
|
|
|
|
|
|
virtual Common::Matrix44 GetView() = 0;
|
|
|
|
|
|
|
|
virtual void MoveVertical(float amt) = 0;
|
|
|
|
virtual void MoveHorizontal(float amt) = 0;
|
|
|
|
|
2020-06-11 23:21:50 -06:00
|
|
|
virtual void MoveForward(float amt) = 0;
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
virtual void Rotate(const Common::Vec3& amt) = 0;
|
2020-10-22 22:09:14 -06:00
|
|
|
virtual void Rotate(const Common::Quaternion& quat) = 0;
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
virtual void Reset() = 0;
|
|
|
|
|
|
|
|
virtual void DoState(PointerWrap& p) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FreeLookCamera
|
|
|
|
{
|
|
|
|
public:
|
2020-12-25 21:19:09 -07:00
|
|
|
FreeLookCamera();
|
2020-06-18 22:44:17 -06:00
|
|
|
void SetControlType(FreeLook::ControlType type);
|
2020-04-26 15:37:49 -06:00
|
|
|
Common::Matrix44 GetView();
|
2020-05-18 16:22:41 -06:00
|
|
|
Common::Vec2 GetFieldOfView() const;
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
void MoveVertical(float amt);
|
|
|
|
void MoveHorizontal(float amt);
|
2020-06-11 23:21:50 -06:00
|
|
|
void MoveForward(float amt);
|
2020-04-26 15:37:49 -06:00
|
|
|
|
|
|
|
void Rotate(const Common::Vec3& amt);
|
2021-03-11 23:02:06 -07:00
|
|
|
void Rotate(const Common::Quaternion& amt);
|
2020-04-26 15:37:49 -06:00
|
|
|
|
2020-05-18 16:22:41 -06:00
|
|
|
void IncreaseFovX(float fov);
|
|
|
|
void IncreaseFovY(float fov);
|
2020-06-22 21:09:32 -06:00
|
|
|
float GetFovStepSize() const;
|
2020-05-18 16:22:41 -06:00
|
|
|
|
2020-04-26 15:37:49 -06:00
|
|
|
void Reset();
|
|
|
|
|
|
|
|
void DoState(PointerWrap& p);
|
|
|
|
|
|
|
|
bool IsDirty() const;
|
2020-06-17 11:07:40 -06:00
|
|
|
void SetClean();
|
2020-04-26 15:37:49 -06:00
|
|
|
|
2020-06-11 23:17:40 -06:00
|
|
|
void ModifySpeed(float multiplier);
|
|
|
|
void ResetSpeed();
|
|
|
|
float GetSpeed() const;
|
|
|
|
|
2020-06-18 22:49:07 -06:00
|
|
|
bool IsActive() const;
|
|
|
|
|
2020-04-26 15:37:49 -06:00
|
|
|
private:
|
|
|
|
bool m_dirty = false;
|
2020-05-18 16:22:41 -06:00
|
|
|
float m_fov_x = 1.0f;
|
|
|
|
float m_fov_y = 1.0f;
|
2020-06-18 22:44:17 -06:00
|
|
|
std::optional<FreeLook::ControlType> m_current_type;
|
2020-04-26 15:37:49 -06:00
|
|
|
std::unique_ptr<CameraController> m_camera_controller;
|
2020-06-22 21:09:32 -06:00
|
|
|
|
2021-03-17 19:51:35 -06:00
|
|
|
float m_min_fov_multiplier = 0.025f;
|
|
|
|
float m_speed = 60.0f;
|
2020-04-26 15:37:49 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
extern FreeLookCamera g_freelook_camera;
|