added main/Lighting module, added operator-() to util/Vector, added m_shininess to main/Light

git-svn-id: svn://anubis/fart/trunk@71 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-01-30 20:28:05 +00:00
parent 434064c03c
commit 8677680577
5 changed files with 58 additions and 0 deletions

View File

@ -23,10 +23,14 @@ class Light
} }
const Color & getSpecularColor() const { return m_specular_color; } const Color & getSpecularColor() const { return m_specular_color; }
void setShininess(double shininess) { m_shininess = shininess; }
double getShininess() const { return m_shininess; }
protected: protected:
Vector m_position; Vector m_position;
Color m_diffuse_color; Color m_diffuse_color;
Color m_specular_color; Color m_specular_color;
double m_shininess;
}; };
#endif #endif

19
main/Lighting.cc Normal file
View File

@ -0,0 +1,19 @@
#include "Lighting.h"
Color Lighting::computePhong(const Material & material,
const std::vector<Light *> & lights,
const Ray & viewRay,
const Vector & surfacePoint,
const Vector & surfaceNormal,
const Color & ambientLight)
{
Color result = ambientLight;
Vector V = -viewRay.getDirection();
for (std::vector<Light *>::const_iterator it = lights.begin();
it != lights.end();
it++)
{
}
return result;
}

25
main/Lighting.h Normal file
View File

@ -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 <vector>
class Lighting
{
public:
static Color computePhong(const Material & material,
const std::vector<Light *> & lights,
const Ray & viewRay,
const Vector & surfacePoint,
const Vector & surfaceNormal,
const Color & ambientLight);
protected:
};
#endif

View File

@ -26,6 +26,15 @@ Vector & Vector::normalize()
return *this; 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 double Vector::mag() const
{ {
return sqrt(m_array[0] * m_array[0] return sqrt(m_array[0] * m_array[0]

View File

@ -11,6 +11,7 @@ class Vector
Vector(double x, double y, double z); Vector(double x, double y, double z);
double & operator[](int idx) { return m_array[idx]; } double & operator[](int idx) { return m_array[idx]; }
double operator[](int idx) const { return m_array[idx]; } double operator[](int idx) const { return m_array[idx]; }
Vector operator-() const;
Vector & normalize(); Vector & normalize();
double mag() const; double mag() const;
double mag2() const; double mag2() const;