Final Changes before submission
This commit is contained in:
@ -29,26 +29,26 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
19
Model.cpp
19
Model.cpp
@ -335,10 +335,8 @@ void Model::CalculateVertexNormals()
|
||||
|
||||
for (Vertex& currentVertex : _transformedVertices)
|
||||
{
|
||||
|
||||
currentVertex.SetNormal(currentVertex.GetNormal() / currentVertex.GetContributeCount());
|
||||
currentVertex.NormalizeNormal();
|
||||
|
||||
currentVertex.SetNormal(currentVertex.GetNormal() / currentVertex.GetContributeCount());
|
||||
currentVertex.NormalizeNormal();
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,3 +359,16 @@ void Model::Sort()
|
||||
|
||||
sort(_polygons.begin(), _polygons.end(), DepthCompare);
|
||||
}
|
||||
|
||||
void Model::CalculateUVPerspective()
|
||||
{
|
||||
for (Polygon3D& currentPolygon : _polygons)
|
||||
{
|
||||
|
||||
for (int cpi = 0; cpi < currentPolygon.GetPolygonVertexCount(); cpi++)
|
||||
{
|
||||
_transformedVertices[currentPolygon.GetIndex(cpi)].UVCorrect(_uvCoords[currentPolygon.GetUVIndex(cpi)].GetU(), _uvCoords[currentPolygon.GetUVIndex(cpi)].GetV());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
2
Model.h
2
Model.h
@ -78,6 +78,8 @@ public:
|
||||
void CalculateVertexNormals();
|
||||
void Sort(void);
|
||||
|
||||
void CalculateUVPerspective(void);
|
||||
|
||||
private:
|
||||
vector<Polygon3D> _polygons;
|
||||
vector<Vertex> _vertices;
|
||||
|
976
Rasteriser.cpp
976
Rasteriser.cpp
File diff suppressed because it is too large
Load Diff
28
Rasteriser.h
28
Rasteriser.h
@ -2,6 +2,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tchar.h>
|
||||
#include <ctime>
|
||||
#include "Framework.h"
|
||||
#include "Vector3D.h"
|
||||
#include "Vertex.h"
|
||||
@ -25,7 +26,7 @@ public:
|
||||
void Update(const Bitmap& bitmap);
|
||||
void Render(const Bitmap& bitmap);
|
||||
void ClearViewport(const Bitmap& bitmap);
|
||||
void DrawString(HDC hDc, int x, int y, LPCTSTR text, COLORREF textColor = 0x00FFFFFF, COLORREF backgroundColor = 0x00000000);
|
||||
void DrawString(HDC hDc, int x, int y, LPCTSTR text, int fontSize = 48, COLORREF textColor = 0x00FFFFFF, COLORREF backgroundColor = 0x00000000);
|
||||
|
||||
~Rasteriser();
|
||||
|
||||
@ -58,23 +59,40 @@ public:
|
||||
void FillGouraudSideTriangle(HDC hDc, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
||||
|
||||
void FillPolygonTextured(HDC hDc, Model& model, vector<Vertex>& verticies);
|
||||
void FillTexturedSideTriangle(HDC hDc, Model& model, const Vertex& v1, const Vertex& v2, const Vertex& v3, const UVCoord& uv1, const UVCoord& uv2, const UVCoord& uv3);
|
||||
void FillTexturedSideTriangle(HDC hDc, Model& model, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
||||
|
||||
void FillPolygonTexturedA(HDC hDc, Model& model, vector<Vertex>& verticies);
|
||||
void FillTexturedBottomFlatTriangle(HDC hDc, Model& model, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
||||
void FillTexturedTopFlatTriangle(HDC hDc, Model& model, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
||||
|
||||
private:
|
||||
// Vector arrays to hold the scene models, the lights and the cameras.
|
||||
vector<Model> _sceneModels;
|
||||
vector<Light*> _lights;
|
||||
vector<Camera> _cameras;
|
||||
|
||||
// Index of the currently viewing camera.
|
||||
int _currentCamera = 0;
|
||||
|
||||
// Matrices and Aspect ration for the viewing and perspective transformations.
|
||||
Matrix _currentPerspectiveMatrix;
|
||||
Matrix _currentViewMatrix;
|
||||
float _currentAspectRatio = 0.0f;
|
||||
int _rotation = 0;
|
||||
|
||||
int _currentDrawMode = 0;
|
||||
|
||||
// bool to check if the screen is minimized to stop processing
|
||||
bool _screenMinimized = false;
|
||||
string _modelDataLocation = ".//model_data/";
|
||||
|
||||
// timer variables to hold the start time of the showcase, and the current time for
|
||||
// calculation of where in the showcase we are.
|
||||
time_t _startTime;
|
||||
time_t _currentTime;
|
||||
|
||||
// an int to store the current state of the showcase.
|
||||
int _currentState;
|
||||
int _maxStates;
|
||||
|
||||
// An array to store counters for use in.
|
||||
int _counters[10];
|
||||
};
|
||||
|
||||
|
27
Vertex.cpp
27
Vertex.cpp
@ -207,6 +207,11 @@ float Vertex::GetZOriginal() const
|
||||
return _zOriginal;
|
||||
}
|
||||
|
||||
void Vertex::SetZOriginal(const float value)
|
||||
{
|
||||
_zOriginal = value;
|
||||
}
|
||||
|
||||
float Vertex::GetUOverZ() const
|
||||
{
|
||||
return _uOverZ;
|
||||
@ -214,7 +219,7 @@ float Vertex::GetUOverZ() const
|
||||
|
||||
void Vertex::SetUOverZ(const float value)
|
||||
{
|
||||
_uOverZ = value / _zOriginal;
|
||||
_uOverZ = value;
|
||||
}
|
||||
|
||||
float Vertex::GetVOverZ() const
|
||||
@ -224,7 +229,7 @@ float Vertex::GetVOverZ() const
|
||||
|
||||
void Vertex::SetVOverZ(const float value)
|
||||
{
|
||||
_vOverZ = value / _zOriginal;
|
||||
_vOverZ = value;
|
||||
}
|
||||
|
||||
float Vertex::GetZRecip() const
|
||||
@ -232,12 +237,19 @@ float Vertex::GetZRecip() const
|
||||
return _zRecip;
|
||||
}
|
||||
|
||||
void Vertex::UVCorrect(float u, float v)
|
||||
void Vertex::SetZRecip(const float value)
|
||||
{
|
||||
_zOriginal = _w;
|
||||
_zRecip = 1 / _zOriginal;
|
||||
SetUOverZ(u);
|
||||
SetVOverZ(v);
|
||||
_zRecip = value;
|
||||
}
|
||||
|
||||
void Vertex::UVCorrect(float u, float v, bool calcZRecip)
|
||||
{
|
||||
SetUOverZ(u / _zOriginal);
|
||||
SetVOverZ(v / _zOriginal);
|
||||
if (calcZRecip)
|
||||
{
|
||||
SetZRecip(1 / _zOriginal);
|
||||
}
|
||||
}
|
||||
|
||||
int Vertex::GetXInt(bool forceRoundUp) const
|
||||
@ -290,6 +302,7 @@ int Vertex::GetWInt(bool forceRoundUp) const
|
||||
|
||||
void Vertex::Dehomogenize()
|
||||
{
|
||||
_zOriginal = _w;
|
||||
_x = _x / _w;
|
||||
_y = _y / _w;
|
||||
_z = _z / _w;
|
||||
|
5
Vertex.h
5
Vertex.h
@ -45,12 +45,14 @@ public:
|
||||
void SetUVIndex(const int index);
|
||||
|
||||
float GetZOriginal() const;
|
||||
void SetZOriginal(const float value);
|
||||
float GetUOverZ() const;
|
||||
void SetUOverZ(const float value);
|
||||
float GetVOverZ() const;
|
||||
void SetVOverZ(const float value);
|
||||
float GetZRecip() const;
|
||||
void UVCorrect(float u, float v);
|
||||
void SetZRecip(const float value);
|
||||
void UVCorrect(float u, float v, bool calcZRecip = true);
|
||||
|
||||
// Accessors for returning the private x, y, z and w values as integeres instead of floats
|
||||
// the ceil function to round the number up by defaults but using providing a false param will
|
||||
@ -76,6 +78,7 @@ private:
|
||||
float _z;
|
||||
float _w;
|
||||
|
||||
float _zOriginalSet = 0;
|
||||
float _zOriginal;
|
||||
|
||||
int _contributeCount;
|
||||
|
Reference in New Issue
Block a user