mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added debug methods
This commit is contained in:
@@ -18,9 +18,12 @@ namespace omath::projection
|
|||||||
Camera(const Vector3& position, const Vector3& viewAngles, const Vector3& viewPort, float fov, float near, float far);
|
Camera(const Vector3& position, const Vector3& viewAngles, const Vector3& viewPort, float fov, float near, float far);
|
||||||
void SetViewAngles(const Vector3& viewAngles);
|
void SetViewAngles(const Vector3& viewAngles);
|
||||||
[[nodiscard]] const Vector3& GetViewAngles() const;
|
[[nodiscard]] const Vector3& GetViewAngles() const;
|
||||||
|
static float& GetFloat1();
|
||||||
|
|
||||||
|
static float& GetFloat2();
|
||||||
|
|
||||||
[[nodiscard]] Matrix GetViewMatrix() const;
|
[[nodiscard]] Matrix GetViewMatrix() const;
|
||||||
[[nodiscard]] Matrix GetProjectionMatrix() const;
|
[[nodiscard]] Matrix GetProjectionMatrix(float scaleX, float scaleY) const;
|
||||||
[[nodiscard]] Matrix GetTranslationMatrix() const;
|
[[nodiscard]] Matrix GetTranslationMatrix() const;
|
||||||
[[nodiscard]] Matrix GetOrientationMatrix() const;
|
[[nodiscard]] Matrix GetOrientationMatrix() const;
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,22 @@ namespace omath::projection
|
|||||||
m_farPlaneDistance = far;
|
m_farPlaneDistance = far;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float & Camera::GetFloat1() {
|
||||||
|
static float m_float1 = 1.52550f;
|
||||||
|
return m_float1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float & Camera::GetFloat2() {
|
||||||
|
static float m_float2 = 1.14500f;
|
||||||
|
return m_float2;
|
||||||
|
}
|
||||||
|
|
||||||
Matrix Camera::GetViewMatrix() const
|
Matrix Camera::GetViewMatrix() const
|
||||||
{
|
{
|
||||||
return GetTranslationMatrix() * GetOrientationMatrix();
|
return GetTranslationMatrix() * GetOrientationMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix Camera::GetProjectionMatrix() const
|
Matrix Camera::GetProjectionMatrix(const float scaleX, const float scaleY) const
|
||||||
{
|
{
|
||||||
const float fRight = std::tan(angles::DegreesToRadians(m_fieldOfView) / 2.f);
|
const float fRight = std::tan(angles::DegreesToRadians(m_fieldOfView) / 2.f);
|
||||||
const float fLeft = -fRight;
|
const float fLeft = -fRight;
|
||||||
@@ -40,8 +50,8 @@ namespace omath::projection
|
|||||||
const auto near = m_nearPlaneDistance;
|
const auto near = m_nearPlaneDistance;
|
||||||
|
|
||||||
return Matrix({
|
return Matrix({
|
||||||
{1.555f / (fRight - fLeft), 0.f, 0.f, 0.f},
|
{scaleX / (fRight - fLeft), 0.f, 0.f, 0.f},
|
||||||
{0.f, 1.15f / (top - botton), 0.f, 0.f},
|
{0.f, scaleY / (top - botton), 0.f, 0.f},
|
||||||
{0.f, 0.f, (far + near) / (far - near), 1.f},
|
{0.f, 0.f, (far + near) / (far - near), 1.f},
|
||||||
{0.f, 0.f, -near * far / (far - near), 0.f},
|
{0.f, 0.f, -near * far / (far - near), 0.f},
|
||||||
});
|
});
|
||||||
@@ -78,7 +88,7 @@ namespace omath::projection
|
|||||||
{
|
{
|
||||||
const auto posVecAsMatrix = Matrix({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}});
|
const auto posVecAsMatrix = Matrix({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}});
|
||||||
|
|
||||||
const auto viewProjectionMatrix = GetViewMatrix() * GetProjectionMatrix();
|
const auto viewProjectionMatrix = GetViewMatrix() * GetProjectionMatrix(GetFloat1(), GetFloat2());
|
||||||
|
|
||||||
auto projected = posVecAsMatrix * viewProjectionMatrix;
|
auto projected = posVecAsMatrix * viewProjectionMatrix;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user