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

74 lines
1.7 KiB
C++

#pragma once
#include "Vector3D.h"
#include "windows.h"
class Vertex
{
public:
Vertex();
Vertex(float x, float y, float z);
Vertex(float x, float y, float z, float w);
Vertex(const Vertex& other);
// Accessors
float GetX() const;
void SetX(const float x);
float GetY() const;
void SetY(const float y);
float GetZ() const;
void SetZ(const float z);
float GetW() const;
void SetW(const float w);
const int GetContributeCount() const;
void IncrementContributeCount();
void ResetContributeCount();
const Vector3D& GetNormal() const;
void SetNormal(float x, float y, float z);
void SetNormal(const Vector3D& normal);
void NormalizeNormal();
void ResetNormal(bool resetCount = false);
const COLORREF GetColor() const;
int GetR() const;
int GetG() const;
int GetB() const;
void SetColor(const int r, const int g, const int b);
void SetColor(const COLORREF colorIn);
// Accessor Methods 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
// use the floor function instead to round the number down
int GetXInt(bool forceRoundUp = false) const;
int GetYInt(bool forceRoundUp = false) const;
int GetZInt(bool forceRoundUp = false) const;
int GetWInt(bool forceRoundUp = false) const;
void Dehomogenize();
// Assignment operator
Vertex& operator= (const Vertex& rhs);
bool operator== (const Vertex& rhs) const;
const Vertex operator+ (const Vertex& rhs) const;
const Vector3D operator- (const Vertex& rhs) const;
private:
float _x;
float _y;
float _z;
float _w;
int _contributeCount;
Vector3D _normal;
int _r;
int _g;
int _b;
void Copy(const Vertex& other);
};