-class SGAcMaterialCrippleVisitor : public SGStateAttributeVisitor {
-public:
- virtual void apply(StateSet::RefAttributePair& refAttr)
- {
- Material* material;
- material = dynamic_cast<Material*>(refAttr.first.get());
- if (!material)
- return;
- material->setColorMode(Material::AMBIENT_AND_DIFFUSE);
- }
-};
-
-// Work around an OSG bug - the file loaders don't use the file path
-// in options while the file is being loaded.
-
-struct OptionsPusher {
- FilePathList localPathList;
- bool validOptions;
- OptionsPusher(const ReaderWriter::Options* options):
- validOptions(false)
- {
- if (!options)
- return;
- Registry* registry = Registry::instance();
- localPathList = registry->getDataFilePathList();
- const FilePathList& regPathList = registry->getDataFilePathList();
- const FilePathList& optionsPathList = options->getDatabasePathList();
- for (FilePathList::const_iterator iter = optionsPathList.begin();
- iter != optionsPathList.end();
- ++iter) {
- if (find(regPathList.begin(), regPathList.end(), *iter)
- == regPathList.end())
- localPathList.push_back(*iter);
- }
- // Save the current Registry path list and install the augmented one.
- localPathList.swap(registry->getDataFilePathList());
- validOptions = true;
- }
- ~OptionsPusher()
- {
- // Restore the old path list
- if (validOptions)
- localPathList.swap(Registry::instance()->getDataFilePathList());
- }
-};