]> git.mxchange.org Git - simgear.git/commitdiff
pass SGReaderWriterXMLOptions to effects
authorTim Moore <timoore33@gmail.com>
Wed, 16 Dec 2009 19:11:04 +0000 (20:11 +0100)
committerTim Moore <timoore33@gmail.com>
Tue, 9 Mar 2010 10:02:56 +0000 (11:02 +0100)
This will allow parameters to refer to properties in models, though
that doesn't work yet.

14 files changed:
simgear/scene/material/Effect.cxx
simgear/scene/material/Effect.hxx
simgear/scene/material/EffectBuilder.cxx
simgear/scene/material/EffectBuilder.hxx
simgear/scene/material/TextureBuilder.cxx
simgear/scene/material/TextureBuilder.hxx
simgear/scene/material/makeEffect.cxx
simgear/scene/material/mat.cxx
simgear/scene/material/mat.hxx
simgear/scene/model/SGReaderWriterXMLOptions.hxx
simgear/scene/model/model.cxx
simgear/scene/model/model.hxx
simgear/scene/model/modellib.cxx
simgear/scene/sky/newcloud.cxx

index 9da202f7ca411cf99b447e20ff3b678391d6cd7d..3ad9316216fd0904e039f9c8caeb79f76092ab2c 100644 (file)
@@ -66,6 +66,7 @@
 #include <osgDB/ReadFile>
 #include <osgDB/Registry>
 
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
@@ -143,7 +144,7 @@ Effect::~Effect()
 }
 
 void buildPass(Effect* effect, Technique* tniq, const SGPropertyNode* prop,
-               const osgDB::ReaderWriter::Options* options)
+               const SGReaderWriterXMLOptions* options)
 {
     Pass* pass = new Pass;
     tniq->passes.push_back(pass);
@@ -188,12 +189,12 @@ osg::Vec4f getColor(const SGPropertyNode* prop)
 struct LightingBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options);
+                        const SGReaderWriterXMLOptions* options);
 };
 
 void LightingBuilder::buildAttribute(Effect* effect, Pass* pass,
                                      const SGPropertyNode* prop,
-                                     const osgDB::ReaderWriter::Options* options)
+                                     const SGReaderWriterXMLOptions* options)
 {
     const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
     if (!realProp)
@@ -207,7 +208,7 @@ InstallAttributeBuilder<LightingBuilder> installLighting("lighting");
 struct ShadeModelBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -229,7 +230,7 @@ InstallAttributeBuilder<ShadeModelBuilder> installShadeModel("shade-model");
 struct CullFaceBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp) {
@@ -257,7 +258,7 @@ InstallAttributeBuilder<CullFaceBuilder> installCullFace("cull-face");
 struct ColorMaskBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -284,7 +285,7 @@ EffectPropertyMap<StateSet::RenderingHint> renderingHints(renderingHintInit);
 struct HintBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -300,7 +301,7 @@ InstallAttributeBuilder<HintBuilder> installHint("rendering-hint");
 struct RenderBinBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -327,7 +328,7 @@ InstallAttributeBuilder<RenderBinBuilder> installRenderBin("render-bin");
 struct MaterialBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options);
+                        const SGReaderWriterXMLOptions* options);
 };
 
 EffectNameValue<Material::ColorMode> colorModeInit[] =
@@ -343,7 +344,7 @@ EffectPropertyMap<Material::ColorMode> colorModes(colorModeInit);
 
 void MaterialBuilder::buildAttribute(Effect* effect, Pass* pass,
                                      const SGPropertyNode* prop,
-                                     const osgDB::ReaderWriter::Options* options)
+                                     const SGReaderWriterXMLOptions* options)
 {
     if (!isAttributeActive(effect, prop))
         return;
@@ -413,7 +414,7 @@ EffectPropertyMap<BlendFunc::BlendFuncMode> blendFuncModes(blendFuncModesInit);
 struct BlendBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -526,7 +527,7 @@ EffectPropertyMap<Stencil::Operation> stencilOperation(stencilOperationInit);
 struct StencilBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -604,7 +605,7 @@ alphaComparison(alphaComparisonInit);
 struct AlphaTestBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -715,12 +716,12 @@ void reload_shaders()
 struct ShaderProgramBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options);
