
Added Light Base Class Added AmbientLight, DirectionalLight and PointLight Classes Added Constructor to the Camera Class Added Light CoEff's to the Model Class Added Color Variables to Polygon3D Class Added Light Vector to hold the lights in the Rasteriser Added Camera Vector to hold multiple Cameras and Methods to set which is the current Added Lighting to the Rasterizer Added DrawSolidFlat method to the Rastorizer Added Bounds Check to the SharedTools for Int and Float values Added Color Enum Class Added Normalize Method to the Vector3D Class Renamed the TransformTools to SharedTools since adding more non transform methods to it
106 lines
2.2 KiB
C++
106 lines
2.2 KiB
C++
#include "Camera.h"
|
|
|
|
Camera::Camera()
|
|
{
|
|
}
|
|
|
|
Camera::Camera(float xRot, float yRot, float zRot, const Vertex& pos)
|
|
{
|
|
_initialRotation[0] = xRot;
|
|
_currentRotation[0] = xRot;
|
|
_initialRotation[1] = yRot;
|
|
_currentRotation[1] = yRot;
|
|
_initialRotation[2] = zRot;
|
|
_currentRotation[2] = zRot;
|
|
_initialPosition = pos;
|
|
_currentPosition = pos;
|
|
}
|
|
|
|
Camera::Camera(const Camera& other)
|
|
{
|
|
Copy(other);
|
|
}
|
|
|
|
Camera::~Camera()
|
|
{
|
|
}
|
|
|
|
Matrix Camera::UpdateCameraPosition(const Vertex& newPos)
|
|
{
|
|
_currentPosition = newPos;
|
|
return GetCurrentCameraTransformMatrix();
|
|
}
|
|
|
|
Matrix Camera::RotateCamera(float xRot, float yRot, float zRot)
|
|
{
|
|
_currentRotation[0] = xRot;
|
|
_currentRotation[1] = yRot;
|
|
_currentRotation[2] = zRot;
|
|
return GetCurrentCameraTransformMatrix();
|
|
}
|
|
|
|
Matrix Camera::GetCurrentCameraTransformMatrix()
|
|
{
|
|
return GetCameraRotationMatrix(Axis::X, _currentRotation[0]) * GetCameraRotationMatrix(Axis::Y, _currentRotation[1]) * GetCameraRotationMatrix(Axis::Z, _currentRotation[2]) * GetCameraTranslateMatrix(_currentPosition);
|
|
}
|
|
|
|
float Camera::GetCurrentRotationValue(const Axis axis)
|
|
{
|
|
switch (axis)
|
|
{
|
|
case (Axis::X):
|
|
return _currentRotation[0];
|
|
case (Axis::Y):
|
|
return _currentRotation[1];
|
|
case (Axis::Z):
|
|
return _currentRotation[2];
|
|
default:
|
|
throw "No valid axis?";
|
|
}
|
|
}
|
|
|
|
float Camera::GetInitialRotationValue(const Axis axis)
|
|
{
|
|
switch (axis)
|
|
{
|
|
case (Axis::X):
|
|
return _initialRotation[0];
|
|
case (Axis::Y):
|
|
return _initialRotation[1];
|
|
case (Axis::Z):
|
|
return _initialRotation[2];
|
|
default:
|
|
throw "No valid axis?";
|
|
}
|
|
}
|
|
|
|
Vertex Camera::GetCurrentPosition()
|
|
{
|
|
return _currentPosition;
|
|
}
|
|
|
|
Vertex Camera::GetInitialPosition()
|
|
{
|
|
return _initialPosition;
|
|
}
|
|
|
|
Camera& Camera::operator=(const Camera& rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
Copy(rhs);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void Camera::Copy(const Camera& other)
|
|
{
|
|
_initialRotation[0] = other._initialRotation[0];
|
|
_currentRotation[0] = other._currentRotation[0];
|
|
_initialRotation[1] = other._initialRotation[1];
|
|
_currentRotation[1] = other._currentRotation[1];
|
|
_initialRotation[2] = other._initialRotation[2];
|
|
_currentRotation[2] = other._currentRotation[2];
|
|
_initialPosition = other._initialPosition;
|
|
_currentPosition = other._currentPosition;
|
|
} |