From: Roland Hieber Date: Mon, 25 Jan 2010 23:12:30 +0000 (+0100) Subject: mmh, there was something missing for assignment 3 X-Git-Url: https://git.rohieb.name/MicroTrace.git/commitdiff_plain/49b259147e3ece2ed0aa4ad72b686970031cfc46?hp=dfcd78f3f458d8c4bfbc27b08ced5aae0f2e57d4 mmh, there was something missing for assignment 3 --- 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