1 #ifndef MSP_GL_MATERIAL_H_
2 #define MSP_GL_MATERIAL_H_
4 #include <msp/datafile/objectloader.h>
6 #include "programdata.h"
12 Stores basic material properties. This includes color and reflection
13 parameters, but does not include texturing. Materials interact with light
14 sources and ambient lighting to produce the base color of a surface. Textures
15 can be used to add detail.
17 Material provides a set of uniform variables for use with shaders.
22 class Loader: public DataFile::CollectionObjectLoader<Material>
29 Loader(Material &, Collection &);
33 Color make_color(float, float, float, float);
34 void ambient(float, float, float, float);
35 void diffuse(float, float, float, float);
36 void specular(float, float, float, float);
37 void emission(float, float, float, float);
38 void shininess(float);
39 void reflectivity(float);
54 /** Sets the ambient color of the material. Provided to shaders with the
55 name material.ambient. */
56 void set_ambient(const Color &);
58 /** Sets the diffuse (direction-independent) color of the material.
59 Provided to shaders with the name material.diffuse. */
60 void set_diffuse(const Color &);
62 /** Sets the specular (direction-dependent) color of the material. Provided
63 to shaders with the name material.specular. */
64 void set_specular(const Color &);
65 void set_emission(const Color &);
67 /** Sets the specular exponent of the material. Provided to shaders with
68 the name material.shininess. */
69 void set_shininess(float);
71 /** Sets the reflectivity of the material. Provided to shaders with the
72 name reflectivity. Has no effect when shaders are not used. */
73 void set_reflectivity(float);
75 const Color &get_ambient() const { return ambient; }
76 const Color &get_diffuse() const { return diffuse; }
77 const Color &get_specular() const { return specular; }
78 const Color &get_emission() const { return emission; }
79 float get_shininess() const { return shininess; }
80 float get_reflectivity() const { return reflectivity; }
82 /** Returns the uniforms for the material. */
83 const ProgramData &get_shader_data() const { return shdata; }