18Material(
const std::string &name) :
Namable(name) {
19 _base_color.set(1.0f, 1.0f, 1.0f, 1.0f);
20 _ambient.set(1.0f, 1.0f, 1.0f, 1.0f);
21 _diffuse.set(1.0f, 1.0f, 1.0f, 1.0f);
22 _specular.set(0.0f, 0.0f, 0.0f, 1.0f);
23 _emission.set(0.0f, 0.0f, 0.0f, 1.0f);
27 _refractive_index = 1;
37 _base_color(copy._base_color),
38 _ambient(copy._ambient),
39 _diffuse(copy._diffuse),
40 _specular(copy._specular),
41 _emission(copy._emission),
42 _shininess(copy._shininess),
43 _roughness(copy._roughness),
44 _metallic(copy._metallic),
45 _refractive_index(copy._refractive_index),
46 _flags(copy._flags & ~(F_attrib_lock | F_used_by_auto_shader)) {
73 return (_flags & F_base_color) != 0;
95 return (_flags & F_ambient) != 0;
113 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
115 _flags &= ~F_ambient;
116 _ambient = _base_color;
125 return (_flags & F_diffuse) != 0;
143 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
145 _flags &= ~F_diffuse;
146 _diffuse = _base_color * (1 - _metallic);
155 return (_flags & F_specular) != 0;
173 return (_flags & F_emission) != 0;
191 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
193 _flags &= ~F_emission;
194 _emission.set(0.0f, 0.0f, 0.0f, 0.0f);
211 return (_flags & F_roughness) != 0;
220 return (_flags & F_metallic) != 0;
238 return (_flags & F_refractive_index) != 0;
247 return _refractive_index;
255 return (_flags & F_local) != 0;
266 if (is_used_by_auto_shader() &&
get_local() != local) {
267 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
281 return (_flags & F_twoside) != 0;
291 if (is_used_by_auto_shader() &&
get_twoside() != twoside) {
292 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
297 _flags &= ~F_twoside;
304INLINE
bool Material::
305operator == (
const Material &other)
const {
312INLINE
bool Material::
313operator != (
const Material &other)
const {
320INLINE
bool Material::
321operator < (
const Material &other)
const {
330 return (_flags & F_attrib_lock) != 0;
338 _flags |= F_attrib_lock;
344INLINE
bool Material::
345is_used_by_auto_shader()
const {
346 return (_flags & F_attrib_lock) != 0;
355 _flags |= F_used_by_auto_shader;
364 return _flags & ~F_used_by_auto_shader;
Defines the way an object appears in the presence of lighting.
get_ambient
Returns the ambient color setting, if it has been set.
has_specular
Returns true if the specular color has been explicitly set for this material, false otherwise.
bool has_metallic() const
Returns true if the metallic has been explicitly set for this material, false otherwise.
get_emission
Returns the emission color setting, if it has been set.
has_diffuse
Returns true if the diffuse color has been explicitly set for this material, false otherwise.
has_base_color
Returns true if the base color has been explicitly set for this material, false otherwise.
get_base_color
Returns the base_color color setting, if it has been set.
get_refractive_index
Returns the index of refraction, or 1 if none has been set for this material.
void mark_used_by_auto_shader()
Called by the shader generator to indicate that a shader has been generated that uses this material.
get_twoside
Returns the state of the two-sided lighting flag.
set_twoside
Set this true to enable two-sided lighting.
clear_diffuse
Removes the explicit diffuse color from the material.
clear_emission
Removes the explicit emission color from the material.
get_specular
Returns the specular color setting, if it has been set.
has_emission
Returns true if the emission color has been explicitly set for this material, false otherwise.
has_ambient
Returns true if the ambient color has been explicitly set for this material, false otherwise.
int compare_to(const Material &other) const
Returns a number less than zero if this material sorts before the other one, greater than zero if it ...
get_metallic
Returns the metallic setting, if it has been set.
bool is_attrib_locked() const
get_shininess
Returns the shininess exponent of the material.
static Material * get_default()
Returns the default material.
clear_ambient
Removes the explicit ambient color from the material.
bool has_refractive_index() const
Returns true if a refractive index has explicitly been specified for this material.
set_local
Sets the local viewer flag.
get_diffuse
Returns the diffuse color setting, if it has been set.
bool has_roughness() const
Returns true if the roughness has been explicitly set for this material, false otherwise.
get_local
Returns the local viewer flag.
A base class for all things which can have a name.