X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Fbasicmaterial.cpp;h=30202a568f62a7964700f7f765cc3af84c3350f6;hb=3ac3a51c623271da815c8ee60c484445871753bf;hp=33dced53d7fb65c68fce1251893f14b202c144c3;hpb=842c817bb679a5a0abc05e8149e2e6e0ae1a0412;p=libs%2Fgl.git diff --git a/source/materials/basicmaterial.cpp b/source/materials/basicmaterial.cpp index 33dced53..30202a56 100644 --- a/source/materials/basicmaterial.cpp +++ b/source/materials/basicmaterial.cpp @@ -5,8 +5,18 @@ using namespace std; namespace Msp { namespace GL { -BasicMaterial::BasicMaterial(): - receive_shadows(false) +const Tag BasicMaterial::texture_tags[] = +{ + Tag("diffuse_map"), + Tag("specular_map"), + Tag("shininess_map"), + Tag("normal_map"), + Tag("emission_map"), + Tag("reflectivity_map"), + Tag() +}; + +BasicMaterial::BasicMaterial() { set_diffuse(Color(1.0f)); set_specular(Color(0.0f)); @@ -29,9 +39,10 @@ void BasicMaterial::fill_program_info(string &module_name, map &spe spec_values["use_emission_map"] = (emission.texture!=0); spec_values["use_reflectivity"] = (reflectivity.value!=0 || reflectivity.texture!=0); spec_values["use_reflectivity_map"] = (reflectivity.texture!=0); - spec_values["use_shadow_map"] = receive_shadows; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" void BasicMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const { attach_texture_to(diffuse.texture, texturing, tex_shdata, "diffuse_map"); @@ -41,6 +52,25 @@ void BasicMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_sh attach_texture_to(shininess.texture, texturing, tex_shdata, "shininess_map"); attach_texture_to(reflectivity.texture, texturing, tex_shdata, "reflectivity_map"); } +#pragma GCC diagnostic pop + +const Texture *BasicMaterial::get_texture(Tag tag) const +{ + if(tag==texture_tags[0]) + return diffuse.texture; + else if(tag==texture_tags[1]) + return specular.texture; + else if(tag==texture_tags[2]) + return shininess.texture; + else if(tag==texture_tags[3]) + return normal.texture; + else if(tag==texture_tags[4]) + return emission.texture; + else if(tag==texture_tags[5]) + return reflectivity.texture; + else + return 0; +} void BasicMaterial::set_diffuse(const Color &color) { @@ -102,11 +132,6 @@ void BasicMaterial::set_reflectivity_map(const Texture *tex) reflectivity.texture = tex; } -void BasicMaterial::set_receive_shadows(bool s) -{ - receive_shadows = s; -} - DataFile::Loader::ActionMap BasicMaterial::Loader::shared_actions; @@ -131,7 +156,6 @@ void BasicMaterial::Loader::init_actions() 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); - add("receive_shadows", &BasicMaterial::receive_shadows); } } // namespace GL