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:
IDunnoDev
2021-12-11 20:31:39 +00:00
committed by iDunnoDev
parent df3c9fac81
commit cdb940f6aa
32 changed files with 1136 additions and 243 deletions

100
Model.cpp
View File

@ -5,10 +5,80 @@ Model::Model()
_kdRed = 1.0f;
_kdGreen = 1.0f;
_kdBlue = 1.0f;
_active = false;
_drawMethod = DrawMethod::Wireframe;
_modelMD2Filename = "";
_modelTextureFilename = "";
}
Model::Model(string MD2Filename, string textureFilename)
{
_kdRed = 1.0f;
_kdGreen = 1.0f;
_kdBlue = 1.0f;
_active = false;
_drawMethod = DrawMethod::Wireframe;
_modelMD2Filename = MD2Filename;
_modelTextureFilename = textureFilename;
}
Model::~Model()
{
_vertices.~vector();
_transformedVertices.~vector();
_polygons.~vector();
_pendingTransforms.~vector();
_uvCoords.~vector();
}
string Model::GetModelFilename() const
{
return _modelMD2Filename;
}
const char* Model::CGetModelFilename() const
{
return _modelMD2Filename.c_str();
}
string Model::GetTextureFilename() const
{
return _modelTextureFilename;
}
const char* Model::CGetTextureFilename() const
{
return _modelTextureFilename.c_str();
}
void Model::SetActive(bool value)
{
_active = value;
}
void Model::ToggleActive()
{
_active = !_active;
}
bool Model::GetActive() const
{
return _active;
}
void Model::SetDrawMethod(DrawMethod method)
{
_drawMethod = method;
}
DrawMethod Model::GetDrawMethod() const
{
return _drawMethod;
}
vector<Polygon3D>& Model::GetPolygons()
@ -21,6 +91,11 @@ vector<Vertex>& Model::GetVertices()
return _vertices;
}
vector<UVCoord>& Model::GetUVCoords()
{
return _uvCoords;
}
const vector<Matrix>& Model::GetPendingTransforms()
{
return _pendingTransforms;
@ -36,6 +111,11 @@ size_t Model::GetVerticesCount()
return _vertices.size();
}
size_t Model::GetUVCoordCount()
{
return _uvCoords.size();
}
size_t Model::GetPendingTransformCount()
{
return _pendingTransforms.size();
@ -47,9 +127,14 @@ void Model::AddVertex(float x, float y, float z)
_transformedVertices.push_back(Vertex(x, y, z));
}
void Model::AddPolygon(int index0, int index1, int index2)
void Model::AddPolygon(int index0, int index1, int index2, int uvIndex0, int uvIndex1, int uvIndex2)
{
_polygons.push_back(Polygon3D(index0, index1, index2));
_polygons.push_back(Polygon3D(index0, index1, index2, uvIndex0, uvIndex1, uvIndex2));
}
void Model::AddTextureUV(float u, float v)
{
_uvCoords.push_back(UVCoord(u, v));
}
void Model::EnqueueTransform(Matrix transform)
@ -62,6 +147,11 @@ void Model::ClearPendingTransforms()
_pendingTransforms.clear();
}
Texture& Model::GetTexture()
{
return _texture;
}
const Polygon3D& Model::GetPolygon(int index) const
{
return _polygons[index];
@ -77,6 +167,11 @@ const Vertex& Model::GetVertex(int index) const
return _transformedVertices[index];
}
const UVCoord& Model::GetUVCoord(int index) const
{
return _uvCoords[index];
}
vector<Vertex> Model::GetPolygonVertexArray(int index) const
{
vector<Vertex> polygonVerticies = {};
@ -234,6 +329,7 @@ void Model::CalculateVertexNormals()
{
_transformedVertices[_polygons[pi].GetIndex(i)].SetNormal(_transformedVertices[_polygons[pi].GetIndex(i)].GetNormal() + _polygons[pi].GetNormal());
_transformedVertices[_polygons[pi].GetIndex(i)].IncrementContributeCount();
_transformedVertices[_polygons[pi].GetIndex(i)].SetUVIndex(_polygons[pi].GetUVIndex(i));
}
}