From 887233e3e4a27c2db99be57b68e1ab7f40e5e0f0 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 13 Sep 2013 18:39:11 -0700 Subject: [PATCH] Add diffuse parameters to Material --- src/material.cc | 44 +++++++++++++++++++++++++++++++++++++++----- src/material.h | 18 +++++++++++++++--- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/material.cc b/src/material.cc index 574ff58..632a818 100644 --- a/src/material.cc +++ b/src/material.cc @@ -8,16 +8,50 @@ #include "material.h" -Color -Material::get_color() +Material::Material() + : diffuse_level(1.0), + diffuse_color(Color::Black) +{ } + + +float +Material::get_diffuse_level() const { - return color; + return diffuse_level; } void -Material::set_color(const Color &c) +Material::set_diffuse_level(const float &kd) { - color = c; + diffuse_level = kd; + _clamp_parameter(diffuse_level); +} + + +const Color & +Material::get_diffuse_color() + const +{ + return diffuse_color; +} + + +void +Material::set_diffuse_color(const Color &c) +{ + diffuse_color = c; +} + + +void +Material::_clamp_parameter(float ¶m) +{ + if (param < 0.0) { + param = 0.0; + } + else if (param > 1.0) { + param = 1.0; + } } diff --git a/src/material.h b/src/material.h index c6b51de..60950cf 100644 --- a/src/material.h +++ b/src/material.h @@ -14,11 +14,23 @@ class Material { public: - Color get_color() const; - void set_color(const Color &c); + enum { + DiffuseLightingTypeLambert = 1, + } DiffuseLightingType; + + Material(); + + float get_diffuse_level() const; + void set_diffuse_level(const float &kd); + const Color &get_diffuse_color() const; + void set_diffuse_color(const Color &c); private: - Color color; + void _clamp_parameter(float ¶m); + + // Diffusion parameters. + float diffuse_level; + Color diffuse_color; }; #endif