mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
changed naming of engines section
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
#include "omath/projection/Camera.hpp"
|
#include "omath/projection/Camera.hpp"
|
||||||
|
|
||||||
namespace omath::opengl
|
namespace omath::opengl_engine
|
||||||
{
|
{
|
||||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <omath/Angle.hpp>
|
#include <omath/Angle.hpp>
|
||||||
#include <omath/ViewAngles.hpp>
|
#include <omath/ViewAngles.hpp>
|
||||||
|
|
||||||
namespace omath::opengl
|
namespace omath::opengl_engine
|
||||||
{
|
{
|
||||||
constexpr Vector3<float> kAbsUp = {0, 1, 0};
|
constexpr Vector3<float> kAbsUp = {0, 1, 0};
|
||||||
constexpr Vector3<float> kAbsRight = {1, 0, 0};
|
constexpr Vector3<float> kAbsRight = {1, 0, 0};
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace omath::opengl
|
namespace omath::opengl_engine
|
||||||
{
|
{
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
#include "omath/projection/Camera.hpp"
|
#include "omath/projection/Camera.hpp"
|
||||||
|
|
||||||
namespace omath::source
|
namespace omath::source_engine
|
||||||
{
|
{
|
||||||
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
#include <omath/Mat.hpp>
|
#include <omath/Mat.hpp>
|
||||||
#include <omath/Angle.hpp>
|
#include <omath/Angle.hpp>
|
||||||
#include <omath/ViewAngles.hpp>
|
#include <omath/ViewAngles.hpp>
|
||||||
namespace omath::source
|
|
||||||
|
namespace omath::source_engine
|
||||||
{
|
{
|
||||||
constexpr Vector3<float> kAbsUp = {0, 0, 1};
|
constexpr Vector3<float> kAbsUp = {0, 0, 1};
|
||||||
constexpr Vector3<float> kAbsRight = {0, -1, 0};
|
constexpr Vector3<float> kAbsRight = {0, -1, 0};
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
|
|
||||||
namespace omath::source
|
namespace omath::source_engine
|
||||||
{
|
{
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
inline Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
add_subdirectory(Source)
|
add_subdirectory(source_engine)
|
||||||
add_subdirectory(OpenGL)
|
add_subdirectory(opengl_engine)
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
//
|
//
|
||||||
// Created by Orange on 12/23/2024.
|
// Created by Orange on 12/23/2024.
|
||||||
//
|
//
|
||||||
#include "omath/engines/OpenGL/Camera.hpp"
|
#include "omath/engines/opengl_engine/Camera.hpp"
|
||||||
#include "omath/engines/OpenGL/Formulas.hpp"
|
#include "omath/engines/opengl_engine/Formulas.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace omath::opengl
|
namespace omath::opengl_engine
|
||||||
{
|
{
|
||||||
|
|
||||||
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||||
@@ -25,7 +25,7 @@ namespace omath::opengl
|
|||||||
}
|
}
|
||||||
Mat4x4 Camera::CalcViewMatrix() const
|
Mat4x4 Camera::CalcViewMatrix() const
|
||||||
{
|
{
|
||||||
return opengl::CalcViewMatrix(m_viewAngles, m_origin);
|
return opengl_engine::CalcViewMatrix(m_viewAngles, m_origin);
|
||||||
}
|
}
|
||||||
Mat4x4 Camera::CalcProjectionMatrix() const
|
Mat4x4 Camera::CalcProjectionMatrix() const
|
||||||
{
|
{
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
//
|
//
|
||||||
// Created by Orange on 12/4/2024.
|
// Created by Orange on 12/4/2024.
|
||||||
//
|
//
|
||||||
#include "omath/engines/Source/Camera.hpp"
|
#include "omath/engines/source_engine/Camera.hpp"
|
||||||
#include "omath/engines/Source/Formulas.hpp"
|
#include "omath/engines/source_engine/Formulas.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace omath::source
|
namespace omath::source_engine
|
||||||
{
|
{
|
||||||
|
|
||||||
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
Camera::Camera(const Vector3<float>& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
|
||||||
@@ -26,7 +26,7 @@ namespace omath::source
|
|||||||
|
|
||||||
Mat4x4 Camera::CalcViewMatrix() const
|
Mat4x4 Camera::CalcViewMatrix() const
|
||||||
{
|
{
|
||||||
return source::CalcViewMatrix(m_viewAngles, m_origin);
|
return source_engine::CalcViewMatrix(m_viewAngles, m_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat4x4 Camera::CalcProjectionMatrix() const
|
Mat4x4 Camera::CalcProjectionMatrix() const
|
||||||
@@ -4,15 +4,15 @@
|
|||||||
|
|
||||||
#include "omath/projectile_prediction/Projectile.hpp"
|
#include "omath/projectile_prediction/Projectile.hpp"
|
||||||
|
|
||||||
#include <omath/engines/Source/Formulas.hpp>
|
#include <omath/engines/source_engine/Formulas.hpp>
|
||||||
|
|
||||||
namespace omath::projectile_prediction
|
namespace omath::projectile_prediction
|
||||||
{
|
{
|
||||||
Vector3<float> Projectile::PredictPosition(const float pitch, const float yaw, const float time, const float gravity) const
|
Vector3<float> Projectile::PredictPosition(const float pitch, const float yaw, const float time, const float gravity) const
|
||||||
{
|
{
|
||||||
auto currentPos = m_origin + source::ForwardVector({source::PitchAngle::FromDegrees(-pitch),
|
auto currentPos = m_origin + source_engine::ForwardVector({source_engine::PitchAngle::FromDegrees(-pitch),
|
||||||
source::YawAngle::FromDegrees(yaw),
|
source_engine::YawAngle::FromDegrees(yaw),
|
||||||
source::RollAngle::FromDegrees(0)}) *
|
source_engine::RollAngle::FromDegrees(0)}) *
|
||||||
m_launchSpeed * time;
|
m_launchSpeed * time;
|
||||||
currentPos.z -= (gravity * m_gravityScale) * (time * time) * 0.5f;
|
currentPos.z -= (gravity * m_gravityScale) * (time * time) * 0.5f;
|
||||||
|
|
||||||
|
|||||||
@@ -2,35 +2,35 @@
|
|||||||
// Created by Orange on 11/23/2024.
|
// Created by Orange on 11/23/2024.
|
||||||
//
|
//
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <omath/engines/OpenGL/Camera.hpp>
|
#include <omath/engines/opengl_engine//Camera.hpp>
|
||||||
#include <omath/engines/OpenGL/Constants.hpp>
|
#include <omath/engines/opengl_engine/Constants.hpp>
|
||||||
#include <omath/engines/OpenGL/Formulas.hpp>
|
#include <omath/engines/opengl_engine/Formulas.hpp>
|
||||||
|
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, ForwardVector)
|
TEST(UnitTestOpenGL, ForwardVector)
|
||||||
{
|
{
|
||||||
const auto forward = omath::opengl::ForwardVector({});
|
const auto forward = omath::opengl_engine::ForwardVector({});
|
||||||
|
|
||||||
EXPECT_EQ(forward, omath::opengl::kAbsForward);
|
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, RightVector)
|
TEST(UnitTestOpenGL, RightVector)
|
||||||
{
|
{
|
||||||
const auto right = omath::opengl::RightVector({});
|
const auto right = omath::opengl_engine::RightVector({});
|
||||||
|
|
||||||
EXPECT_EQ(right, omath::opengl::kAbsRight);
|
EXPECT_EQ(right, omath::opengl_engine::kAbsRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, UpVector)
|
TEST(UnitTestOpenGL, UpVector)
|
||||||
{
|
{
|
||||||
const auto up = omath::opengl::UpVector({});
|
const auto up = omath::opengl_engine::UpVector({});
|
||||||
EXPECT_EQ(up, omath::opengl::kAbsUp);
|
EXPECT_EQ(up, omath::opengl_engine::kAbsUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
const auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
|
|
||||||
for (float distance = -10.f; distance > -1000.f; distance -= 0.01f)
|
for (float distance = -10.f; distance > -1000.f; distance -= 0.01f)
|
||||||
@@ -50,7 +50,7 @@ TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
|||||||
TEST(UnitTestOpenGL, CameraSetAndGetFov)
|
TEST(UnitTestOpenGL, CameraSetAndGetFov)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
||||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||||
@@ -60,7 +60,7 @@ TEST(UnitTestOpenGL, CameraSetAndGetFov)
|
|||||||
|
|
||||||
TEST(UnitTestOpenGL, CameraSetAndGetOrigin)
|
TEST(UnitTestOpenGL, CameraSetAndGetOrigin)
|
||||||
{
|
{
|
||||||
auto cam = omath::opengl::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
||||||
|
|
||||||
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
|
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
|
||||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||||
|
|||||||
@@ -2,35 +2,35 @@
|
|||||||
// Created by Orange on 11/23/2024.
|
// Created by Orange on 11/23/2024.
|
||||||
//
|
//
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <omath/engines/Source/Camera.hpp>
|
#include <omath/engines/source_engine/Camera.hpp>
|
||||||
#include <omath/engines/Source/Constants.hpp>
|
#include <omath/engines/source_engine/Constants.hpp>
|
||||||
#include <omath/engines/Source/Formulas.hpp>
|
#include <omath/engines/source_engine/Formulas.hpp>
|
||||||
|
|
||||||
|
|
||||||
TEST(UnitTestSourceEngine, ForwardVector)
|
TEST(UnitTestSourceEngine, ForwardVector)
|
||||||
{
|
{
|
||||||
const auto forward = omath::source::ForwardVector({});
|
const auto forward = omath::source_engine::ForwardVector({});
|
||||||
|
|
||||||
EXPECT_EQ(forward, omath::source::kAbsForward);
|
EXPECT_EQ(forward, omath::source_engine::kAbsForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestSourceEngine, RightVector)
|
TEST(UnitTestSourceEngine, RightVector)
|
||||||
{
|
{
|
||||||
const auto right = omath::source::RightVector({});
|
const auto right = omath::source_engine::RightVector({});
|
||||||
|
|
||||||
EXPECT_EQ(right, omath::source::kAbsRight);
|
EXPECT_EQ(right, omath::source_engine::kAbsRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestSourceEngine, UpVector)
|
TEST(UnitTestSourceEngine, UpVector)
|
||||||
{
|
{
|
||||||
const auto up = omath::source::UpVector({});
|
const auto up = omath::source_engine::UpVector({});
|
||||||
EXPECT_EQ(up, omath::source::kAbsUp);
|
EXPECT_EQ(up, omath::source_engine::kAbsUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
const auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
|
|
||||||
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
||||||
@@ -50,7 +50,7 @@ TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
|||||||
TEST(UnitTestSourceEngine, CameraSetAndGetFov)
|
TEST(UnitTestSourceEngine, CameraSetAndGetFov)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
||||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||||
@@ -60,7 +60,7 @@ TEST(UnitTestSourceEngine, CameraSetAndGetFov)
|
|||||||
|
|
||||||
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
|
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
|
||||||
{
|
{
|
||||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
||||||
|
|
||||||
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
|
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
|
||||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
#include <complex>
|
#include <complex>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <omath/Matrix.hpp>
|
#include <omath/engines/source_engine/Camera.hpp>
|
||||||
#include <omath/engines/Source/Camera.hpp>
|
|
||||||
#include <omath/projection/Camera.hpp>
|
#include <omath/projection/Camera.hpp>
|
||||||
#include <print>
|
#include <print>
|
||||||
|
|
||||||
TEST(UnitTestProjection, Projection)
|
TEST(UnitTestProjection, Projection)
|
||||||
{
|
{
|
||||||
const auto x = omath::Angle<float, 0.f, 180.f, omath::AngleFlags::Clamped>::FromDegrees(90.f);
|
const auto x = omath::Angle<float, 0.f, 180.f, omath::AngleFlags::Clamped>::FromDegrees(90.f);
|
||||||
auto cam = omath::source::Camera({0, 0, 0}, omath::source::ViewAngles{}, {1920.f, 1080.f}, x, 0.01f, 1000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, omath::source_engine::ViewAngles{}, {1920.f, 1080.f}, x, 0.01f, 1000.f);
|
||||||
|
|
||||||
const auto projected = cam.WorldToScreen({1000, 0, 50});
|
const auto projected = cam.WorldToScreen({1000, 0, 50});
|
||||||
std::print("{} {} {}", projected->x, projected->y, projected->z);
|
std::print("{} {} {}", projected->x, projected->y, projected->z);
|
||||||
|
|||||||
Reference in New Issue
Block a user