
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
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include "Framework.h"
|
|
#include "Vector3D.h"
|
|
#include "Vertex.h"
|
|
#include "Matrix.h"
|
|
#include "SharedTools.h"
|
|
#include "Camera.h"
|
|
#include "Model.h"
|
|
#include "MD2Loader.h"
|
|
#include "Light.h"
|
|
#include "AmbientLight.h"
|
|
#include "DirectionalLight.h"
|
|
#include "PointLight.h"
|
|
|
|
using namespace std;
|
|
using namespace SharedTools;
|
|
|
|
class Rasteriser : public Framework
|
|
{
|
|
public:
|
|
bool Initialise();
|
|
void Update(const Bitmap& bitmap);
|
|
void Render(const Bitmap& bitmap);
|
|
void ClearViewport(const Bitmap& bitmap);
|
|
|
|
void SetCurrentCamera(int index);
|
|
Camera& GetCamera(int index);
|
|
Camera& GetCurrentCamera();
|
|
|
|
void CalculateLighting(Model& currentModel, bool fullLightRender);
|
|
|
|
void DrawSquare(HDC hDc, const vector<Vertex> verticies);
|
|
void DrawShape(HDC hDc, const vector<Vertex> verticies);
|
|
|
|
void DrawWireFrame(HDC hDc, Model& model);
|
|
void DrawSolidFlat(HDC hDc, Model& model);
|
|
void DrawRasterisedSolidFlat(HDC hDc, Model& model);
|
|
void DrawGouraud(HDC hDc, Model& model);
|
|
|
|
void FillPolygonFlat(HDC hDc, vector<Vertex>& verticies, COLORREF colorIn);
|
|
void FillFlatSideTriangle(HDC hDc, const Vertex& v1, const Vertex& v2, const Vertex& v3, COLORREF colorIn);
|
|
|
|
void FillPolygonGouraud(HDC hDc, vector<Vertex>& verticies);
|
|
void FillGouraudTopFlatTriangle(HDC hDc, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
|
void FillGouraudBottomFlatTriangle(HDC hDc, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
|
|
|
void FillPolygonGouraudInt(HDC hDc, vector<Vertex>& verticies);
|
|
void FillGouraudSideTriangle(HDC hDc, const Vertex& v1, const Vertex& v2, const Vertex& v3);
|
|
|
|
private:
|
|
vector<Model> _sceneModels;
|
|
vector<Light*> _lights;
|
|
vector<Camera> _cameras;
|
|
|
|
int _currentCamera = 0;
|
|
|
|
Matrix _currentPerspectiveMatrix;
|
|
Matrix _currentViewMatrix;
|
|
float _currentAspectRatio = 0.0f;
|
|
int _rotation = 0;
|
|
|
|
bool _screenMinimized = false;
|
|
};
|
|
|