Week5 [26/10]

Added the Z Access to the Matrix class
Added the Identity Matrix Method to the Matrix Class
Added MD2Loader Class
Added Model Class
Added Polygon Class
Added Clear Viewport Method to Rasterizer
Added Z Axis to the Vertex Class
Updated Transformation Matrices to pass a matrix back so that we can do the multiplication at once
This commit is contained in:
IDunnoDev
2021-12-11 13:24:09 +00:00
committed by iDunnoDev
parent 7c62126ede
commit 3b374c1e17
15 changed files with 432 additions and 52 deletions

View File

@ -119,12 +119,31 @@ const Vertex Matrix::operator*(const Vertex& other) const
{
Vertex newVertex(other);
newVertex.SetX(_matrix[0][0] * other.GetX() + _matrix[0][1] * other.GetY() + _matrix[0][2] * other.GetW());
newVertex.SetY(_matrix[1][0] * other.GetX() + _matrix[1][1] * other.GetY() + _matrix[1][2] * other.GetW());
newVertex.SetW(_matrix[2][0] * other.GetX() + _matrix[2][1] * other.GetY() + _matrix[2][2] * other.GetW());
newVertex.SetX(_matrix[0][0] * other.GetX() + _matrix[0][1] * other.GetY() + _matrix[0][2] * other.GetZ() + _matrix[0][3] * other.GetW());
newVertex.SetY(_matrix[1][0] * other.GetX() + _matrix[1][1] * other.GetY() + _matrix[1][2] * other.GetZ() + _matrix[1][3] * other.GetW());
newVertex.SetZ(_matrix[2][0] * other.GetX() + _matrix[2][1] * other.GetY() + _matrix[2][2] * other.GetZ() + _matrix[2][3] * other.GetW());
newVertex.SetW(_matrix[3][0] * other.GetX() + _matrix[3][1] * other.GetY() + _matrix[3][2] * other.GetZ() + _matrix[3][3] * other.GetW());
return newVertex;
}
Matrix Matrix::IdentityMatrix()
{
for (int i = 0; i < ROWS; i++)
{
for (int j = 0; j < COLS; j++)
{
float currentValue = 0.0f;
if (j == i)
{
currentValue = 1.0f;
}
_matrix[i][j] = currentValue;
}
}
return _matrix;
}
void Matrix::Copy(const Matrix& other)
{
for (int i = 0; i < ROWS; i++)