Files
Graphics-Rasterizer/Model.h
IDunnoDev df3c9fac81 Week9 [23/11] - [29/11]
Added Lighting Changes for Vertex Normal Calculation
Added Method to Get a Polygons Vertices as a Vector array
Added Methods to Add the Color to a Polygon and Vertex Object
Added Normalization to the Polygon normal vector
Added Vector Normal Calculation to the Model Class
Added Light Calculation method to the Rasterizer Class
Added Flag to Rasterizer to stop processing when the screen is minimised
Added Flat and Gouraud Drawing Methods to the Resterizer
Added Standard and INT triangle drawing Methods
Added Function to mimic sgn function from Java
Added Length to Vector3D class
Added / operator to Vector3D class
Added Get(x,y,z,w)Int methods to Vertex class
Changed Color Variables on the Vertex/Polygon classes to use r, g and b values rather than COLORREF
Changed Camera translation functions to use normal Translation Functions
Cleaned up Code
Removed Unused code from the Camera Class
2021-12-11 19:26:56 +00:00

69 lines
1.9 KiB
C++

#pragma once
#include "Vector3D.h"
#include "Vertex.h"
#include "Polygon3D.h"
#include "Matrix.h"
#include "Camera.h"
#include <vector>
#include <algorithm>
using namespace std;
class Model
{
public:
Model();
~Model();
vector<Polygon3D>& GetPolygons(void);
vector<Vertex>& GetVertices(void);
const vector<Matrix>& GetPendingTransforms(void);
size_t GetPolygonCount(void);
size_t GetVerticesCount(void);
size_t GetPendingTransformCount(void);
void AddVertex(float x, float y, float z);
void AddPolygon(int index0, int index1, int index2);
void EnqueueTransform(Matrix transform);
void ClearPendingTransforms();
const Polygon3D& GetPolygon(int index) const;
const Vertex& GetVertex(int polygonIndex, int vertexPolygonIndex) const;
const Vertex& GetVertex(int index) const;
vector<Vertex> GetPolygonVertexArray(int index) const;
void SetPolygonColor(int index, COLORREF color);
void SetVertexColor(int polyIndex, int vertIndex, COLORREF color);
void SetReflectionCoefficient(float red, float green, float blue);
void SetReflectionCoefficient(ColRef color, float value);
void SetRedReflectionCoefficient(float value);
void SetGreenReflectionCoefficient(float value);
void SetBlueReflectionCoefficient(float value);
float GetReflectionCoefficient(ColRef color) const;
float GetRedReflectionCoefficient() const;
float GetGreenReflectionCoefficient() const;
float GetBlueReflectionCoefficient() const;
void ApplyTransformToLocalVertices(const Matrix& transform);
void ApplyTransformToTransformedVertices(const Matrix& transform);
void DehomogenizeAllVertices(void);
void CalculateBackfaces(Camera& currentCamera);
void CalculateVertexNormals();
void Sort(void);
private:
vector<Polygon3D> _polygons;
vector<Vertex> _vertices;
vector<Vertex> _transformedVertices;
vector<Matrix> _pendingTransforms;
float _kdRed;
float _kdGreen;
float _kdBlue;
};