
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
90 lines
1.5 KiB
C++
90 lines
1.5 KiB
C++
#include "Camera.h"
|
|
|
|
Camera::Camera(float xRot, float yRot, float zRot, const Vertex& pos)
|
|
{
|
|
_xRot = xRot;
|
|
_yRot = yRot;
|
|
_zRot = zRot;
|
|
_cameraPosition = pos;
|
|
}
|
|
|
|
Camera::Camera(const Camera& other)
|
|
{
|
|
Copy(other);
|
|
}
|
|
|
|
Camera::~Camera()
|
|
{
|
|
}
|
|
|
|
Matrix Camera::UpdateCameraPosition(const Vertex& newPos)
|
|
{
|
|
_cameraPosition = newPos;
|
|
return GetCurrentCameraTransformMatrix();
|
|
}
|
|
|
|
Matrix Camera::RotateCamera(float xRot, float yRot, float zRot)
|
|
{
|
|
_xRot = xRot;
|
|
_yRot = yRot;
|
|
_zRot = zRot;
|
|
return GetCurrentCameraTransformMatrix();
|
|
}
|
|
|
|
Matrix Camera::GetCurrentCameraTransformMatrix()
|
|
{
|
|
return GetCameraRotationMatrix(Axis::X, _xRot) * GetCameraRotationMatrix(Axis::Y, _yRot) * GetCameraRotationMatrix(Axis::Z, _zRot) * GetCameraTranslateMatrix(_cameraPosition);
|
|
}
|
|
|
|
void Camera::SetXRot(const float value)
|
|
{
|
|
_xRot = value;
|
|
}
|
|
|
|
float Camera::GetXRot() const
|
|
{
|
|
return _xRot;
|
|
}
|
|
|
|
void Camera::SetYRot(const float value)
|
|
{
|
|
_yRot = value;
|
|
}
|
|
|
|
float Camera::GetYRot() const
|
|
{
|
|
return _yRot;
|
|
}
|
|
|
|
void Camera::SetZRot(const float value)
|
|
{
|
|
_zRot = value;
|
|
}
|
|
|
|
float Camera::GetZRot() const
|
|
{
|
|
return _zRot;
|
|
}
|
|
|
|
Vertex Camera::GetCameraPosition() const
|
|
{
|
|
return _cameraPosition;
|
|
}
|
|
|
|
Camera& Camera::operator=(const Camera& rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
Copy(rhs);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void Camera::Copy(const Camera& other)
|
|
{
|
|
_xRot = other.GetXRot();
|
|
_yRot = other.GetYRot();
|
|
_zRot = other.GetZRot();
|
|
|
|
_cameraPosition = other.GetCameraPosition();
|
|
} |