+                        const SGReaderWriterXMLOptions* options);
 };
 
 void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
                                           const SGPropertyNode* prop,
-                                          const osgDB::ReaderWriter::Options*
+                                          const SGReaderWriterXMLOptions*
                                           options)
 {
     using namespace boost;
@@ -815,7 +816,7 @@ EffectPropertyMap<Uniform::Type> uniformTypes(uniformTypesInit);
 struct UniformBuilder :public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -889,7 +890,7 @@ InstallAttributeBuilder<UniformBuilder> installUniform("uniform");
 struct NameBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         // name can't use <use>
         string name = prop->getStringValue();
@@ -911,7 +912,7 @@ EffectPropertyMap<PolygonMode::Mode> polygonModeModes(polygonModeModesInit);
 struct PolygonModeBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -939,7 +940,7 @@ InstallAttributeBuilder<PolygonModeBuilder> installPolygonMode("polygon-mode");
 struct VertexProgramTwoSideBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -956,7 +957,7 @@ installTwoSide("vertex-program-two-side");
 struct VertexProgramPointSizeBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -986,7 +987,7 @@ EffectPropertyMap<Depth::Function> depthFunction(depthFunctionInit);
 struct DepthBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options)
+                        const SGReaderWriterXMLOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -1017,7 +1018,7 @@ struct DepthBuilder : public PassAttributeBuilder
 InstallAttributeBuilder<DepthBuilder> installDepth("depth");
 
 void buildTechnique(Effect* effect, const SGPropertyNode* prop,
-                    const osgDB::ReaderWriter::Options* options)
+                    const SGReaderWriterXMLOptions* options)
 {
     Technique* tniq = new Technique;
     effect->techniques.push_back(tniq);
@@ -1123,7 +1124,7 @@ bool makeParametersFromStateSet(SGPropertyNode* effectRoot, const StateSet* ss)
 
 // Walk the techniques property tree, building techniques and
 // passes.
-bool Effect::realizeTechniques(const osgDB::ReaderWriter::Options* options)
+bool Effect::realizeTechniques(const SGReaderWriterXMLOptions* options)
 {
     if (_isRealized)
         return true;
index 1f33b9e86d61209f7a0b1f6cb5c4a08b7aa64446..0690db3a76a5f17e36334fafd24429a1b778b2e9 100644 (file)
@@ -45,6 +45,7 @@ namespace simgear
 {
 class Technique;
 class Effect;
+class SGReaderWriterXMLOptions;
 
 /**
  * Object to be initialized at some point after an effect -- and its
@@ -89,7 +90,7 @@ public:
     /**
      * Build the techniques from the effect properties.
      */
-    bool realizeTechniques(const osgDB::ReaderWriter::Options* options = 0);
+    bool realizeTechniques(const SGReaderWriterXMLOptions* options = 0);
     /**
      * Updaters that should be derefed when the effect is
      * deleted. Updaters arrange to be run by listening on properties
@@ -144,7 +145,7 @@ protected:
     Cache* _cache;
     friend size_t hash_value(const Key& key);
     friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
-                              const osgDB::ReaderWriter::Options* options);
+                              const SGReaderWriterXMLOptions* options);
     bool _isRealized;
 };
 // Automatic support for boost hash function
@@ -153,11 +154,11 @@ size_t hash_value(const Effect::Key&);
 
 Effect* makeEffect(const std::string& name,
                    bool realizeTechniques,
-                   const osgDB::ReaderWriter::Options* options = 0);
+                   const SGReaderWriterXMLOptions* options = 0);
 
 Effect* makeEffect(SGPropertyNode* prop,
                    bool realizeTechniques,
-                   const osgDB::ReaderWriter::Options* options = 0);
+                   const SGReaderWriterXMLOptions* options = 0);
 
 bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
                                 const osg::StateSet* ss);
index 34f14ac84aed8f862dd0bc7591121465377e16c2..65ba71dbcb773bae4134de21fc4c63798ef6e562 100644 (file)
@@ -2,6 +2,7 @@
 #  include <simgear_config.h>
 #endif
 
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 
 #include <simgear/math/SGMath.hxx>
index be4b03452d035e0e89ff8b592bbf78fae61244f5..d16e3347a46f0ddbcad36f8789202650cf01b34d 100644 (file)
@@ -56,10 +56,10 @@ class EffectBuilder : public SGReferenced
 public:
     virtual ~EffectBuilder() {}
     virtual T* build(Effect* effect, const SGPropertyNode*,
-                     const osgDB::ReaderWriter::Options* options) = 0;
+                     const SGReaderWriterXMLOptions* options) = 0;
     static T* buildFromType(Effect* effect, const std::string& type,
                             const SGPropertyNode*props,
-                            const osgDB::ReaderWriter::Options* options)
+                            const SGReaderWriterXMLOptions* options)
     {
         BuilderMap& builderMap = getMap();
         typename BuilderMap::iterator iter = builderMap.find(type);
@@ -255,7 +255,7 @@ protected:
 public:
     virtual void buildAttribute(Effect* effect, Pass* pass,
                                 const SGPropertyNode* prop,
-                                const osgDB::ReaderWriter::Options* options)
+                                const SGReaderWriterXMLOptions* options)
     = 0;
     static PassAttributeBuilder* find(const std::string& str)
     {
index a924b95571055057d3e378b86ff0ba10ad7a439a..f81f2b9bfaedb42eb035a9b9e0718a5560f35358 100644 (file)
@@ -35,6 +35,7 @@
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_comparison.hpp>
 
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/math/SGMath.hxx>
@@ -56,7 +57,7 @@ TexGen* buildTexGen(Effect* Effect, const SGPropertyNode* tgenProp);
 // Hack to force inclusion of TextureBuilder.cxx in library
 osg::Texture* TextureBuilder::buildFromType(Effect* effect, const string& type,
                                             const SGPropertyNode*props,
-                                            const osgDB::ReaderWriter::Options*
+                                            const SGReaderWriterXMLOptions*
                                             options)
 {
     return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
@@ -98,7 +99,7 @@ TexEnv* buildTexEnv(Effect* effect, const SGPropertyNode* prop)
 
 void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
                                         const SGPropertyNode* prop,
-                                        const osgDB::ReaderWriter::Options* options)
+                                        const SGReaderWriterXMLOptions* options)
 {
     if (!isAttributeActive(effect, prop))
         return;
@@ -177,7 +178,7 @@ EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
 
 
 TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
-                      const osgDB::ReaderWriter::Options* options,
+                      const SGReaderWriterXMLOptions* options,
                       const string& texType)
 {
     Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
@@ -213,7 +214,7 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
 }
 
 void setAttrs(const TexTuple& attrs, Texture* tex,
-              const osgDB::ReaderWriter::Options* options)
+              const SGReaderWriterXMLOptions* options)
 {
     const string& imageName = attrs.get<0>();
     if (imageName.empty()) {
@@ -253,7 +254,7 @@ class TexBuilder : public TextureBuilder
 public:
     TexBuilder(const string& texType) : _type(texType) {}
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const osgDB::ReaderWriter::Options* options);
+                   const SGReaderWriterXMLOptions* options);
 protected:
     typedef map<TexTuple, ref_ptr<T> > TexMap;
     TexMap texMap;
@@ -262,7 +263,7 @@ protected:
 
 template<typename T>
 Texture* TexBuilder<T>::build(Effect* effect, const SGPropertyNode* props,
-                              const osgDB::ReaderWriter::Options* options)
+                              const SGReaderWriterXMLOptions* options)
 {
     TexTuple attrs = makeTexTuple(effect, props, options, _type);
     typename TexMap::iterator itr = texMap.find(attrs);
@@ -286,11 +287,11 @@ class WhiteTextureBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const osgDB::ReaderWriter::Options* options);
+                   const SGReaderWriterXMLOptions* options);
 };
 
 Texture* WhiteTextureBuilder::build(Effect* effect, const SGPropertyNode*,
-                                    const osgDB::ReaderWriter::Options* options)
+                                    const SGReaderWriterXMLOptions* options)
 {
     return StateAttributeFactory::instance()->getWhiteTexture();
 }
@@ -304,11 +305,11 @@ class TransparentTextureBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const osgDB::ReaderWriter::Options* options);
+                   const SGReaderWriterXMLOptions* options);
 };
 
 Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
-                                    const osgDB::ReaderWriter::Options* options)
+                                    const SGReaderWriterXMLOptions* options)
 {
     return StateAttributeFactory::instance()->getTransparentTexture();
 }
@@ -368,14 +369,14 @@ class NoiseBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const osgDB::ReaderWriter::Options* options);
+                   const SGReaderWriterXMLOptions* options);
 protected:
     typedef map<int, ref_ptr<Texture3D> > NoiseMap;
     NoiseMap _noises;
 };
 
 Texture* NoiseBuilder::build(Effect* effect, const SGPropertyNode* props,
-                             const osgDB::ReaderWriter::Options* options)
+                             const SGReaderWriterXMLOptions* options)
 {
     int texSize = 64;
     const SGPropertyNode* sizeProp = getEffectPropertyChild(effect, props,
index ca6c54945f3eb902a88eeb5f10e14e1b1c5fd066..55df27360e178bb531a9d83afc0502050917ab9e 100644 (file)
@@ -29,13 +29,13 @@ public:
     // Hack to force inclusion of TextureBuilder.cxx in library
     static osg::Texture* buildFromType(Effect* effect, const std::string& type,
                                        const SGPropertyNode*props,
-                                       const osgDB::ReaderWriter::Options* options);
+                                       const SGReaderWriterXMLOptions* options);
 };
 
 struct TextureUnitBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const osgDB::ReaderWriter::Options* options);
+                        const SGReaderWriterXMLOptions* options);
 };
 
 
index 1a8efcdbb058912c2e95f3b2bc16073ee8403dcf..4ce5841f5d2a0ae303862dc133e6396dca0bb928 100644 (file)
@@ -31,6 +31,7 @@
 #include <osgDB/Registry>
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/SplicingVisitor.hxx>
@@ -116,7 +117,7 @@ void mergePropertyTrees(SGPropertyNode* resultNode,
 
 Effect* makeEffect(const string& name,
                    bool realizeTechniques,
-                   const osgDB::ReaderWriter::Options* options)
+                   const SGReaderWriterXMLOptions* options)
 {
     {
         OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
@@ -159,7 +160,7 @@ Effect* makeEffect(const string& name,
 
 Effect* makeEffect(SGPropertyNode* prop,
                    bool realizeTechniques,
-                   const osgDB::ReaderWriter::Options* options)
+                   const SGReaderWriterXMLOptions* options)
 {
     // Give default names to techniques and passes
     vector<SGPropertyNode_ptr> techniques = prop->getChildren("technique");
index 2fc7e9c84c3573c09a958419fbff39ca08e21c5a..5947579e1f5c4af23d94d222aa4945791a75ffb2 100644 (file)
@@ -49,6 +49,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
@@ -68,12 +69,12 @@ using namespace simgear;
 ////////////////////////////////////////////////////////////////////////
 
 SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
-                                             const osgDB::ReaderWriter::Options* o ) :
-  effect(e), texture_path(t), effect_realized(l), options(o)
+                                             const SGReaderWriterXMLOptions* o)
+    : effect(e), texture_path(t), effect_realized(l), options(o)
 {
 }
 
-SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
+SGMaterial::SGMaterial( const SGReaderWriterXMLOptions* options,
                         const SGPropertyNode *props )
 {
     init();
@@ -81,6 +82,17 @@ SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
     buildEffectProperties(options);
 }
 
+SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
+                        const SGPropertyNode *props )
+{
+    osg::ref_ptr<const SGReaderWriterXMLOptions> sgOptions;
+    if (options)
+        sgOptions = new SGReaderWriterXMLOptions(*options);
+    init();
+    read_properties( sgOptions.get(), props );
+    buildEffectProperties(sgOptions.get());
+}
+
 SGMaterial::~SGMaterial (void)
 {
 }
@@ -91,7 +103,7 @@ SGMaterial::~SGMaterial (void)
 ////////////////////////////////////////////////////////////////////////
 
 void
-SGMaterial::read_properties(const osgDB::ReaderWriter::Options* options,
+SGMaterial::read_properties(const SGReaderWriterXMLOptions* options,
                             const SGPropertyNode *props)
 {
                                // Gather the path(s) to the texture(s)
@@ -245,10 +257,12 @@ Effect* SGMaterial::get_effect(int n)
     return _status[i].effect.get();
 }
 
-void SGMaterial::buildEffectProperties(const osgDB::ReaderWriter::Options*
-                                       options)
+void SGMaterial::buildEffectProperties(const SGReaderWriterXMLOptions* options)
 {
     using namespace osg;
+    ref_ptr<SGReaderWriterXMLOptions> xmlOptions;
+    if (options)
+        xmlOptions = new SGReaderWriterXMLOptions(*options);
     ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
     SGPropertyNode_ptr propRoot = new SGPropertyNode();
     makeChild(propRoot, "inherits-from")->setStringValue(effect);
@@ -279,7 +293,7 @@ void SGMaterial::buildEffectProperties(const osgDB::ReaderWriter::Options*
             ->setStringValue(wrapu ? "repeat" : "clamp");
         makeChild(texProp, "wrap-t")
             ->setStringValue(wrapv ? "repeat" : "clamp");
-        matState.effect = makeEffect(effectProp, false, options);
+        matState.effect = makeEffect(effectProp, false, xmlOptions.get());
         matState.effect->setUserData(user.get());
     }
 }
index ac2e5f1bb26d6343b708e82a63f56c9e5fed673c..619ae8dae08bae9c62ccfb1ad68c1a7b8c071eea 100644 (file)
 #include <simgear/math/SGMath.hxx>
 
 #include <osg/ref_ptr>
-#include <osgDB/ReaderWriter>
 
 namespace osg
 {
 class StateSet;
 }
 
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
@@ -87,6 +87,8 @@ public:
    */
   SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
 
+  SGMaterial(const simgear::SGReaderWriterXMLOptions*,
+             const SGPropertyNode *props);
   /**
    * Destructor.
    */
@@ -271,11 +273,11 @@ protected:
 
   struct _internal_state {
       _internal_state(simgear::Effect *e, const std::string &t, bool l,
-                      const osgDB::ReaderWriter::Options *o);
+                      const simgear::SGReaderWriterXMLOptions *o);
       osg::ref_ptr<simgear::Effect> effect;
       std::string texture_path;
       bool effect_realized;
-      osg::ref_ptr<const osgDB::ReaderWriter::Options> options;
+      osg::ref_ptr<const simgear::SGReaderWriterXMLOptions> options;
   };
 
 private:
@@ -361,9 +363,9 @@ private:
   // Internal constructors and methods.
   ////////////////////////////////////////////////////////////////////
 
-  void read_properties(const osgDB::ReaderWriter::Options* options,
+  void read_properties(const simgear::SGReaderWriterXMLOptions* options,
                         const SGPropertyNode *props);
-  void buildEffectProperties(const osgDB::ReaderWriter::Options* options);
+  void buildEffectProperties(const simgear::SGReaderWriterXMLOptions* options);
 };
 
 
index 17532aeece9728eff39d755478d08ff63f0780fa..cca34824d82cc7d57d249d69427246470a4cf180 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef SGREADERWRITERXMLOPTIONS_HXX
 #define SGREADERWRITERXMLOPTIONS_HXX 1
 
-#include <osgDB/ReaderWriter>
+#include <osgDB/Registry>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/props/props.hxx>
 
index 59f33694956d600a31858e939f93bae7fd17a568..1ea486f0d13afc5b1dae4353c449539f77df3d85 100644 (file)
@@ -33,6 +33,7 @@
 #include <simgear/props/props_io.hxx>
 #include <simgear/props/condition.hxx>
 
+#include "SGReaderWriterXMLOptions.hxx"
 #include "model.hxx"
 
 using std::vector;
@@ -209,7 +210,7 @@ class MakeEffectVisitor : public SplicingVisitor
 public:
     typedef std::map<string, SGPropertyNode_ptr> EffectMap;
     using SplicingVisitor::apply;
-    MakeEffectVisitor(const osgDB::ReaderWriter::Options* options = 0)
+    MakeEffectVisitor(const SGReaderWriterXMLOptions* options = 0)
         : _options(options)
     {
     }
@@ -225,7 +226,7 @@ public:
 protected:
     EffectMap _effectMap;
     SGPropertyNode_ptr _currentEffectParent;
-    osg::ref_ptr<const osgDB::ReaderWriter::Options> _options;
+    osg::ref_ptr<const SGReaderWriterXMLOptions> _options;
 };
 
 void MakeEffectVisitor::apply(osg::Group& node)
@@ -302,7 +303,7 @@ protected:
 
 ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
                                  PropertyList& effectProps,
-                                 const osgDB::ReaderWriter::Options* options)
+                                 const SGReaderWriterXMLOptions* options)
 {
     SGPropertyNode_ptr defaultEffectPropRoot;
     MakeEffectVisitor visitor(options);
index 49dc0666e1307ee9245ab0e4f93bde30c9624915..c2097fdcd52930cab553b80cd5cae13b53cc4ea7 100644 (file)
 #include <simgear/props/props.hxx>
 #include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
 
+namespace simgear
+{
+class SGReaderWriterXMLOptions;
+}
+
 osg::Texture2D*
 SGLoadTexture2D(bool staticTexture, const std::string& path,
                 const osgDB::ReaderWriter::Options* options = 0,
@@ -97,7 +102,7 @@ public:
 osg::ref_ptr<osg::Node>
 instantiateEffects(osg::Node* model,
                    PropertyList& effectProps,
-                   const osgDB::ReaderWriter::Options* options);
+                   const SGReaderWriterXMLOptions* options);
 
 /**
  * Transform an OSG subgraph by substituting the Effects and
@@ -110,7 +115,7 @@ instantiateEffects(osg::Node* model,
 
 inline osg::ref_ptr<osg::Node>
 instantiateEffects(osg::Node* model,
-                   const osgDB::ReaderWriter::Options* options)
+                   const SGReaderWriterXMLOptions* options)
 {
     PropertyList effectProps;
     return instantiateEffects(model, effectProps, options);
index 6a13c516fdfbe5a10a15f870665d823a6be70535..4b457f5e48bc2aeece69d10e7e44acbfb07bd882 100644 (file)
@@ -71,8 +71,12 @@ osg::Node* loadFile(const string& path, osgDB::ReaderWriter::Options* options)
     ref_ptr<Node> model = readRefNodeFile(path, options);
     if (!model)
         return 0;
-    if (boost::iends_with(path, ".ac"))
-        model = instantiateEffects(model.get(), options);
+    if (boost::iends_with(path, ".ac")) {
+        ref_ptr<SGReaderWriterXMLOptions> sgOptions;
+        if (options)
+            sgOptions = new SGReaderWriterXMLOptions(*options);
+        model = instantiateEffects(model.get(), sgOptions.get());
+    }
      return model.release();
 }
 }
index 162f137a0c58c38941c449d99cbdd2d27fe88f1d..6d35ad998b224074b7ebe08d8385f7c8bb38986a 100644 (file)
@@ -46,6 +46,7 @@
 #include <simgear/misc/PathOptions.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/scene/model/model.hxx>
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/scene/util/SGUpdateVisitor.hxx>
 
@@ -108,9 +109,11 @@ SGNewCloud::SGNewCloud(string type,
                                      "texture"),
                            "image"),
                  texture);
-        osg::ref_ptr<osgDB::ReaderWriter::Options> options
+        ref_ptr<osgDB::ReaderWriter::Options> options
             = makeOptionsFromPath(tex_path);
-        if ((effect = makeEffect(pcloudEffect, true, options)))
+        ref_ptr<SGReaderWriterXMLOptions> sgOptions
+            = new SGReaderWriterXMLOptions(*options.get());
+        if ((effect = makeEffect(pcloudEffect, true, sgOptions.get())))
             effectMap.insert(EffectMap::value_type(texture, effect));
     } else {
         effect = iter->second.get();