Files
Graphics-Rasterizer/Model.h
IDunnoDev cdb940f6aa 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
2021-12-11 20:31:39 +00:00

102 lines
2.7 KiB
C++

#pragma once
#include "Vector3D.h"
#include "Vertex.h"
#include "Polygon3D.h"
#include "Matrix.h"
#include "Camera.h"
#include "Texture.h"
#include "UVCoord.h"
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
enum class DrawMethod { Wireframe, Flat, FlatRaster, Smooth, Textured };
class Model
{
public:
Model();
Model(string MD2Filename, string textureFilename);
~Model();
string GetModelFilename() const;
const char* CGetModelFilename() const;
string GetTextureFilename() const;
const char* CGetTextureFilename() const;
void SetActive(bool value);
void ToggleActive();
bool GetActive() const;
void SetDrawMethod(DrawMethod method);
DrawMethod GetDrawMethod() const;
vector<Polygon3D>& GetPolygons(void);
vector<Vertex>& GetVertices(void);
vector<UVCoord>& GetUVCoords(void);
const vector<Matrix>& GetPendingTransforms(void);
size_t GetPolygonCount(void);
size_t GetVerticesCount(void);
size_t GetUVCoordCount(void);
size_t GetPendingTransformCount(void);
void AddVertex(float x, float y, float z);
void AddPolygon(int index0, int index1, int index2, int uvIndex0, int uvIndex1, int uvIndex2);
void AddTextureUV(float u, float v);
void EnqueueTransform(Matrix transform);
void ClearPendingTransforms();
Texture& GetTexture();
const Polygon3D& GetPolygon(int index) const;
const Vertex& GetVertex(int polygonIndex, int vertexPolygonIndex) const;
const Vertex& GetVertex(int index) const;
const UVCoord& GetUVCoord(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;
vector<UVCoord> _uvCoords;
Texture _texture;
float _kdRed;
float _kdGreen;
float _kdBlue;
bool _active;
DrawMethod _drawMethod;
string _modelMD2Filename;
string _modelTextureFilename;
};