X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2Fmatlib.cxx;h=5de7e01c75d9e227d8fb989370f7049a2b7e5272;hb=675c86582d8b25270897db0a36d0e02388f09bf4;hp=4f1357707479c24d555c6437ca5485329402194f;hpb=c3b1802e956db11c2b06d354d90bca3ca9622a7b;p=simgear.git diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 4f135770..5de7e01c 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -25,10 +25,6 @@ # include #endif -#if defined ( __CYGWIN__ ) -#include -#endif - #include #include #include @@ -36,18 +32,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include @@ -82,7 +67,10 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, << ex.getMessage() ); throw; } - + osg::ref_ptr options + = new osgDB::ReaderWriter::Options; + options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL); + options->setDatabasePath(fg_root); int nMaterials = materials.nChildren(); for (int i = 0; i < nMaterials; i++) { const SGPropertyNode *node = materials.getChild(i); @@ -97,7 +85,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, } } - SGSharedPtr m = new SGMaterial(fg_root, node); + SGSharedPtr m = new SGMaterial(options.get(), node); vectornames = node->getChildren("name"); for ( unsigned int j = 0; j < names.size(); j++ ) { @@ -105,7 +93,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, // cerr << "Material " << name << endl; matlib[name] = m; m->add_name(name); - SG_LOG( SG_TERRAIN, SG_INFO, " Loading material " + SG_LOG( SG_TERRAIN, SG_DEBUG, " Loading material " << names[j]->getStringValue() ); } } else { @@ -135,15 +123,20 @@ SGMaterialLib::~SGMaterialLib ( void ) { } const SGMaterial* -SGMaterialLib::findMaterial(const simgear::Effect* effect) +SGMaterialLib::findMaterial(const osg::Geode* geode) { - if (!effect) - return 0; - - const SGMaterialUserData* matUserData - = dynamic_cast(effect->getUserData()); - if (!matUserData) - return 0; - else - return matUserData->getMaterial(); + if (!geode) + return 0; + const simgear::EffectGeode* effectGeode; + effectGeode = dynamic_cast(geode); + if (!effectGeode) + return 0; + const simgear::Effect* effect = effectGeode->getEffect(); + if (!effect) + return 0; + const SGMaterialUserData* userData; + userData = dynamic_cast(effect->getUserData()); + if (!userData) + return 0; + return userData->getMaterial(); }