
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
112 lines
1.7 KiB
C++
112 lines
1.7 KiB
C++
#include "Light.h"
|
|
|
|
Light::Light()
|
|
{
|
|
SetLightIntensity(255, 255, 255);
|
|
}
|
|
|
|
Light::Light(int red, int green, int blue)
|
|
{
|
|
SetLightIntensity(red, green, blue);
|
|
}
|
|
|
|
Light::Light(const Light& other)
|
|
{
|
|
Copy(other);
|
|
}
|
|
|
|
Light::~Light()
|
|
{
|
|
}
|
|
|
|
void Light::SetLightIntensity(int red, int green, int blue)
|
|
{
|
|
_liRed = BoundsCheck(0, 255, red);
|
|
_liGreen = BoundsCheck(0, 255, green);
|
|
_liBlue = BoundsCheck(0, 255, blue);
|
|
}
|
|
|
|
void Light::SetLightIntensity(ColRef color, int value)
|
|
{
|
|
int valueChecked = BoundsCheck(0, 255, value);
|
|
|
|
switch (color)
|
|
{
|
|
default:
|
|
case ColRef::Red:
|
|
_liRed = valueChecked;
|
|
break;
|
|
case ColRef::Green:
|
|
_liGreen = valueChecked;
|
|
break;
|
|
case ColRef::Blue:
|
|
_liBlue = valueChecked;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void Light::SetRedLightIntensity(int value)
|
|
{
|
|
SetLightIntensity(ColRef::Red, value);
|
|
}
|
|
|
|
void Light::SetGreenLightIntensity(int value)
|
|
{
|
|
SetLightIntensity(ColRef::Green, value);
|
|
}
|
|
|
|
void Light::SetBlueLightIntensity(int value)
|
|
{
|
|
SetLightIntensity(ColRef::Blue, value);
|
|
}
|
|
|
|
int Light::GetLightIntensity(ColRef color) const
|
|
{
|
|
int result;
|
|
switch (color)
|
|
{
|
|
default:
|
|
case ColRef::Red:
|
|
result = _liRed;
|
|
break;
|
|
case ColRef::Green:
|
|
result = _liGreen;
|
|
break;
|
|
case ColRef::Blue:
|
|
result = _liBlue;
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
int Light::GetRedLightIntensity() const
|
|
{
|
|
return GetLightIntensity(ColRef::Red);
|
|
}
|
|
|
|
int Light::GetGreenLightIntensity() const
|
|
{
|
|
return GetLightIntensity(ColRef::Green);
|
|
}
|
|
|
|
int Light::GetBlueLightIntensity() const
|
|
{
|
|
return GetLightIntensity(ColRef::Blue);
|
|
}
|
|
|
|
Light& Light::operator= (const Light& rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
Copy(rhs);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void Light::Copy(const Light& other)
|
|
{
|
|
_liRed = other.GetRedLightIntensity();
|
|
_liGreen = other.GetGreenLightIntensity();
|
|
_liBlue = other.GetBlueLightIntensity();
|
|
} |