X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbasicmaterial.cpp;h=362fc9db14e6a8636960bec3a746cd8e62715ed8;hp=858c65daf56e8a31e5cdb9c22f1ab0da3f43ae57;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=fd62e55d37716787fe909883a1b18e5b8128ec80 diff --git a/source/basicmaterial.cpp b/source/basicmaterial.cpp index 858c65da..362fc9db 100644 --- a/source/basicmaterial.cpp +++ b/source/basicmaterial.cpp @@ -5,7 +5,8 @@ using namespace std; namespace Msp { namespace GL { -BasicMaterial::BasicMaterial() +BasicMaterial::BasicMaterial(): + receive_shadows(false) { set_diffuse(Color(1.0f)); set_specular(Color(0.0f)); @@ -41,6 +42,8 @@ string BasicMaterial::create_program_source() const if (reflectivity.texture) source += "const bool use_reflectivity_map = true;\n"; } + if(receive_shadows) + source += "const bool use_shadow_map = true;\n"; return source; } @@ -114,29 +117,36 @@ 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; BasicMaterial::Loader::Loader(BasicMaterial &m): - DerivedObjectLoader >(m) + DerivedObjectLoader >(m) { set_actions(shared_actions); } BasicMaterial::Loader::Loader(BasicMaterial &m, Collection &c): - DerivedObjectLoader >(m, c) + DerivedObjectLoader >(m, c) { set_actions(shared_actions); } void BasicMaterial::Loader::init_actions() { + Material::PropertyLoader::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); + add("receive_shadows", &BasicMaterial::receive_shadows); } } // namespace GL