Week8 [16/11] - [19/11]
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
This commit is contained in:
16
Vector3D.cpp
16
Vector3D.cpp
@ -54,10 +54,21 @@ void Vector3D::SetZ(const float z)
|
||||
_z = z;
|
||||
}
|
||||
|
||||
float Vector3D::DotProduct(const Vector3D v1, const Vector3D v2)
|
||||
void Vector3D::Normalize()
|
||||
{
|
||||
return ((v1.GetX() * v2.GetX()) + (v1.GetY() * v2.GetY()) + (v1.GetZ() * v2.GetZ()));
|
||||
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()));
|
||||
}
|
||||
|
||||
Vector3D Vector3D::CrossProduct(const Vector3D v1, const Vector3D v2)
|
||||
@ -65,6 +76,7 @@ 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()));
|
||||
}
|
||||
|
||||
|
||||
const Vector3D Vector3D::operator+ (const Vector3D& rhs) const
|
||||
{
|
||||
return Vector3D(_x + rhs.GetX(), _y + rhs.GetY(), _z + rhs.GetZ());
|
||||
|
Reference in New Issue
Block a user