diff --git a/main/Light.h b/main/Light.h index 9a37068..5e4dc96 100644 --- a/main/Light.h +++ b/main/Light.h @@ -23,10 +23,14 @@ class Light } const Color & getSpecularColor() const { return m_specular_color; } + void setShininess(double shininess) { m_shininess = shininess; } + double getShininess() const { return m_shininess; } + protected: Vector m_position; Color m_diffuse_color; Color m_specular_color; + double m_shininess; }; #endif diff --git a/main/Lighting.cc b/main/Lighting.cc new file mode 100644 index 0000000..e15841c --- /dev/null +++ b/main/Lighting.cc @@ -0,0 +1,19 @@ + +#include "Lighting.h" + +Color Lighting::computePhong(const Material & material, + const std::vector & lights, + const Ray & viewRay, + const Vector & surfacePoint, + const Vector & surfaceNormal, + const Color & ambientLight) +{ + Color result = ambientLight; + Vector V = -viewRay.getDirection(); + for (std::vector::const_iterator it = lights.begin(); + it != lights.end(); + it++) + { + } + return result; +} diff --git a/main/Lighting.h b/main/Lighting.h new file mode 100644 index 0000000..7201006 --- /dev/null +++ b/main/Lighting.h @@ -0,0 +1,25 @@ + +#ifndef LIGHTING_H +#define LIGHTING_H LIGHTING_H + +#include "Light.h" +#include "Material.h" +#include "util/Ray.h" +#include "util/Color.h" +#include + +class Lighting +{ + public: + static Color computePhong(const Material & material, + const std::vector & lights, + const Ray & viewRay, + const Vector & surfacePoint, + const Vector & surfaceNormal, + const Color & ambientLight); + + protected: +}; + +#endif + diff --git a/util/Vector.cc b/util/Vector.cc index c19591d..bbdde16 100644 --- a/util/Vector.cc +++ b/util/Vector.cc @@ -26,6 +26,15 @@ Vector & Vector::normalize() return *this; } +Vector Vector::operator-() const +{ + Vector result; + result[0] = -m_array[0]; + result[1] = -m_array[1]; + result[2] = -m_array[2]; + return result; +} + double Vector::mag() const { return sqrt(m_array[0] * m_array[0] diff --git a/util/Vector.h b/util/Vector.h index 6078ef1..cd14835 100644 --- a/util/Vector.h +++ b/util/Vector.h @@ -11,6 +11,7 @@ class Vector Vector(double x, double y, double z); double & operator[](int idx) { return m_array[idx]; } double operator[](int idx) const { return m_array[idx]; } + Vector operator-() const; Vector & normalize(); double mag() const; double mag2() const;