Week10 [30/11] - [06/12]
Added active Variable to the Lights Classes Added updated MD2Loader Class Added Model Filename and Texture File Name to the Model Class Added Active Flag to the Model Class Added DrawMode to the Model Class Added Texture and UV Variables to the Model Class Added UV Coordinates to the Polygon3D Class Added DrawString method to the Rasterizer to write text to the screen space Added Interpolate and Lerp Methods to the Rasterizer Added Select statement for drawing a current models draw mode Added DrawTextured Method to the Rasterizer Class Added UVCoord Class Added Texture Class Added = operator to the Vector3D Class Added UVCoord to the Vertex Class Moved Models and Texture Files into a subfolder Fixed issue with textures not loading properly because of the vector address problem
This commit is contained in:
@ -1,19 +1,30 @@
|
||||
#include "Polygon3D.h"
|
||||
|
||||
Polygon3D::Polygon3D() : _indices{ 0 }
|
||||
Polygon3D::Polygon3D() : _indices{ 0 }, _uvIndices { 0 }
|
||||
{
|
||||
_depth = 0.0f;
|
||||
_color = RGB(0, 0, 0);
|
||||
_r = 0;
|
||||
_g = 0;
|
||||
_b = 0;
|
||||
_culled = false;
|
||||
}
|
||||
|
||||
Polygon3D::Polygon3D(int index0, int index1, int index2)
|
||||
Polygon3D::Polygon3D(int index0, int index1, int index2, int uvIndex0, int uvIndex1, int uvIndex2)
|
||||
{
|
||||
_indices[0] = index0;
|
||||
_indices[1] = index1;
|
||||
_indices[2] = index2;
|
||||
|
||||
_uvIndices[0] = uvIndex0;
|
||||
_uvIndices[1] = uvIndex1;
|
||||
_uvIndices[2] = uvIndex2;
|
||||
|
||||
_depth = 0.0f;
|
||||
_color = RGB(0, 0, 0);
|
||||
|
||||
_r = 0;
|
||||
_g = 0;
|
||||
_b = 0;
|
||||
|
||||
_culled = false;
|
||||
}
|
||||
|
||||
@ -24,6 +35,7 @@ Polygon3D::Polygon3D(const Polygon3D& other)
|
||||
|
||||
Polygon3D::~Polygon3D()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
size_t Polygon3D::GetPolygonVertexCount() const
|
||||
@ -31,11 +43,21 @@ size_t Polygon3D::GetPolygonVertexCount() const
|
||||
return sizeof(_indices) / sizeof(_indices[0]);
|
||||
}
|
||||
|
||||
size_t Polygon3D::GetPolygonUVCount() const
|
||||
{
|
||||
return sizeof(_uvIndices) / sizeof(_uvIndices[0]);
|
||||
}
|
||||
|
||||
int Polygon3D::GetIndex(const int index) const
|
||||
{
|
||||
return _indices[index];
|
||||
}
|
||||
|
||||
int Polygon3D::GetUVIndex(const int index) const
|
||||
{
|
||||
return _uvIndices[index];
|
||||
}
|
||||
|
||||
void Polygon3D::SetNormal(const Vector3D& normal)
|
||||
{
|
||||
_normal = normal;
|
||||
@ -52,22 +74,52 @@ void Polygon3D::NormalizeNormal()
|
||||
}
|
||||
|
||||
void Polygon3D::SetColor(int red, int green, int blue)
|
||||
{
|
||||
int redChecked = BoundsCheck(0, 255, red);
|
||||
int greenChecked = BoundsCheck(0, 255, green);
|
||||
int blueChecked = BoundsCheck(0, 255, blue);
|
||||
|
||||
_color = RGB(redChecked, greenChecked, blueChecked);
|
||||
{
|
||||
_r = red;
|
||||
_g = green;
|
||||
_b = blue;
|
||||
}
|
||||
|
||||
void Polygon3D::SetColor(const COLORREF color)
|
||||
{
|
||||
_color = color;
|
||||
_r = GetRValue(color);
|
||||
_g = GetGValue(color);
|
||||
_b = GetBValue(color);
|
||||
}
|
||||
|
||||
int Polygon3D::GetR() const
|
||||
{
|
||||
return _r;
|
||||
}
|
||||
|
||||
void Polygon3D::SetR(const int r)
|
||||
{
|
||||
_r = r;
|
||||
}
|
||||
|
||||
int Polygon3D::GetG() const
|
||||
{
|
||||
return _g;
|
||||
}
|
||||
|
||||
void Polygon3D::SetG(const int g)
|
||||
{
|
||||
_g = g;
|
||||
}
|
||||
|
||||
int Polygon3D::GetB() const
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
void Polygon3D::SetB(const int b)
|
||||
{
|
||||
_b = b;
|
||||
}
|
||||
|
||||
COLORREF Polygon3D::GetColor() const
|
||||
{
|
||||
return _color;
|
||||
return RGB(_r, _g, _b);
|
||||
}
|
||||
|
||||
void Polygon3D::SetDepth(float depth)
|
||||
@ -105,8 +157,17 @@ void Polygon3D::Copy(const Polygon3D& other)
|
||||
{
|
||||
_indices[i] = other.GetIndex(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sizeof(_uvIndices) / sizeof(_uvIndices[0]); i++)
|
||||
{
|
||||
_uvIndices[i] = other.GetUVIndex(i);
|
||||
}
|
||||
|
||||
_normal = other.GetNormal();
|
||||
_culled = other.GetCulled();
|
||||
_depth = other.GetDepth();
|
||||
_color = other.GetColor();
|
||||
|
||||
_r = other.GetR();
|
||||
_g = other.GetG();
|
||||
_b = other.GetB();
|
||||
}
|
Reference in New Issue
Block a user