From c9874f30d047ec16bde263e9d078660cef9e9b65 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 18 Feb 2026 08:15:18 +0300 Subject: [PATCH 01/10] add --- .../omath/engines/cry_engine/constants.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 include/omath/engines/cry_engine/constants.hpp diff --git a/include/omath/engines/cry_engine/constants.hpp b/include/omath/engines/cry_engine/constants.hpp new file mode 100644 index 00000000..70293ade --- /dev/null +++ b/include/omath/engines/cry_engine/constants.hpp @@ -0,0 +1,25 @@ +// +// Created by Vlad on 10/21/2025. +// + +#pragma once +#include "omath/linear_algebra/mat.hpp" +#include "omath/linear_algebra/vector3.hpp" +#include +#include + +namespace omath::cry_engine +{ + constexpr Vector3 k_abs_up = {0, 0, 1}; + constexpr Vector3 k_abs_right = {1, 0, 0}; + constexpr Vector3 k_abs_forward = {0, 1, 0}; + + using Mat4X4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>; + using Mat3X3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>; + using Mat1X3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>; + using PitchAngle = Angle; + using YawAngle = Angle; + using RollAngle = Angle; + + using ViewAngles = omath::ViewAngles; +} // namespace omath::frostbite_engine \ No newline at end of file From d0f3e5059a797832108d7bb8c05fee0cbc1cf338 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 18 Feb 2026 08:20:38 +0300 Subject: [PATCH 02/10] added formulas --- include/omath/engines/cry_engine/formulas.hpp | 74 +++++++++++++++++++ source/engines/cry_engine/formulas.cpp | 42 +++++++++++ 2 files changed, 116 insertions(+) create mode 100644 include/omath/engines/cry_engine/formulas.hpp create mode 100644 source/engines/cry_engine/formulas.cpp diff --git a/include/omath/engines/cry_engine/formulas.hpp b/include/omath/engines/cry_engine/formulas.hpp new file mode 100644 index 00000000..46c2b765 --- /dev/null +++ b/include/omath/engines/cry_engine/formulas.hpp @@ -0,0 +1,74 @@ +// +// Created by Vlad on 3/22/2025. +// + +#pragma once +#include "omath/engines/cry_engine/constants.hpp" + +namespace omath::cry_engine +{ + [[nodiscard]] + Vector3 forward_vector(const ViewAngles& angles) noexcept; + + [[nodiscard]] + Vector3 right_vector(const ViewAngles& angles) noexcept; + + [[nodiscard]] + Vector3 up_vector(const ViewAngles& angles) noexcept; + + [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept; + + [[nodiscard]] + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; + + [[nodiscard]] + Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept; + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType units_to_centimeters(const FloatingType& units) + { + return units / static_cast(100); + } + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType units_to_meters(const FloatingType& units) + { + return units; + } + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType units_to_kilometers(const FloatingType& units) + { + return units_to_meters(units) / static_cast(1000); + } + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) + { + return centimeters * static_cast(100); + } + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType meters_to_units(const FloatingType& meters) + { + return meters; + } + + template + requires std::is_floating_point_v + [[nodiscard]] + constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) + { + return meters_to_units(kilometers * static_cast(1000)); + } +} // namespace omath::frostbite_engine diff --git a/source/engines/cry_engine/formulas.cpp b/source/engines/cry_engine/formulas.cpp new file mode 100644 index 00000000..14ad0491 --- /dev/null +++ b/source/engines/cry_engine/formulas.cpp @@ -0,0 +1,42 @@ +// +// Created by Vlad on 3/22/2025. +// +#include "omath/engines/cry_engine/formulas.hpp" + +namespace omath::cry_engine +{ + Vector3 forward_vector(const ViewAngles& angles) noexcept + { + const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); + + return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; + } + Vector3 right_vector(const ViewAngles& angles) noexcept + { + const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); + + return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; + } + Vector3 up_vector(const ViewAngles& angles) noexcept + { + const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); + + return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; + } + Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept + { + return mat_camera_view(forward_vector(angles), right_vector(angles), + up_vector(angles), cam_origin); + } + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept + { + return mat_rotation_axis_z(angles.roll) + * mat_rotation_axis_y(angles.yaw) + * mat_rotation_axis_x(angles.pitch); + } + Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, + const float far) noexcept + { + return mat_perspective_left_handed(field_of_view, aspect_ratio, near, far); + } +} // namespace omath::unity_engine From 49319a1c7c91845c2b4286593b7a50e3c451be37 Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 19 Feb 2026 00:54:59 +0300 Subject: [PATCH 03/10] added more files --- .idea/editor.xml | 4 +- include/omath/engines/cry_engine/camera.hpp | 13 ++++ .../cry_engine/traits/camera_trait.hpp | 24 ++++++ .../cry_engine/traits/pred_engine_trait.hpp | 76 +++++++++++++++++++ source/engines/cry_engine/camera_trait.cpp | 26 +++++++ 5 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 include/omath/engines/cry_engine/camera.hpp create mode 100644 include/omath/engines/cry_engine/traits/camera_trait.hpp create mode 100644 include/omath/engines/cry_engine/traits/pred_engine_trait.hpp create mode 100644 source/engines/cry_engine/camera_trait.cpp diff --git a/.idea/editor.xml b/.idea/editor.xml index 2eff1aff..bce786e3 100644 --- a/.idea/editor.xml +++ b/.idea/editor.xml @@ -17,7 +17,7 @@