Add diffuse parameters to Material

This commit is contained in:
Eryn Wells 2013-09-13 18:39:11 -07:00
parent 438b0734a4
commit 887233e3e4
2 changed files with 54 additions and 8 deletions

View file

@ -8,16 +8,50 @@
#include "material.h" #include "material.h"
Color Material::Material()
Material::get_color() : diffuse_level(1.0),
diffuse_color(Color::Black)
{ }
float
Material::get_diffuse_level()
const const
{ {
return color; return diffuse_level;
} }
void 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 &param)
{
if (param < 0.0) {
param = 0.0;
}
else if (param > 1.0) {
param = 1.0;
}
} }

View file

@ -14,11 +14,23 @@
class Material class Material
{ {
public: public:
Color get_color() const; enum {
void set_color(const Color &c); 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: private:
Color color; void _clamp_parameter(float &param);
// Diffusion parameters.
float diffuse_level;
Color diffuse_color;
}; };
#endif #endif