
Added active Variable to the Lights Classes Added updated MD2Loader Class Added Model Filename and Texture File Name to the Model Class Added Active Flag to the Model Class Added DrawMode to the Model Class Added Texture and UV Variables to the Model Class Added UV Coordinates to the Polygon3D Class Added DrawString method to the Rasterizer to write text to the screen space Added Interpolate and Lerp Methods to the Rasterizer Added Select statement for drawing a current models draw mode Added DrawTextured Method to the Rasterizer Class Added UVCoord Class Added Texture Class Added = operator to the Vector3D Class Added UVCoord to the Vertex Class Moved Models and Texture Files into a subfolder Fixed issue with textures not loading properly because of the vector address problem
113 lines
1.8 KiB
C++
113 lines
1.8 KiB
C++
#include "Vector3D.h"
|
|
|
|
Vector3D::Vector3D()
|
|
{
|
|
_x = 1;
|
|
_y = 1;
|
|
_z = 1;
|
|
}
|
|
|
|
Vector3D::Vector3D(float x, float y, float z)
|
|
{
|
|
_x = x;
|
|
_y = y;
|
|
_z = z;
|
|
}
|
|
|
|
Vector3D::Vector3D(const Vector3D& other)
|
|
{
|
|
Copy(other);
|
|
}
|
|
|
|
Vector3D::~Vector3D()
|
|
{
|
|
}
|
|
|
|
// Accessors
|
|
float Vector3D::GetX() const
|
|
{
|
|
return _x;
|
|
}
|
|
|
|
void Vector3D::SetX(const float x)
|
|
{
|
|
_x = x;
|
|
}
|
|
|
|
float Vector3D::GetY() const
|
|
{
|
|
return _y;
|
|
}
|
|
|
|
void Vector3D::SetY(const float y)
|
|
{
|
|
_y = y;
|
|
}
|
|
|
|
float Vector3D::GetZ() const
|
|
{
|
|
return _z;
|
|
}
|
|
|
|
void Vector3D::SetZ(const float z)
|
|
{
|
|
_z = z;
|
|
}
|
|
|
|
const void Vector3D::Normalize()
|
|
{
|
|
float length = sqrt(_x * _x + _y * _y + _z * _z);
|
|
|
|
if (length != 0)
|
|
{
|
|
_x /= length;
|
|
_y /= length;
|
|
_z /= length;
|
|
}
|
|
}
|
|
|
|
float Vector3D::DotProduct(const Vector3D v1, const Vector3D v2)
|
|
{
|
|
return v1.GetX() * v2.GetX() + v1.GetY() * v2.GetY() + v1.GetZ() * v2.GetZ();
|
|
}
|
|
|
|
float Vector3D::Length(const Vector3D v1, const Vector3D v2)
|
|
{
|
|
return (float)sqrt(pow((v1.GetX() - v2.GetX()), 2) + pow((v1.GetY() - v2.GetY()), 2) + pow((v1.GetZ() - v2.GetZ()), 2));
|
|
}
|
|
|
|
Vector3D Vector3D::CrossProduct(const Vector3D v1, const Vector3D v2)
|
|
{
|
|
return Vector3D(v1.GetY() * v2.GetZ() - v1.GetZ() * v2.GetY(), v1.GetZ() * v2.GetX() - v1.GetX() * v2.GetZ(), v1.GetX() * v2.GetY() - v1.GetY() * v2.GetX());
|
|
}
|
|
|
|
Vector3D& Vector3D::operator= (const Vector3D& rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
Copy(rhs);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
const Vector3D Vector3D::operator+ (const Vector3D& rhs) const
|
|
{
|
|
return Vector3D(_x + rhs.GetX(), _y + rhs.GetY(), _z + rhs.GetZ());
|
|
}
|
|
|
|
const Vector3D Vector3D::operator/ (const float rhs) const
|
|
{
|
|
return Vector3D(_x / rhs, _y / rhs, _z / rhs);
|
|
}
|
|
|
|
const Vector3D Vector3D::operator/ (const int rhs) const
|
|
{
|
|
return Vector3D(_x / rhs, _y / rhs, _z / rhs);
|
|
}
|
|
|
|
void Vector3D::Copy(const Vector3D& other)
|
|
{
|
|
_x = other.GetX();
|
|
_y = other.GetY();
|
|
_z = other.GetZ();
|
|
} |