Files
Graphics-Rasterizer/SharedTools.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

38 lines
1.2 KiB
C++

#pragma once
#include "Matrix.h"
#include <cmath>
enum class Axis { X, Y, Z };
enum class ColRef { Red, Green, Blue };
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
namespace SharedTools
{
const float PI = (float)acos(-1);
int BoundsCheck(int min, int max, int value);
float BoundsCheck(float min, float max, float value);
Matrix GetTranslateMatrix(const float x, const float y, const float z);
Matrix GetTranslateMatrix(const Vertex& position);
Matrix GetScaleMatrix(const float x, const float y, const float z);
Matrix GetRotationMatrix(const Axis rotAxis, const float rotDegrees);
Matrix GetRotationMatrixFromPoint(const Axis rotAxis, const float rotDegrees, const float x, const float y, const float z);
Matrix GetOrthegraphicProjectionMatrix(float d);
Matrix GetPerspectiveProjectionMatrix(float d, float aspectRatio);
Matrix GetViewMatrix(float d, int width, int height);
Matrix GetCameraRotationMatrix(const Axis rotAxis, const float rotDegrees);
Matrix GetCameraTranslateMatrix(const float x, const float y, const float z);
Matrix GetCameraTranslateMatrix(const Vertex& position);
float DegreesToRadians(const float degrees);
};