Week8 [16/11] - [19/11]

Added Light Base Class
Added AmbientLight, DirectionalLight and PointLight Classes
Added Constructor to the Camera Class
Added Light CoEff's to the Model Class
Added Color Variables to Polygon3D Class
Added Light Vector to hold the lights in the Rasteriser
Added Camera Vector to hold multiple Cameras and Methods to set which is the current
Added Lighting to the Rasterizer
Added DrawSolidFlat method to the Rastorizer
Added Bounds Check to the SharedTools for Int and Float values
Added Color Enum Class
Added Normalize Method to the Vector3D Class
Renamed the TransformTools to SharedTools since adding more non transform methods to it
This commit is contained in:
IDunnoDev
2021-12-11 17:05:43 +00:00
committed by iDunnoDev
parent 773507b4ab
commit f5fd5b6756
24 changed files with 815 additions and 41 deletions

View File

@ -2,13 +2,16 @@
Model::Model()
{
_kdRed = 1.0f;
_kdGreen = 1.0f;
_kdBlue = 1.0f;
}
Model::~Model()
{
}
const vector<Polygon3D>& Model::GetPolygons()
vector<Polygon3D>& Model::GetPolygons()
{
return _polygons;
}
@ -59,21 +62,97 @@ void Model::ClearPendingTransforms()
_pendingTransforms.clear();
}
const Polygon3D& Model::GetPolygon(int index)
const Polygon3D& Model::GetPolygon(int index) const
{
return _polygons[index];
}
const Vertex& Model::GetVertex(int polygonIndex, int vertexPolygonIndex)
const Vertex& Model::GetVertex(int polygonIndex, int vertexPolygonIndex) const
{
return GetVertex(GetPolygon(polygonIndex).GetIndex(vertexPolygonIndex));
}
const Vertex& Model::GetVertex(int index)
const Vertex& Model::GetVertex(int index) const
{
return _transformedVertices[index];
}
void Model::SetReflectionCoefficient(float red, float green, float blue)
{
_kdRed = BoundsCheck(0.0f, 1.0f, red);
_kdGreen = BoundsCheck(0.0f, 1.0f, green);
_kdBlue = BoundsCheck(0.0f, 1.0f, blue);
}
void Model::SetReflectionCoefficient(ColRef color, float value)
{
float valueChecked = BoundsCheck(0.0f, 1.0f, value);
switch (color)
{
default:
case ColRef::Red:
_kdRed = valueChecked;
break;
case ColRef::Green:
_kdGreen = valueChecked;
break;
case ColRef::Blue:
_kdBlue = valueChecked;
break;
}
}
void Model::SetRedReflectionCoefficient(float value)
{
SetReflectionCoefficient(ColRef::Red, value);
}
void Model::SetGreenReflectionCoefficient(float value)
{
SetReflectionCoefficient(ColRef::Green, value);
}
void Model::SetBlueReflectionCoefficient(float value)
{
SetReflectionCoefficient(ColRef::Blue, value);
}
float Model::GetReflectionCoefficient(ColRef color) const
{
float result;
switch (color)
{
default:
case ColRef::Red:
result = _kdRed;
break;
case ColRef::Green:
result = _kdGreen;
break;
case ColRef::Blue:
result = _kdBlue;
break;
}
return result;
}
float Model::GetRedReflectionCoefficient() const
{
return GetReflectionCoefficient(ColRef::Red);
}
float Model::GetGreenReflectionCoefficient() const
{
return GetReflectionCoefficient(ColRef::Green);
}
float Model::GetBlueReflectionCoefficient() const
{
return GetReflectionCoefficient(ColRef::Blue);
}
void Model::ApplyTransformToLocalVertices(const Matrix& transform)
{
for (int i = 0; i < GetVerticesCount(); i++)