
Added Camera Class Added *= operator to the matrix class Added Transformation Queue vector to the Model Class Added Get Vertex, Polygon and Polygon Vertex methods to the Model Class Added DehomogenizeAllVerticies method to the Model Class Added GetPolygonVertexCount method to Polygon Class Added Ability to have multiple models in a "scene" in the Rasterizer Added DrawWireFrame method to the Rasterizer Class Added Aspect Ratio and View Matrix to the Rasterizer Class Added TransformTools namespace to hold shared transformation functions Added Dehomogenize method to the Vector Class Moved Transformation methods to a new shared name space
102 lines
2.2 KiB
C++
102 lines
2.2 KiB
C++
#include "Camera.h"
|
|
|
|
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;
|
|
} |