From 927d56fef37e4da64490ef8ad942de558a2fb822 Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 27 Aug 2024 23:03:33 +0300 Subject: [PATCH] added debug methods --- include/omath/projection/Camera.h | 5 ++++- source/projection/Camera.cpp | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/omath/projection/Camera.h b/include/omath/projection/Camera.h index f86c8b6..7b2f864 100644 --- a/include/omath/projection/Camera.h +++ b/include/omath/projection/Camera.h @@ -18,9 +18,12 @@ namespace omath::projection Camera(const Vector3& position, const Vector3& viewAngles, const Vector3& viewPort, float fov, float near, float far); void SetViewAngles(const Vector3& viewAngles); [[nodiscard]] const Vector3& GetViewAngles() const; + static float& GetFloat1(); + + static float& GetFloat2(); [[nodiscard]] Matrix GetViewMatrix() const; - [[nodiscard]] Matrix GetProjectionMatrix() const; + [[nodiscard]] Matrix GetProjectionMatrix(float scaleX, float scaleY) const; [[nodiscard]] Matrix GetTranslationMatrix() const; [[nodiscard]] Matrix GetOrientationMatrix() const; diff --git a/source/projection/Camera.cpp b/source/projection/Camera.cpp index fd93ec1..7d6b2ac 100644 --- a/source/projection/Camera.cpp +++ b/source/projection/Camera.cpp @@ -21,12 +21,22 @@ namespace omath::projection m_farPlaneDistance = far; } + float & Camera::GetFloat1() { + static float m_float1 = 1.52550f; + return m_float1; + } + + float & Camera::GetFloat2() { + static float m_float2 = 1.14500f; + return m_float2; + } + Matrix Camera::GetViewMatrix() const { return GetTranslationMatrix() * GetOrientationMatrix(); } - Matrix Camera::GetProjectionMatrix() const + Matrix Camera::GetProjectionMatrix(const float scaleX, const float scaleY) const { const float fRight = std::tan(angles::DegreesToRadians(m_fieldOfView) / 2.f); const float fLeft = -fRight; @@ -40,8 +50,8 @@ namespace omath::projection const auto near = m_nearPlaneDistance; return Matrix({ - {1.555f / (fRight - fLeft), 0.f, 0.f, 0.f}, - {0.f, 1.15f / (top - botton), 0.f, 0.f}, + {scaleX / (fRight - fLeft), 0.f, 0.f, 0.f}, + {0.f, scaleY / (top - botton), 0.f, 0.f}, {0.f, 0.f, (far + near) / (far - near), 1.f}, {0.f, 0.f, -near * far / (far - near), 0.f}, }); @@ -78,7 +88,7 @@ namespace omath::projection { const auto posVecAsMatrix = Matrix({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}}); - const auto viewProjectionMatrix = GetViewMatrix() * GetProjectionMatrix(); + const auto viewProjectionMatrix = GetViewMatrix() * GetProjectionMatrix(GetFloat1(), GetFloat2()); auto projected = posVecAsMatrix * viewProjectionMatrix;