Week12 [14/12]

Added UVCheck texture file
Added UV perspective Variables to the Vertex Class
Added Texture Draw method to the Rasteriser
This commit is contained in:
IDunnoDev
2021-12-14 13:50:09 +00:00
committed by iDunnoDev
parent cdb940f6aa
commit eeea920e45
4 changed files with 161 additions and 56 deletions

View File

@ -11,6 +11,11 @@ Vertex::Vertex()
_r = 0;
_g = 0;
_b = 0;
_uvIndex = -1;
_zOriginal = 0;
_uOverZ = 0;
_vOverZ = 0;
_zRecip = 0;
}
Vertex::Vertex(const float x, const float y, const float z)
@ -24,6 +29,11 @@ Vertex::Vertex(const float x, const float y, const float z)
_r = 0;
_g = 0;
_b = 0;
_uvIndex = -1;
_zOriginal = 0;
_uOverZ = 0;
_vOverZ = 0;
_zRecip = 0;
}
Vertex::Vertex(const float x, const float y, const float z, const float w)
@ -37,6 +47,11 @@ Vertex::Vertex(const float x, const float y, const float z, const float w)
_r = 0;
_g = 0;
_b = 0;
_uvIndex = -1;
_zOriginal = 0;
_uOverZ = 0;
_vOverZ = 0;
_zRecip = 0;
}
Vertex::Vertex(const Vertex & other)
@ -187,6 +202,44 @@ void Vertex::SetUVIndex(const int index)
_uvIndex = index;
}
float Vertex::GetZOriginal() const
{
return _zOriginal;
}
float Vertex::GetUOverZ() const
{
return _uOverZ;
}
void Vertex::SetUOverZ(const float value)
{
_uOverZ = value / _zOriginal;
}
float Vertex::GetVOverZ() const
{
return _vOverZ;
}
void Vertex::SetVOverZ(const float value)
{
_vOverZ = value / _zOriginal;
}
float Vertex::GetZRecip() const
{
return _zRecip;
}
void Vertex::UVCorrect(float u, float v)
{
_zOriginal = _w;
_zRecip = 1 / _zOriginal;
SetUOverZ(u);
SetVOverZ(v);
}
int Vertex::GetXInt(bool forceRoundUp) const
{
if (forceRoundUp)
@ -236,7 +289,7 @@ int Vertex::GetWInt(bool forceRoundUp) const
}
void Vertex::Dehomogenize()
{
{
_x = _x / _w;
_y = _y / _w;
_z = _z / _w;
@ -293,4 +346,9 @@ void Vertex::Copy(const Vertex& other)
_b = other.GetB();
_uvIndex = other.GetUVIndex();
_zOriginal = other.GetZOriginal();
_uOverZ = other.GetUOverZ();
_vOverZ = other.GetVOverZ();
_zRecip = other.GetZRecip();
}