Week7 [09/11] - [11/11]

Added Backface Culling Methods to the Model Class
Added Depth, Normal and Culled Flag Variables to the Polygon3D Class
Added Vector3D Class
Added - operator to the Vertex Class
Cleaned up Code, Adding Void to Params etc
This commit is contained in:
IDunnoDev
2021-12-11 14:48:46 +00:00
committed by iDunnoDev
parent 19639d70d1
commit 773507b4ab
12 changed files with 257 additions and 32 deletions

View File

@ -90,7 +90,9 @@ void Rasteriser::Render(const Bitmap& bitmap)
workingMatrix *= currentTransform;
}
currentModel.ApplyTransformToLocalVertices(workingMatrix);
currentModel.CalculateBackfaces(mainCamera);
currentModel.ApplyTransformToTransformedVertices(mainCamera.GetCurrentCameraTransformMatrix());
currentModel.Sort();
currentModel.ApplyTransformToTransformedVertices(_currentPerspectiveMatrix);
currentModel.DehomogenizeAllVertices();
currentModel.ApplyTransformToTransformedVertices(_currentViewMatrix);
@ -139,19 +141,25 @@ void Rasteriser::DrawWireFrame(HDC hDc, Model& model)
vector<POINT> pointArray;
vector<int> sizeArray;
int unculledPolyCount = 0;
int modelPolygonCount = (int) model.GetPolygonCount();
for (int i = 0; i < modelPolygonCount; i++)
{
int currentPolygonVertexCount = (int) model.GetPolygon(i).GetPolygonVertexCount();
for (int j = 0; j < currentPolygonVertexCount; j++)
{
if (!model.GetPolygon(i).GetCulled())
{
POINT newPoint;
newPoint.x = (long) model.GetVertex(i, j).GetX();
newPoint.y = (long) model.GetVertex(i, j).GetY();
pointArray.push_back(newPoint);
int currentPolygonVertexCount = (int)model.GetPolygon(i).GetPolygonVertexCount();
for (int j = 0; j < currentPolygonVertexCount; j++)
{
POINT newPoint;
newPoint.x = (long)model.GetVertex(i, j).GetX();
newPoint.y = (long)model.GetVertex(i, j).GetY();
pointArray.push_back(newPoint);
}
sizeArray.push_back(currentPolygonVertexCount);
unculledPolyCount++;
}
sizeArray.push_back(currentPolygonVertexCount);
}
PolyPolygon(hDc, pointArray.data(), sizeArray.data(), modelPolygonCount);
PolyPolygon(hDc, pointArray.data(), sizeArray.data(), unculledPolyCount);
}