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

@ -4,21 +4,29 @@ Vertex::Vertex()
{
_x = 0.0f;
_y = 0.0f;
_z = 0.0f;
_w = 0.0f;
}
Vertex::Vertex(float x, float y, float w)
Vertex::Vertex(const float x, const float y, const float z)
{
_x = x;
_y = y;
_z = z;
_w = 1.0f;
}
Vertex::Vertex(const float x, const float y, const float z, const float w)
{
_x = x;
_y = y;
_z = z;
_w = w;
}
Vertex::Vertex(const Vertex & other)
{
_x = other.GetX();
_y = other.GetY();
_w = other.GetW();
Copy(other);
}
float Vertex::GetX() const
@ -41,6 +49,16 @@ void Vertex::SetY(const float y)
_y = y;
}
float Vertex::GetZ() const
{
return _z;
}
void Vertex::SetZ(const float z)
{
_z = z;
}
float Vertex::GetW() const
{
return _w;
@ -57,9 +75,7 @@ Vertex& Vertex::operator=(const Vertex& rhs)
// to ourselves
if (this != &rhs)
{
_x = rhs.GetX();
_y = rhs.GetY();
_w = rhs.GetW();
Copy(rhs);
}
return *this;
}
@ -69,7 +85,7 @@ Vertex& Vertex::operator=(const Vertex& rhs)
bool Vertex::operator==(const Vertex& rhs) const
{
return (_x == rhs.GetX() && _y == rhs.GetY() && _w == rhs.GetW());
return (_x == rhs.GetX() && _y == rhs.GetY() && _z == rhs.GetZ() && _w == rhs.GetW());
}
// You can see three different uses of 'const' here:
@ -80,5 +96,13 @@ bool Vertex::operator==(const Vertex& rhs) const
const Vertex Vertex::operator+(const Vertex& rhs) const
{
return Vertex(_x + rhs.GetX(), _y + rhs.GetY(), _w + rhs.GetW());
return Vertex(_x + rhs.GetX(), _y + rhs.GetY(), _z + rhs.GetZ(), _w + rhs.GetW());
}
void Vertex::Copy(const Vertex& other)
{
_x = other.GetX();
_y = other.GetY();
_z = other.GetZ();
_w = other.GetW();
}