added files

This commit is contained in:
2024-11-27 15:21:07 +03:00
parent a25aef049e
commit 6e5f2331ad
10 changed files with 125 additions and 7 deletions

View File

@@ -0,0 +1,35 @@
//
// Created by Orange on 11/23/2024.
//
#pragma once
#include "omath/Vector3.hpp"
#include "omath/Mat.hpp"
namespace omath::opengl
{
constexpr Vector3 kAbsUp = {0, 1, 0};
constexpr Vector3 kAbsRight = {1, 0, 0};
constexpr Vector3 kAbsForward = {0, 0, -1};
template<class Type> requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix()
{
}
template<class Type> requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix(
const float fieldOfView, const Type &aspectRatio, const Type &near, const Type &far)
{
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2);
return
{
{static_cast<Type>(1) / (aspectRatio * fovHalfTan), 0, 0, 0},
{0, static_cast<Type>(1) / (fovHalfTan), 0, 0},
{0, 0, -(far + near) / (far - near), -(static_cast<Type>(2) * far * near) / (far - near)},
{0, 0, -1, 0},
};
}
}

View File

@@ -0,0 +1,28 @@
//
// Created by Orange on 11/24/2024.
//
#pragma once
namespace omath::source
{
constexpr Vector3 kAbsUp = {0, 0, 1};
constexpr Vector3 kAbsRight = {0, -1, 0};
constexpr Vector3 kAbsForward = {1, 0, 0};
template<class Type> requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix(
const float fieldOfView, const Type &aspectRatio, const Type &near, const Type &far)
{
const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2);
return
{
{static_cast<Type>(1) / (aspectRatio * fovHalfTan), 0, 0, 0},
{0, static_cast<Type>(1) / (fovHalfTan), 0, 0},
{0, 0, (far + near) / (far - near), -(static_cast<Type>(2) * far * near) / (far - near)},
{0, 0, 1, 0},
};
}
}