Add diffuse parameters to Material
This commit is contained in:
		
							parent
							
								
									438b0734a4
								
							
						
					
					
						commit
						887233e3e4
					
				
					 2 changed files with 54 additions and 8 deletions
				
			
		| 
						 | 
					@ -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 ¶m)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (param < 0.0) {
 | 
				
			||||||
 | 
					        param = 0.0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (param > 1.0) {
 | 
				
			||||||
 | 
					        param = 1.0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 ¶m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Diffusion parameters.
 | 
				
			||||||
 | 
					    float diffuse_level;
 | 
				
			||||||
 | 
					    Color diffuse_color;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue