26 constexpr Mat4() noexcept {
43 for (
int i = 0; i < 16; i++) result.
m_fElements[i] = 0.0f;
55 for (
int col = 0; col < 4; ++col) {
56 for (
int row = 0; row < 4; ++row) {
58 for (
int k = 0; k < 4; ++k) {
77 static Mat4 Perspective(
float fov,
float aspect,
float nearplane,
float farplane) {
79 float tanHalfFOV = std::tan(fov * 3.1415926535f * 0.5f / 180.0f);
82 result.
m_fElements[0] = 1.0f / (aspect * tanHalfFOV);
88 result.
m_fElements[10] = -(farplane + nearplane) / (farplane - nearplane);
95 result.
m_fElements[14] = -(2.0f * farplane * nearplane) / (farplane - nearplane);
108 Vec3 fwd = (tgt - eye).normalize();
137 float left,
float right,
float bottom,
float top,
float nearplane,
float farplane) {
142 result.
m_fElements[10] = -2.0f / (farplane - nearplane);
144 result.
m_fElements[12] = -(right + left) / (right - left);
145 result.
m_fElements[13] = -(top + bottom) / (top - bottom);
146 result.
m_fElements[14] = -(farplane + nearplane) / (farplane - nearplane);
159 static Mat4 Scale(
float scaleX,
float scaleY,
float scaleZ) {
A 4x4 Matrix structure stored in Column-Major order (OpenGL Standard).
Definition Matrix.h:18
static Mat4 LookAt(const Vec3 &eye, const Vec3 &tgt, const Vec3 &up)
Creates a View Matrix using Eye, Target, and Up vectors.
Definition Matrix.h:106
float m_fElements[16]
Definition Matrix.h:19
static Mat4 Perspective(float fov, float aspect, float nearplane, float farplane)
Creates a Perspective Projection Matrix (FOV Y).
Definition Matrix.h:77
static Mat4 Zero()
Definition Matrix.h:40
constexpr Mat4() noexcept
Default constructor initializes to Identity Matrix.
Definition Matrix.h:26
static Mat4 Translation(const Vec3 &translation)
Definition Matrix.h:151
static Mat4 Scale(float scaleX, float scaleY, float scaleZ)
Definition Matrix.h:159
static Mat4 Orthographic(float left, float right, float bottom, float top, float nearplane, float farplane)
Definition Matrix.h:136
Mat4 operator*(const Mat4 &other) const
Matrix Multiplication.
Definition Matrix.h:53
static Mat4 Identity()
Definition Matrix.h:37
A 3-component vector structure (x, y, z) with standard math operations.
Definition MathUtils.h:11
float x
Definition MathUtils.h:12
constexpr float dot(const Vec3 &other) const noexcept
Definition MathUtils.h:68
float z
Definition MathUtils.h:12
constexpr Vec3 cross(const Vec3 &other) const noexcept
Definition MathUtils.h:71
Vec3 normalize() const
Definition MathUtils.h:51
float y
Definition MathUtils.h:12