X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2Fmatlib.cxx;h=5de7e01c75d9e227d8fb989370f7049a2b7e5272;hb=675c86582d8b25270897db0a36d0e02388f09bf4;hp=b20ccb447abdf34689fff536485f61cda4543cf1;hpb=0793c2cb8c94f499944f3b5f9d0b2d79a7d47794;p=simgear.git diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index b20ccb44..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 @@ -58,6 +43,8 @@ #include "mat.hxx" +#include "Effect.hxx" +#include "Technique.hxx" #include "matlib.hxx" using std::string; @@ -80,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); @@ -95,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++ ) { @@ -103,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 { @@ -133,19 +123,20 @@ SGMaterialLib::~SGMaterialLib ( void ) { } const SGMaterial* -SGMaterialLib::findMaterial(const osg::StateSet* stateSet) +SGMaterialLib::findMaterial(const osg::Geode* geode) { - if (!stateSet) - return 0; - - const osg::Referenced* base = stateSet->getUserData(); - if (!base) - return 0; - - const SGMaterialUserData* matUserData - = dynamic_cast(base); - if (!matUserData) - return 0; - - 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(); }