mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
patch
This commit is contained in:
@@ -23,7 +23,7 @@ namespace omath::projection
|
||||
|
||||
Matrix Camera::GetViewMatrix() const
|
||||
{
|
||||
return GetOrientationMatrix() * GetTranslationMatrix();
|
||||
return GetTranslationMatrix() * GetOrientationMatrix();
|
||||
}
|
||||
|
||||
Matrix Camera::GetProjectionMatrix() const
|
||||
@@ -40,10 +40,10 @@ namespace omath::projection
|
||||
const auto m_fNear = m_nearPlaneDistance;
|
||||
|
||||
return Matrix({
|
||||
{2.f / (fRight - fLeft), 0.f, 0.f, 0.f},
|
||||
{0.f, 0.f, 2.f / (fTop - fBottom), 0.f},
|
||||
{0.f, (m_fFar + m_fNear) / (m_fFar - m_fNear), 0.f, 1.f},
|
||||
{0.f, -2.f * m_fNear * m_fFar / (m_fFar - m_fNear), 0.f, 0.f},
|
||||
{2.f / (fRight - fLeft), 0.f, 0.f, 0.f},
|
||||
{0.f, 2.f / (fTop - fBottom), 0.f, 0.f},
|
||||
{0.f, 0.f, (m_fFar + m_fNear) / (m_fFar - m_fNear), 1.f},
|
||||
{0.f, 0.f, -2.f * m_fNear * m_fFar / (m_fFar - m_fNear), 0.f},
|
||||
});
|
||||
|
||||
}
|
||||
@@ -52,10 +52,10 @@ namespace omath::projection
|
||||
{
|
||||
return Matrix(
|
||||
{
|
||||
{1.f, 0.f, 0.f, -m_origin.x},
|
||||
{0.f, 1.f, 0.f, -m_origin.y},
|
||||
{0.f, 0.f, 1.f, -m_origin.z},
|
||||
{0.f, 0.f, 0.f, 1.f},
|
||||
{1.f, 0.f, 0.f, 0.f},
|
||||
{0.f, 1.f, 0.f, 1.f},
|
||||
{0.f, 0.f, 1.f, 0.f},
|
||||
{-m_origin.x, -m_origin.y, -m_origin.z, 1.f},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,6 +90,6 @@ namespace omath::projection
|
||||
|
||||
projected *= Matrix::ToScreenMatrix(m_viewPort.x, m_viewPort.y);
|
||||
|
||||
return Vector3{projected.At(0, 0), projected.At(0, 1), projected.At(0, 2)};
|
||||
return Vector3{projected.At(0, 0), projected.At(0, 2), projected.At(0, 1)};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by Vlad on 27.08.2024.
|
||||
//
|
||||
#include <complex>
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/Matrix.h>
|
||||
#include <print>
|
||||
@@ -8,8 +9,10 @@
|
||||
|
||||
TEST(UnitTestProjection, IsPointOnScreen)
|
||||
{
|
||||
const omath::projection::Camera camera({}, {90, 0.f, 0.f} , {1920.f, 1080.f, 0.f}, 120, 10, 100);
|
||||
const omath::projection::Camera camera({0, 0, 0}, {0, 0.f, 0.f} , {1920.f, 1080.f, 0.f}, 110, 0.1, 500);
|
||||
|
||||
const auto proj = camera.WorldToScreen({0, 0, 20});
|
||||
const auto proj = camera.WorldToScreen({5, 0, 0});
|
||||
if (proj)
|
||||
std::print("{} {} {}", proj->x, proj->z, proj->y);
|
||||
EXPECT_TRUE(proj.has_value());
|
||||
}
|
||||
Reference in New Issue
Block a user