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:
parent
434064c03c
commit
8677680577
@ -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
|
||||
|
19
main/Lighting.cc
Normal file
19
main/Lighting.cc
Normal 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
25
main/Lighting.h
Normal 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
|
||||
|
@ -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]
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user