diff --git a/include/omath/engines/opengl.hpp b/include/omath/engines/opengl.hpp index 6b70756..6bed17e 100644 --- a/include/omath/engines/opengl.hpp +++ b/include/omath/engines/opengl.hpp @@ -12,15 +12,27 @@ namespace omath::opengl constexpr Vector3 kAbsRight = {1, 0, 0}; constexpr Vector3 kAbsForward = {0, 0, -1}; - template requires std::is_floating_point_v || std::is_integral_v - [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix() - { + template + requires std::is_floating_point_v || std::is_integral_v + [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> ViewMatrix(const Vector3& forward, + const Vector3& right, + const Vector3& up, + const Vector3& cam_origin) + { + return + { + {right.x, up.x, -forward.x, 0}, + {right.y, up.y, -forward.y, 0}, + {right.z, up.z, -forward.z, 0}, + {-cam_origin.x, -cam_origin.y, -cam_origin.z, 1}, + }; } - template requires std::is_floating_point_v || std::is_integral_v + template + requires std::is_floating_point_v || std::is_integral_v [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix( - const float fieldOfView, const Type &aspectRatio, const Type &near, const Type &far) + const float fieldOfView, const Type& aspectRatio, const Type& near, const Type& far) { const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2); diff --git a/include/omath/engines/source.hpp b/include/omath/engines/source.hpp index 24308fc..32c248a 100644 --- a/include/omath/engines/source.hpp +++ b/include/omath/engines/source.hpp @@ -2,7 +2,8 @@ // Created by Orange on 11/24/2024. // #pragma once - +#include "omath/Vector3.hpp" +#include "omath/Mat.hpp" namespace omath::source { diff --git a/include/omath/engines/unity.hpp b/include/omath/engines/unity.hpp new file mode 100644 index 0000000..ff43bb2 --- /dev/null +++ b/include/omath/engines/unity.hpp @@ -0,0 +1,12 @@ +// +// Created by Orange on 11/27/2024. +// + +#pragma once +#include + + +namespace omath::unity +{ + +}; diff --git a/include/omath/projection/Camera.hpp b/include/omath/projection/Camera.hpp index d2d450e..ac5a241 100644 --- a/include/omath/projection/Camera.hpp +++ b/include/omath/projection/Camera.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include "ErrorCodes.hpp" diff --git a/source/projection/Camera.cpp b/source/projection/Camera.cpp index c26f75a..af9782b 100644 --- a/source/projection/Camera.cpp +++ b/source/projection/Camera.cpp @@ -3,10 +3,6 @@ // #include "omath/projection/Camera.hpp" -#include - -#include "omath/Angles.hpp" - namespace omath::projection { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3b9b056..6d8d48e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,17 +5,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" include(GoogleTest) add_executable(unit-tests - UnitTestPrediction.cpp - UnitTestMatrix.cpp - UnitTestMat.cpp - UnitTestAstar.cpp - UnitTestProjection.cpp - UnitTestVector3.cpp - UnitTestVector2.cpp - UnitTestColor.cpp - UnitTestVector4.cpp - UnitTestLineTrace.cpp - UnitTestOpenGL.cpp + general/UnitTestPrediction.cpp + general/UnitTestMatrix.cpp + general/UnitTestMat.cpp + general/UnitTestAstar.cpp + general/UnitTestProjection.cpp + general/UnitTestVector3.cpp + general/UnitTestVector2.cpp + general/UnitTestColor.cpp + general/UnitTestVector4.cpp + general/UnitTestLineTrace.cpp + + engines/UnitTestOpenGL.cpp + engines/UnitTestUnityEngine.cpp + engines/UnitTestSourceEngine.cpp ) target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm) diff --git a/tests/UnitTestOpenGL.cpp b/tests/engines/UnitTestOpenGL.cpp similarity index 79% rename from tests/UnitTestOpenGL.cpp rename to tests/engines/UnitTestOpenGL.cpp index e4f1561..0c44e4a 100644 --- a/tests/UnitTestOpenGL.cpp +++ b/tests/engines/UnitTestOpenGL.cpp @@ -38,11 +38,11 @@ TEST(UnitTestOpenGL, Projection) } TEST(UnitTestOpenGL, Projection2) { - const auto orient = omath::Mat<>::OrientationMat(omath::opengl::kAbsForward, omath::opengl::kAbsRight, omath::opengl::kAbsUp); + const auto orient = omath::opengl::ViewMatrix(omath::opengl::kAbsForward, -omath::opengl::kAbsRight, omath::opengl::kAbsUp, {}); - const omath::Mat<4, 1> cords_omath = + const omath::Mat<4, 1,float, omath::MatStoreType::COLUMN_MAJOR> cords_omath = { - {0}, {0}, {10}, {1} + {0}, {0}, {-10}, {1} }; - std::cout << (orient.Transposed() * cords_omath).ToString(); + std::cout << (orient * cords_omath).ToString(); } \ No newline at end of file diff --git a/tests/engines/UnitTestSourceEngine.cpp b/tests/engines/UnitTestSourceEngine.cpp new file mode 100644 index 0000000..4f6b72b --- /dev/null +++ b/tests/engines/UnitTestSourceEngine.cpp @@ -0,0 +1,3 @@ +// +// Created by Orange on 11/27/2024. +// diff --git a/tests/engines/UnitTestUnityEngine.cpp b/tests/engines/UnitTestUnityEngine.cpp new file mode 100644 index 0000000..4f6b72b --- /dev/null +++ b/tests/engines/UnitTestUnityEngine.cpp @@ -0,0 +1,3 @@ +// +// Created by Orange on 11/27/2024. +// diff --git a/tests/UnitTestAstar.cpp b/tests/general/UnitTestAstar.cpp similarity index 100% rename from tests/UnitTestAstar.cpp rename to tests/general/UnitTestAstar.cpp diff --git a/tests/UnitTestColor.cpp b/tests/general/UnitTestColor.cpp similarity index 100% rename from tests/UnitTestColor.cpp rename to tests/general/UnitTestColor.cpp diff --git a/tests/UnitTestLineTrace.cpp b/tests/general/UnitTestLineTrace.cpp similarity index 100% rename from tests/UnitTestLineTrace.cpp rename to tests/general/UnitTestLineTrace.cpp diff --git a/tests/UnitTestMat.cpp b/tests/general/UnitTestMat.cpp similarity index 100% rename from tests/UnitTestMat.cpp rename to tests/general/UnitTestMat.cpp diff --git a/tests/UnitTestMatrix.cpp b/tests/general/UnitTestMatrix.cpp similarity index 100% rename from tests/UnitTestMatrix.cpp rename to tests/general/UnitTestMatrix.cpp diff --git a/tests/UnitTestPrediction.cpp b/tests/general/UnitTestPrediction.cpp similarity index 100% rename from tests/UnitTestPrediction.cpp rename to tests/general/UnitTestPrediction.cpp diff --git a/tests/UnitTestProjection.cpp b/tests/general/UnitTestProjection.cpp similarity index 100% rename from tests/UnitTestProjection.cpp rename to tests/general/UnitTestProjection.cpp diff --git a/tests/UnitTestVector2.cpp b/tests/general/UnitTestVector2.cpp similarity index 100% rename from tests/UnitTestVector2.cpp rename to tests/general/UnitTestVector2.cpp diff --git a/tests/UnitTestVector3.cpp b/tests/general/UnitTestVector3.cpp similarity index 100% rename from tests/UnitTestVector3.cpp rename to tests/general/UnitTestVector3.cpp diff --git a/tests/UnitTestVector4.cpp b/tests/general/UnitTestVector4.cpp similarity index 100% rename from tests/UnitTestVector4.cpp rename to tests/general/UnitTestVector4.cpp