+#include "basicmaterial.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GL {
+
+BasicMaterial::BasicMaterial()
+{
+ set_diffuse(Color(1.0f));
+ set_specular(Color(0.0f));
+ set_emission(Color(0.0f));
+ set_shininess(50.0f);
+ set_reflectivity(0.0f);
+}
+
+void BasicMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const
+{
+ attach_texture_to(diffuse.texture, texturing, tex_shdata, "diffuse_map");
+ attach_texture_to(specular.texture, texturing, tex_shdata, "specular_map");
+ attach_texture_to(normal.texture, texturing, tex_shdata, "normal_map");
+ attach_texture_to(emission.texture, texturing, tex_shdata, "emission_map");
+ attach_texture_to(shininess.texture, texturing, tex_shdata, "shininess_map");
+ attach_texture_to(reflectivity.texture, texturing, tex_shdata, "reflectivity_map");
+}
+
+void BasicMaterial::set_diffuse(const Color &color)
+{
+ diffuse.value = color;
+ shdata.uniform("basic_material.diffuse", color);
+}
+
+void BasicMaterial::set_diffuse_map(const Texture *tex)
+{
+ diffuse.texture = tex;
+}
+
+void BasicMaterial::set_specular(const Color &color)
+{
+ specular.value = color;
+ shdata.uniform("basic_material.specular", color);
+}
+
+void BasicMaterial::set_specular_map(const Texture *tex)
+{
+ specular.texture = tex;
+}
+
+void BasicMaterial::set_normal_map(const Texture *tex)
+{
+ normal.texture = tex;
+}
+
+void BasicMaterial::set_emission(const Color &color)
+{
+ emission.value = color;
+ shdata.uniform("basic_material.emission", color);
+}
+
+void BasicMaterial::set_emission_map(const Texture *tex)
+{
+ emission.texture = tex;
+}
+
+void BasicMaterial::set_shininess(float value)
+{
+ shininess.value = value;
+ shdata.uniform("basic_material.shininess", value);
+}
+
+void BasicMaterial::set_shininess_map(const Texture *tex)
+{
+ shininess.texture = tex;
+}
+
+void BasicMaterial::set_reflectivity(float value)
+{
+ reflectivity.value = value;
+ shdata.uniform("basic_material.reflectivity", value);
+}
+
+void BasicMaterial::set_reflectivity_map(const Texture *tex)
+{
+ reflectivity.texture = tex;
+}
+
+
+DataFile::Loader::ActionMap BasicMaterial::Loader::shared_actions;
+
+BasicMaterial::Loader::Loader(BasicMaterial &m):
+ DerivedObjectLoader<BasicMaterial, Material::LoaderBase<BasicMaterial> >(m)
+{
+ set_actions(shared_actions);
+}
+
+BasicMaterial::Loader::Loader(BasicMaterial &m, Collection &c):
+ DerivedObjectLoader<BasicMaterial, Material::LoaderBase<BasicMaterial> >(m, c)
+{
+ set_actions(shared_actions);
+}
+
+void BasicMaterial::Loader::init_actions()
+{
+ add_property("diffuse", &BasicMaterial::set_diffuse, &BasicMaterial::set_diffuse_map, true);
+ add_property("specular", &BasicMaterial::set_specular, &BasicMaterial::set_specular_map, false);
+ add_property("normal", &BasicMaterial::set_normal_map);
+ add_property("emission", &BasicMaterial::set_emission, &BasicMaterial::set_emission_map, false);
+ add_property("shininess", &BasicMaterial::set_shininess, &BasicMaterial::set_shininess_map);
+ add_property("reflectivity", &BasicMaterial::set_reflectivity, &BasicMaterial::set_reflectivity_map);
+}
+
+} // namespace GL
+} // namespace Msp