From 49b259147e3ece2ed0aa4ad72b686970031cfc46 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Tue, 26 Jan 2010 00:12:30 +0100 Subject: [PATCH 1/1] mmh, there was something missing for assignment 3 --- Light.cxx | 26 ++++++++++++++++++++++++++ Light.hxx | 25 +++++++++++++++++++++++++ PhongShader.cxx | 35 +++++++++++++++++++++++++++++++++++ PhongShader.hxx | 26 ++++++++++++++++++++++++++ PointLight.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ PointLight.hxx | 25 +++++++++++++++++++++++++ SpotLight.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ SpotLight.hxx | 27 +++++++++++++++++++++++++++ 8 files changed, 252 insertions(+) create mode 100644 Light.cxx create mode 100644 Light.hxx create mode 100644 PhongShader.cxx create mode 100644 PhongShader.hxx create mode 100644 PointLight.cxx create mode 100644 PointLight.hxx create mode 100644 SpotLight.cxx create mode 100644 SpotLight.hxx diff --git a/Light.cxx b/Light.cxx new file mode 100644 index 0000000..ee29a71 --- /dev/null +++ b/Light.cxx @@ -0,0 +1,26 @@ +#include "Light.hxx" + +Light::Light(Scene* scene) + : m_scene(scene) +{ +} + +Light::~Light() +{ +} + +Light::Light() + : m_scene(0) +{ +} + +Light::Light(const Light& l) +{ + operator=(l); +} + +Light& +Light::operator=(const Light& ) +{ + return *this; +} diff --git a/Light.hxx b/Light.hxx new file mode 100644 index 0000000..a152693 --- /dev/null +++ b/Light.hxx @@ -0,0 +1,25 @@ +#ifndef LIGHT_HXX +#define LIGHT_HXX + +#include "Vec3f.hxx" +#include "Ray.hxx" + +// forward declaration +class Scene; + +class Light +{ +public: + Light(Scene* scene); + virtual ~Light(); + + virtual bool Illuminate(Ray& shadowray, Vec3f& intensity) = 0; +protected: + Scene* m_scene; + +private: + Light(); + Light(const Light& ); + Light& operator=(const Light& ); +}; +#endif diff --git a/PhongShader.cxx b/PhongShader.cxx new file mode 100644 index 0000000..4f4d065 --- /dev/null +++ b/PhongShader.cxx @@ -0,0 +1,35 @@ +#include "PhongShader.hxx" + +PhongShader::PhongShader(Scene* scene, + const Vec3f& am_c, + const Vec3f& di_c, + const Vec3f& sp_c, + float ka, + float kd, + float ks, + float ke) + : Shader(scene), + m_ambient_color(am_c), + m_diffuse_color(di_c), + m_specular_color(sp_c), + m_ka(ka), + m_kd(kd), + m_ks(ks), + m_ke(ke) +{ +} + +PhongShader::PhongShader() + : Shader(0) +{ +} + +PhongShader::~PhongShader() +{ +} + +Vec3f +PhongShader::Shade(Ray& ray) +{ + return Vec3f(); +} diff --git a/PhongShader.hxx b/PhongShader.hxx new file mode 100644 index 0000000..b83e670 --- /dev/null +++ b/PhongShader.hxx @@ -0,0 +1,26 @@ +#ifndef PHONGSHADER_HXX +#define PHONGSHADER_HXX + +#include "Shader.hxx" + +class PhongShader : public Shader +{ +public: + PhongShader(Scene* scene, + const Vec3f& ambient_color, + const Vec3f& diffuse_color, + const Vec3f& specular_color, + float ka, + float kd, + float ks, + float ke); + virtual ~PhongShader(); + + virtual Vec3f Shade(Ray& ray); +private: + PhongShader(); + + Vec3f m_ambient_color, m_diffuse_color, m_specular_color; + float m_ka, m_kd, m_ks, m_ke; +}; +#endif diff --git a/PointLight.cxx b/PointLight.cxx new file mode 100644 index 0000000..1ce5f0b --- /dev/null +++ b/PointLight.cxx @@ -0,0 +1,40 @@ +#include "PointLight.hxx" + +PointLight::PointLight(Scene* scene, const Vec3f& pos, const Vec3f& intensity) + : Light(scene), + m_pos(pos), + m_intensity(intensity) +{ +} + +PointLight::~PointLight() +{ +} + +PointLight::PointLight() + : Light(0), + m_pos(Vec3f()), + m_intensity(Vec3f()) +{ +} + +bool +PointLight::Illuminate(Ray& ray, Vec3f& intensity) +{ + + return false; +} + +const Vec3f& +PointLight::position() const +{ + return m_pos; +} + +const Vec3f& +PointLight::intensity() const +{ + return m_intensity; +} + + diff --git a/PointLight.hxx b/PointLight.hxx new file mode 100644 index 0000000..b086116 --- /dev/null +++ b/PointLight.hxx @@ -0,0 +1,25 @@ +#ifndef POINTLIGHT_HXX +#define POINTLIGHT_HXX + +#include "Light.hxx" + +class PointLight : public Light +{ +public: + PointLight(Scene* scene, const Vec3f& pos, const Vec3f& intensity); + virtual ~PointLight(); + + virtual bool Illuminate(Ray& ray, Vec3f& intensity); + + const Vec3f& position() const; + const Vec3f& intensity() const; + +private: + PointLight(); + + // origin + Vec3f m_pos; + // emission ( red, green, blue ) + Vec3f m_intensity; +}; +#endif diff --git a/SpotLight.cxx b/SpotLight.cxx new file mode 100644 index 0000000..8ec7cf6 --- /dev/null +++ b/SpotLight.cxx @@ -0,0 +1,48 @@ +#include "SpotLight.hxx" + +SpotLight::SpotLight(Scene* scene, + const Vec3f& pos, + const Vec3f& dir, + const Vec3f& intensity, + float alpha_min, + float alpha_max) + : Light(scene), + m_pos(pos), + m_dir(dir), + m_intensity(intensity), + m_alpha_min(alpha_min), + m_alpha_max(alpha_max) +{ +} + +SpotLight::~SpotLight() +{ +} + +SpotLight::SpotLight() + : Light(0), + m_pos(Vec3f()), + m_dir(Vec3f()), + m_intensity(Vec3f()), + m_alpha_min(0.0f), + m_alpha_max(0.0f) +{ +} + +bool +SpotLight::Illuminate(Ray& ray, Vec3f& intensity) +{ + return false; +} + +const Vec3f& +SpotLight::position() const +{ + return m_pos; +} + +const Vec3f& +SpotLight::direction() const +{ + return m_dir; +} diff --git a/SpotLight.hxx b/SpotLight.hxx new file mode 100644 index 0000000..ed404d8 --- /dev/null +++ b/SpotLight.hxx @@ -0,0 +1,27 @@ +#ifndef SPOTLIGHT_HXX +#define SPOTLIGHT_HXX + +#include "Light.hxx" + +class SpotLight : public Light +{ +public: + SpotLight(Scene* scene, const Vec3f& pos, const Vec3f& dir, const Vec3f& intensity, float alpha_min, float alpha_max); + virtual ~SpotLight(); + + virtual bool Illuminate(Ray& ray, Vec3f& intensity); + + const Vec3f& position() const; + const Vec3f& direction() const; + +private: + SpotLight(); + + // position and direction + Vec3f m_pos, m_dir; + // emission (red, green, blue) + Vec3f m_intensity; + // opening angles + float m_alpha_min, m_alpha_max; +}; +#endif -- 2.20.1