36 lines
1009 B
C++
36 lines
1009 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/.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "Camera.hpp"
|
|
#include "Math/Math.hpp"
|
|
|
|
namespace OpenVulkano::Scene
|
|
{
|
|
class MorphableCamera : public PerspectiveCamera
|
|
{
|
|
float m_morphState;
|
|
Math::Matrix4f m_orthoMatrix;
|
|
|
|
public:
|
|
MorphableCamera(float fovDegrees, float nearPlane = 0.1f, float farPlane = 1000.0f, float width = 16, float height = 9)
|
|
: PerspectiveCamera(fovDegrees, nearPlane, farPlane, width, height), m_morphState(0.0f)
|
|
{
|
|
UpdateProjectionMatrix();
|
|
}
|
|
|
|
void SetMorphState(float state)
|
|
{
|
|
m_morphState = Math::Utils::clamp(state, 0.0f, 1.0f);
|
|
UpdateProjectionMatrix();
|
|
}
|
|
|
|
void UpdateProjectionMatrix() override;
|
|
|
|
[[nodiscard]] bool IsPerspective() const override { return m_morphState == 0; }
|
|
[[nodiscard]] bool IsOrtho() const override { return m_morphState == 1; }
|
|
};
|
|
} |