Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
|
#include <Matrix4x4.h>
Public Member Functions | |
Matrix4x4 () | |
Matrix4x4 (const float r11, const float r12, const float r13, const float r14, const float r21, const float r22, const float r23, const float r24, const float r31, const float r32, const float r33, const float r34, const float r41, const float r42, const float r43, const float r44) | |
void | Add (const Matrix4x4 &m1, const Matrix4x4 &m2) |
void | Subtract (const Matrix4x4 &m1, const Matrix4x4 &m2) |
void | Multiple (const Matrix4x4 &m1, const Matrix4x4 &m2) |
void | operator= (const Matrix4x4 &m) |
Matrix4x4 | operator- (const Matrix4x4 &m) const |
Matrix4x4 | operator+ (const Matrix4x4 &m) const |
Matrix4x4 | operator* (const Matrix4x4 &m) const |
void | Identity () |
void | Zero () |
void | Translate (const Vector3D &v) |
void | Translate (const float x, const float y, const float z) |
Vector3D | InverseTranslateVector (const Vector3D &v) const |
bool | InverseMatrix (const Matrix4x4 &m) |
void | InvertMatrix (const Matrix4x4 &m) |
Vector3D | VectorMatrixMultiply (const Vector3D &v) const |
Vector3D | VectorMatrixMultiply3x3 (const Vector3D &v) const |
Vector3D | VectorMatrixMultiply3x3Inv (const Vector3D &v) const |
void | Transpose (const Matrix4x4 &m) |
void | Scale (const Vector3D &scale) |
void | SetRotationRadians (const float x, const float y, const float z) |
void | Rotate (const float angleDegrees, const int x, const int y, const int z) |
void | RotateAxis (const float angleDegrees, const Vector3D &axis) |
void | RotateX (const float angleDegrees) |
void | RotateY (const float angleDegrees) |
void | RotateZ (const float angleDegrees) |
void | CreateViewMatrix (const Vector3D &pos, const Vector3D &dir, const Vector3D &up, const Vector3D &right) |
Public Attributes | |
float | matrix [16] |
Matrix with 4 rows and 4 columns.
Ult::Matrix4x4::Matrix4x4 | ( | ) |
Matrix4x4 constructor. Defaults values to an identity matrix.
Ult::Matrix4x4::Matrix4x4 | ( | const float | r11, |
const float | r12, | ||
const float | r13, | ||
const float | r14, | ||
const float | r21, | ||
const float | r22, | ||
const float | r23, | ||
const float | r24, | ||
const float | r31, | ||
const float | r32, | ||
const float | r33, | ||
const float | r34, | ||
const float | r41, | ||
const float | r42, | ||
const float | r43, | ||
const float | r44 ) |
Matrix4x4 constructor from 16 float values. Stores each value into the 'matrix' array consecutively.
Adds m1 and m2 element-wise and stores the result in this matrix.
void Ult::Matrix4x4::CreateViewMatrix | ( | const Vector3D & | pos, |
const Vector3D & | dir, | ||
const Vector3D & | up, | ||
const Vector3D & | right ) |
Make this a view matrix using camera position, forward view direction, and right vector.
void Ult::Matrix4x4::Identity | ( | ) |
Sets the values of the matrix to an identity matrix.
bool Ult::Matrix4x4::InverseMatrix | ( | const Matrix4x4 & | m | ) |
Attempts to set this matrix as the inverse of m. If fails (determinant of m is 0), sets the matrix to an identity and returns false.
Returns this matrix's translation vector minus v.
void Ult::Matrix4x4::InvertMatrix | ( | const Matrix4x4 & | m | ) |
Sets this matrix as the inverse of m. Transposes the rotational component and negates the translation component.
Multiplies m1 and m2 and stores the result in this matrix.
Multiplies this matrix and m and returns the result.
Adds this matrix and m element-wise and returns the result.
Subtracts this matrix and m element-wise and returns the result.
void Ult::Matrix4x4::operator= | ( | const Matrix4x4 & | m | ) |
Sets the values of this matrix equal to the values of m.
void Ult::Matrix4x4::Rotate | ( | const float | angleDegrees, |
const int | x, | ||
const int | y, | ||
const int | z ) |
Make this a rotation matrix using an axis and angle in degrees.
void Ult::Matrix4x4::RotateAxis | ( | const float | angleDegrees, |
const Vector3D & | axis ) |
Make this a rotation matrix using an axis and angle in degrees.
void Ult::Matrix4x4::RotateX | ( | const float | angleDegrees | ) |
Make this a x-axis rotation matrix using an angle in degrees.
void Ult::Matrix4x4::RotateY | ( | const float | angleDegrees | ) |
Make this a y-axis rotation matrix using an angle in degrees.
void Ult::Matrix4x4::RotateZ | ( | const float | angleDegrees | ) |
Make this a z-axis rotation matrix using an angle in degrees.
void Ult::Matrix4x4::Scale | ( | const Vector3D & | scale | ) |
Sets the scale components (3 main diagonals of the matrix) equal to 'scale'.
void Ult::Matrix4x4::SetRotationRadians | ( | const float | x, |
const float | y, | ||
const float | z ) |
Make this a rotation matrix using 3 radian euler angles for x,y,z.
Subtracts m1 and m2 element-wise and stores the result in this matrix.
void Ult::Matrix4x4::Translate | ( | const float | x, |
const float | y, | ||
const float | z ) |
Sets elements 12,13,14 to x,y,z and element 15 to 1.
void Ult::Matrix4x4::Translate | ( | const Vector3D & | v | ) |
Sets elements 12,13,14 to v and element 15 to 1.
void Ult::Matrix4x4::Transpose | ( | const Matrix4x4 & | m | ) |
Sets the values of this matrix as the transpose of m.
Returns the multiplication of the matrix and v, assuming a w component of 1.
Returns the multiplication of the 3x3 rotational component of the matrix and v.
Returns the multiplication of the 3x3 rotational component transpose of the matrix and v.
void Ult::Matrix4x4::Zero | ( | ) |
Sets the values of the matrix to all zeros.
float Ult::Matrix4x4::matrix[16] |
The 16 matrix values.