]> git.mxchange.org Git - simgear.git/commitdiff
Consolidate the different ReaderWriterOptions classes.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 12 Nov 2011 18:39:48 +0000 (19:39 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 13 Nov 2011 17:35:18 +0000 (18:35 +0100)
28 files changed:
projects/VC90/SimGear.vcproj
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/material/mipmap.cxx
simgear/scene/material/mipmap.hxx
simgear/scene/model/CMakeLists.txt
simgear/scene/model/ModelRegistry.cxx
simgear/scene/model/SGReaderWriterXML.cxx
simgear/scene/model/SGReaderWriterXMLOptions.hxx [deleted file]
simgear/scene/model/model.cxx
simgear/scene/model/model.hxx
simgear/scene/model/modellib.cxx
simgear/scene/sky/newcloud.cxx
simgear/scene/tgdb/CMakeLists.txt
simgear/scene/tgdb/SGReaderWriterBTG.cxx
simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx [deleted file]
simgear/scene/tgdb/TileEntry.cxx
simgear/scene/tgdb/obj.cxx
simgear/scene/tgdb/obj.hxx
simgear/scene/util/CMakeLists.txt
simgear/scene/util/SGReaderWriterOptions.hxx [new file with mode: 0644]

index 7517d1cbf3c09fffaba4541ee8b4945425bcc0ea..7c2eed047a55875953db3e13e2b43115d21bb2e0 100644 (file)
                                RelativePath="..\..\simgear\scene\model\SGReaderWriterXML.hxx"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\simgear\scene\model\SGReaderWriterXMLOptions.hxx"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\simgear\scene\model\SGRotateTransform.cxx"\r
                                >\r
                                RelativePath="..\..\simgear\scene\tgdb\SGReaderWriterBTG.hxx"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\simgear\scene\tgdb\SGReaderWriterBTGOptions.hxx"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\simgear\scene\tgdb\SGVasiDrawable.cxx"\r
                                >\r
index 1a52c65948e97363f3397591c50892df05dfe598..aa221fcc65687c5ea6a55af6ecd9c1b618c0e5ac 100644 (file)
@@ -67,7 +67,7 @@
 #include <osgDB/ReadFile>
 #include <osgDB/Registry>
 
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
@@ -154,7 +154,7 @@ Effect::~Effect()
 }
 
 void buildPass(Effect* effect, Technique* tniq, const SGPropertyNode* prop,
-               const SGReaderWriterXMLOptions* options)
+               const SGReaderWriterOptions* options)
 {
     Pass* pass = new Pass;
     tniq->passes.push_back(pass);
@@ -203,12 +203,12 @@ osg::Vec4f getColor(const SGPropertyNode* prop)
 struct LightingBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options);
+                        const SGReaderWriterOptions* options);
 };
 
 void LightingBuilder::buildAttribute(Effect* effect, Pass* pass,
                                      const SGPropertyNode* prop,
-                                     const SGReaderWriterXMLOptions* options)
+                                     const SGReaderWriterOptions* options)
 {
     const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
     if (!realProp)
@@ -222,7 +222,7 @@ InstallAttributeBuilder<LightingBuilder> installLighting("lighting");
 struct ShadeModelBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -244,7 +244,7 @@ InstallAttributeBuilder<ShadeModelBuilder> installShadeModel("shade-model");
 struct CullFaceBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp) {
@@ -272,7 +272,7 @@ InstallAttributeBuilder<CullFaceBuilder> installCullFace("cull-face");
 struct ColorMaskBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -299,7 +299,7 @@ EffectPropertyMap<StateSet::RenderingHint> renderingHints(renderingHintInit);
 struct HintBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -315,7 +315,7 @@ InstallAttributeBuilder<HintBuilder> installHint("rendering-hint");
 struct RenderBinBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -342,7 +342,7 @@ InstallAttributeBuilder<RenderBinBuilder> installRenderBin("render-bin");
 struct MaterialBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options);
+                        const SGReaderWriterOptions* options);
 };
 
 EffectNameValue<Material::ColorMode> colorModeInit[] =
@@ -358,7 +358,7 @@ EffectPropertyMap<Material::ColorMode> colorModes(colorModeInit);
 
 void MaterialBuilder::buildAttribute(Effect* effect, Pass* pass,
                                      const SGPropertyNode* prop,
-                                     const SGReaderWriterXMLOptions* options)
+                                     const SGReaderWriterOptions* options)
 {
     if (!isAttributeActive(effect, prop))
         return;
@@ -428,7 +428,7 @@ EffectPropertyMap<BlendFunc::BlendFuncMode> blendFuncModes(blendFuncModesInit);
 struct BlendBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -541,7 +541,7 @@ EffectPropertyMap<Stencil::Operation> stencilOperation(stencilOperationInit);
 struct StencilBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -619,7 +619,7 @@ alphaComparison(alphaComparisonInit);
 struct AlphaTestBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -736,7 +736,7 @@ void reload_shaders()
 struct ShaderProgramBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options);
+                        const SGReaderWriterOptions* options);
 };
 
 
@@ -763,7 +763,7 @@ geometryOutputType(geometryOutputTypeInit);
 
 void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
                                           const SGPropertyNode* prop,
-                                          const SGReaderWriterXMLOptions*
+                                          const SGReaderWriterOptions*
                                           options)
 {
     using namespace boost;
@@ -899,7 +899,7 @@ ref_ptr<Uniform> colorMode[3];
 struct UniformBuilder :public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!texture0.valid()) {
             texture0 = new Uniform(Uniform::SAMPLER_2D, "texture");
@@ -1013,7 +1013,7 @@ InstallAttributeBuilder<UniformBuilder> installUniform("uniform");
 struct NameBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         // name can't use <use>
         string name = prop->getStringValue();
@@ -1035,7 +1035,7 @@ EffectPropertyMap<PolygonMode::Mode> polygonModeModes(polygonModeModesInit);
 struct PolygonModeBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -1063,7 +1063,7 @@ InstallAttributeBuilder<PolygonModeBuilder> installPolygonMode("polygon-mode");
 struct PolygonOffsetBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -1091,7 +1091,7 @@ InstallAttributeBuilder<PolygonOffsetBuilder> installPolygonOffset("polygon-offs
 struct VertexProgramTwoSideBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -1108,7 +1108,7 @@ installTwoSide("vertex-program-two-side");
 struct VertexProgramPointSizeBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
         if (!realProp)
@@ -1138,7 +1138,7 @@ EffectPropertyMap<Depth::Function> depthFunction(depthFunctionInit);
 struct DepthBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options)
+                        const SGReaderWriterOptions* options)
     {
         if (!isAttributeActive(effect, prop))
             return;
@@ -1169,7 +1169,7 @@ struct DepthBuilder : public PassAttributeBuilder
 InstallAttributeBuilder<DepthBuilder> installDepth("depth");
 
 void buildTechnique(Effect* effect, const SGPropertyNode* prop,
-                    const SGReaderWriterXMLOptions* options)
+                    const SGReaderWriterOptions* options)
 {
     Technique* tniq = new Technique;
     effect->techniques.push_back(tniq);
@@ -1278,7 +1278,7 @@ bool makeParametersFromStateSet(SGPropertyNode* effectRoot, const StateSet* ss)
 
 // Walk the techniques property tree, building techniques and
 // passes.
-bool Effect::realizeTechniques(const SGReaderWriterXMLOptions* options)
+bool Effect::realizeTechniques(const SGReaderWriterOptions* options)
 {
     if (_isRealized)
         return true;
index 59eea81d8027fe18b4d08276d21df493527e9d01..5187c5bbaccfd1a6bdbd5ac9712cb564dc23bc33 100644 (file)
@@ -45,7 +45,7 @@ namespace simgear
 {
 class Technique;
 class Effect;
-class SGReaderWriterXMLOptions;
+class SGReaderWriterOptions;
 
 /**
  * Object to be initialized at some point after an effect -- and its
@@ -102,7 +102,7 @@ public:
     /**
      * Build the techniques from the effect properties.
      */
-    bool realizeTechniques(const SGReaderWriterXMLOptions* options = 0);
+    bool realizeTechniques(const SGReaderWriterOptions* options = 0);
     /**
      * Updaters that should be derefed when the effect is
      * deleted. Updaters arrange to be run by listening on properties
@@ -157,7 +157,7 @@ protected:
     Cache* _cache;
     friend size_t hash_value(const Key& key);
     friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
-                              const SGReaderWriterXMLOptions* options);
+                              const SGReaderWriterOptions* options);
     bool _isRealized;
 };
 // Automatic support for boost hash function
@@ -166,11 +166,11 @@ size_t hash_value(const Effect::Key&);
 
 Effect* makeEffect(const std::string& name,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options = 0);
+                   const SGReaderWriterOptions* options = 0);
 
 Effect* makeEffect(SGPropertyNode* prop,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options = 0);
+                   const SGReaderWriterOptions* options = 0);
 
 bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
                                 const osg::StateSet* ss);
index 79ebb2482bb1d9b21c1907ed13fc204ccb12d289..635fde3608c7fd82b6111aaa88de2fdca7598339 100644 (file)
@@ -2,7 +2,7 @@
 #  include <simgear_config.h>
 #endif
 
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 
 #include <simgear/math/SGMath.hxx>
@@ -43,7 +43,7 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
 }
 
 string getGlobalProperty(const SGPropertyNode* prop,
-                         const SGReaderWriterXMLOptions* options)
+                         const SGReaderWriterOptions* options)
 {
     if (!prop)
         return string();
@@ -54,7 +54,7 @@ string getGlobalProperty(const SGPropertyNode* prop,
     SGPropertyNode_ptr propRoot;
     if (propName[0] == '/') {
         return propName;
-    } else if ((propRoot = options->getPropRoot())) {
+    } else if ((propRoot = options->getPropertyNode())) {
         string result = propRoot->getPath();
         result.append("/");
         result.append(propName);
index 3165ae1829935995e505682ebf9b80edebe0fcbc..a464071f717b27712e75679a9dadf4d75e1bd6af 100644 (file)
@@ -34,7 +34,7 @@
 #include <simgear/math/SGMath.hxx>
 #include <simgear/props/AtomicChangeListener.hxx>
 #include <simgear/props/props.hxx>
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/structure/Singleton.hxx>
@@ -48,7 +48,7 @@ namespace simgear
 {
 class Effect;
 class Pass;
-class SGReaderWriterXMLOptions;
+class SGReaderWriterOptions;
 
 /**
  * Builder that returns an object, probably an OSG object.
@@ -59,10 +59,10 @@ class EffectBuilder : public SGReferenced
 public:
     virtual ~EffectBuilder() {}
     virtual T* build(Effect* effect, const SGPropertyNode*,
-                     const SGReaderWriterXMLOptions* options) = 0;
+                     const SGReaderWriterOptions* options) = 0;
     static T* buildFromType(Effect* effect, const std::string& type,
                             const SGPropertyNode*props,
-                            const SGReaderWriterXMLOptions* options)
+                            const SGReaderWriterOptions* options)
     {
         BuilderMap& builderMap = getMap();
         typename BuilderMap::iterator iter = builderMap.find(type);
@@ -302,12 +302,12 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
  * mentioned node name.
  */
 std::string getGlobalProperty(const SGPropertyNode* prop,
-                              const SGReaderWriterXMLOptions *);
+                              const SGReaderWriterOptions *);
 
 template<typename NameItr>
 std::vector<std::string>
 getVectorProperties(const SGPropertyNode* prop,
-                    const SGReaderWriterXMLOptions *options, size_t vecSize,
+                    const SGReaderWriterOptions *options, size_t vecSize,
                     NameItr defaultNames)
 {
     using namespace std;
@@ -318,7 +318,7 @@ getVectorProperties(const SGPropertyNode* prop,
     if (useProps.size() == 1) {
         string parentName = useProps[0]->getStringValue();
         if (parentName.size() == 0 || parentName[0] != '/')
-            parentName = options->getPropRoot()->getPath() + "/" + parentName;
+            parentName = options->getPropertyNode()->getPath() + "/" + parentName;
         if (parentName[parentName.size() - 1] != '/')
             parentName.append("/");
         NameItr itr = defaultNames;
@@ -357,7 +357,7 @@ public:
   
     virtual void buildAttribute(Effect* effect, Pass* pass,
                                 const SGPropertyNode* prop,
-                                const SGReaderWriterXMLOptions* options)
+                                const SGReaderWriterOptions* options)
     = 0;
     static PassAttributeBuilder* find(const std::string& str)
     {
@@ -610,7 +610,7 @@ inline void setDynamicVariance(osg::Object* obj)
 template<typename OSGParamType, typename ObjType, typename F>
 void
 initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
-                   const F& setter, const SGReaderWriterXMLOptions* options)
+                   const F& setter, const SGReaderWriterOptions* options)
 {
     const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
     if (!valProp)
@@ -631,7 +631,7 @@ template<typename OSGParamType, typename ObjType, typename SetterReturn>
 inline void
 initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
                    SetterReturn (ObjType::*setter)(const OSGParamType),
-                   const SGReaderWriterXMLOptions* options)
+                   const SGReaderWriterOptions* options)
 {
     initFromParameters<OSGParamType>(effect, prop, obj,
                                      boost::bind(setter, _1, _2), options);
@@ -661,7 +661,7 @@ template<typename OSGParamType, typename ObjType, typename NameItrType,
 void
 initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
                    const F& setter,
-                   NameItrType nameItr, const SGReaderWriterXMLOptions* options)
+                   NameItrType nameItr, const SGReaderWriterOptions* options)
 {
     typedef typename Bridge<OSGParamType>::sg_type sg_type;
     const int numComponents = props::NumComponents<sg_type>::num_components;
@@ -690,7 +690,7 @@ template<typename OSGParamType, typename ObjType, typename NameItrType,
 inline void
 initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
                    SetterReturn (ObjType::*setter)(const OSGParamType&),
-                   NameItrType nameItr, const SGReaderWriterXMLOptions* options)
+                   NameItrType nameItr, const SGReaderWriterOptions* options)
 {
     initFromParameters<OSGParamType>(effect, prop, obj,
                                      boost::bind(setter, _1, _2), nameItr,
index f53fe5265910acdae34eef9b29e57c1317793904..69630b3116428790c0e3ca3cde4fe0782d9cef01 100644 (file)
@@ -37,7 +37,7 @@
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_comparison.hpp>
 
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/math/SGMath.hxx>
@@ -54,13 +54,13 @@ using namespace effect;
 
 TexEnvCombine* buildTexEnvCombine(Effect* effect,
                                   const SGPropertyNode* envProp,
-                                  const SGReaderWriterXMLOptions* options);
+                                  const SGReaderWriterOptions* options);
 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 SGReaderWriterXMLOptions*
+                                            const SGReaderWriterOptions*
                                             options)
 {
     return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
@@ -102,7 +102,7 @@ TexEnv* buildTexEnv(Effect* effect, const SGPropertyNode* prop)
 
 void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
                                         const SGPropertyNode* prop,
-                                        const SGReaderWriterXMLOptions* options)
+                                        const SGReaderWriterOptions* options)
 {
     if (!isAttributeActive(effect, prop))
         return;
@@ -183,7 +183,7 @@ EffectNameValue<Texture::WrapMode> wrapModesInit[] =
 EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
 
 TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
-                      const SGReaderWriterXMLOptions* options,
+                      const SGReaderWriterOptions* options,
                       const string& texType)
 {
     Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
@@ -234,7 +234,7 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
 }
 
 void setAttrs(const TexTuple& attrs, Texture* tex,
-              const SGReaderWriterXMLOptions* options)
+              const SGReaderWriterOptions* options)
 {
     const string& imageName = attrs.get<0>();
     if (imageName.empty()) {
@@ -275,7 +275,7 @@ class TexBuilder : public TextureBuilder
 public:
     TexBuilder(const string& texType) : _type(texType) {}
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 protected:
     typedef map<TexTuple, ref_ptr<T> > TexMap;
     TexMap texMap;
@@ -284,7 +284,7 @@ protected:
 
 template<typename T>
 Texture* TexBuilder<T>::build(Effect* effect, const SGPropertyNode* props,
-                              const SGReaderWriterXMLOptions* options)
+                              const SGReaderWriterOptions* options)
 {
     TexTuple attrs = makeTexTuple(effect, props, options, _type);
     typename TexMap::iterator itr = texMap.find(attrs);
@@ -308,11 +308,11 @@ class WhiteTextureBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 };
 
 Texture* WhiteTextureBuilder::build(Effect* effect, const SGPropertyNode*,
-                                    const SGReaderWriterXMLOptions* options)
+                                    const SGReaderWriterOptions* options)
 {
     return StateAttributeFactory::instance()->getWhiteTexture();
 }
@@ -326,11 +326,11 @@ class TransparentTextureBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 };
 
 Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
-                                    const SGReaderWriterXMLOptions* options)
+                                    const SGReaderWriterOptions* options)
 {
     return StateAttributeFactory::instance()->getTransparentTexture();
 }
@@ -390,14 +390,14 @@ class NoiseBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 protected:
     typedef map<int, ref_ptr<Texture3D> > NoiseMap;
     NoiseMap _noises;
 };
 
 Texture* NoiseBuilder::build(Effect* effect, const SGPropertyNode* props,
-                             const SGReaderWriterXMLOptions* options)
+                             const SGReaderWriterOptions* options)
 {
     int texSize = 64;
     const SGPropertyNode* sizeProp = getEffectPropertyChild(effect, props,
@@ -458,7 +458,7 @@ class CubeMapBuilder : public TextureBuilder
 {
 public:
     Texture* build(Effect* effect, const SGPropertyNode*,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 protected:
     typedef map<CubeMapTuple, ref_ptr<TextureCubeMap> > CubeMap;
     typedef map<string, ref_ptr<TextureCubeMap> > CrossCubeMap;
@@ -481,7 +481,7 @@ void copySubImage(const osg::Image* srcImage, int src_s, int src_t, int width, i
 
 
 Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
-                               const SGReaderWriterXMLOptions* options)
+                               const SGReaderWriterOptions* options)
 {
     // First check that there is a <images> tag
     const SGPropertyNode* texturesProp = getEffectPropertyChild(effect, props, "images");
@@ -690,7 +690,7 @@ EffectNameValue<TexEnvCombine::OperandParam> opParamInit[] =
 EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
 
 TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
-                                  const SGReaderWriterXMLOptions* options)
+                                  const SGReaderWriterOptions* options)
 {
     if (!isAttributeActive(effect, envProp))
         return 0;
index 55df27360e178bb531a9d83afc0502050917ab9e..c8105e750b58385b571be804a3e402a55bab7adb 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 SGReaderWriterXMLOptions* options);
+                                       const SGReaderWriterOptions* options);
 };
 
 struct TextureUnitBuilder : public PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
-                        const SGReaderWriterXMLOptions* options);
+                        const SGReaderWriterOptions* options);
 };
 
 
index 02ac244f8c016a158b268b037480f0aef39013d2..477328ff495daf649680573c2218cdb249870582 100644 (file)
@@ -31,7 +31,7 @@
 #include <osgDB/Registry>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/SplicingVisitor.hxx>
@@ -117,7 +117,7 @@ void mergePropertyTrees(SGPropertyNode* resultNode,
 
 Effect* makeEffect(const string& name,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options)
+                   const SGReaderWriterOptions* options)
 {
     {
         OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
@@ -160,7 +160,7 @@ Effect* makeEffect(const string& name,
 
 Effect* makeEffect(SGPropertyNode* prop,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options)
+                   const SGReaderWriterOptions* options)
 {
     // Give default names to techniques and passes
     vector<SGPropertyNode_ptr> techniques = prop->getChildren("technique");
index fcd95da3d37eeee52e19d688e5cbeb95709eb47e..f70a9a3b43341538f4c364d4be34e8d987283dd3 100644 (file)
@@ -49,7 +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/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
@@ -69,13 +69,13 @@ using namespace simgear;
 ////////////////////////////////////////////////////////////////////////
 
 SGMaterial::_internal_state::_internal_state(Effect *e, bool l,
-                                             const SGReaderWriterXMLOptions* o)
+                                             const SGReaderWriterOptions* o)
     : effect(e), effect_realized(l), options(o)
 {
 }
 
 SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
-                                             const SGReaderWriterXMLOptions* o)
+                                             const SGReaderWriterOptions* o)
     : effect(e), effect_realized(l), options(o)
 {
     texture_paths.push_back(std::make_pair(t,0));
@@ -86,7 +86,7 @@ void SGMaterial::_internal_state::add_texture(const std::string &t, int i)
     texture_paths.push_back(std::make_pair(t,i));
 }
 
-SGMaterial::SGMaterial( const SGReaderWriterXMLOptions* options,
+SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
                         const SGPropertyNode *props )
 {
     init();
@@ -97,9 +97,9 @@ SGMaterial::SGMaterial( const SGReaderWriterXMLOptions* options,
 SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
                         const SGPropertyNode *props )
 {
-    osg::ref_ptr<const SGReaderWriterXMLOptions> sgOptions;
+    osg::ref_ptr<const SGReaderWriterOptions> sgOptions;
     if (options)
-        sgOptions = new SGReaderWriterXMLOptions(*options);
+        sgOptions = new SGReaderWriterOptions(*options);
     init();
     read_properties( sgOptions.get(), props );
     buildEffectProperties(sgOptions.get());
@@ -115,7 +115,7 @@ SGMaterial::~SGMaterial (void)
 ////////////////////////////////////////////////////////////////////////
 
 void
-SGMaterial::read_properties(const SGReaderWriterXMLOptions* options,
+SGMaterial::read_properties(const SGReaderWriterOptions* options,
                             const SGPropertyNode *props)
 {
                                // Gather the path(s) to the texture(s)
@@ -296,12 +296,12 @@ Effect* SGMaterial::get_effect(int n)
     return _status[i].effect.get();
 }
 
-void SGMaterial::buildEffectProperties(const SGReaderWriterXMLOptions* options)
+void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
 {
     using namespace osg;
-    ref_ptr<SGReaderWriterXMLOptions> xmlOptions;
+    ref_ptr<SGReaderWriterOptions> xmlOptions;
     if (options)
-        xmlOptions = new SGReaderWriterXMLOptions(*options);
+        xmlOptions = new SGReaderWriterOptions(*options);
     ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
     SGPropertyNode_ptr propRoot = new SGPropertyNode();
     makeChild(propRoot, "inherits-from")->setStringValue(effect);
index 9e2d06e432d58d7f490a85c4222040ab4f87ece2..06e72b725658dd2b813dfe8e1520e23c2aa52c9b 100644 (file)
@@ -45,7 +45,7 @@ namespace osg
 class StateSet;
 }
 
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/scene/util/SGSceneFeatures.hxx>
@@ -87,7 +87,7 @@ public:
    */
   SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
 
-  SGMaterial(const simgear::SGReaderWriterXMLOptions*,
+  SGMaterial(const simgear::SGReaderWriterOptions*,
              const SGPropertyNode *props);
   /**
    * Destructor.
@@ -273,14 +273,14 @@ protected:
 
   struct _internal_state {
       _internal_state(simgear::Effect *e, bool l,
-                      const simgear::SGReaderWriterXMLOptions *o);
+                      const simgear::SGReaderWriterOptions *o);
       _internal_state(simgear::Effect *e, const std::string &t, bool l,
-                      const simgear::SGReaderWriterXMLOptions *o);
+                      const simgear::SGReaderWriterOptions *o);
       void add_texture(const std::string &t, int i);
       osg::ref_ptr<simgear::Effect> effect;
       std::vector<std::pair<std::string,int> > texture_paths;
       bool effect_realized;
-      osg::ref_ptr<const simgear::SGReaderWriterXMLOptions> options;
+      osg::ref_ptr<const simgear::SGReaderWriterOptions> options;
   };
 
 private:
@@ -366,9 +366,9 @@ private:
   // Internal constructors and methods.
   ////////////////////////////////////////////////////////////////////
 
-  void read_properties(const simgear::SGReaderWriterXMLOptions* options,
+  void read_properties(const simgear::SGReaderWriterOptions* options,
                         const SGPropertyNode *props);
-  void buildEffectProperties(const simgear::SGReaderWriterXMLOptions* options);
+  void buildEffectProperties(const simgear::SGReaderWriterOptions* options);
 };
 
 
index b3ddd02d74eb54cc6bddac9635cc3761f741db1a..59a800daaee2334531dea116e0459673f1b87972 100644 (file)
@@ -44,7 +44,7 @@ EffectNameValue<MipMapFunction> mipmapFunctionsInit[] =
 EffectPropertyMap<MipMapFunction> mipmapFunctions(mipmapFunctionsInit);
 
 MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
-                      const SGReaderWriterXMLOptions* options)
+                      const SGReaderWriterOptions* options)
 {
     const SGPropertyNode* pMipmapR
         = getEffectPropertyChild(effect, props, "function-r");
index 747592e778ab75c9d7f44349a37988e51591f845..0a908c5975ac39e2a631e7104b47f292dcd2b9d5 100644 (file)
@@ -28,7 +28,7 @@ namespace osg {
 namespace simgear
 {
 class Effect;
-class SGReaderWriterXMLOptions;
+class SGReaderWriterOptions;
 
 namespace effect {
 enum MipMapFunction {
@@ -43,7 +43,7 @@ enum MipMapFunction {
 typedef boost::tuple<MipMapFunction, MipMapFunction, MipMapFunction, MipMapFunction> MipMapTuple;
 
 MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
-                      const SGReaderWriterXMLOptions* options);
+                      const SGReaderWriterOptions* options);
 osg::Image* computeMipmap( osg::Image* image, MipMapTuple attrs );
 } }
 
index 37ca27ffbc9d0d15bceccd828689fb81e4c054aa..8977a7f9427073b084a331854a1137b60e249f61 100644 (file)
@@ -10,7 +10,6 @@ set(HEADERS
     SGMaterialAnimation.hxx
     SGOffsetTransform.hxx
     SGReaderWriterXML.hxx
-    SGReaderWriterXMLOptions.hxx
     SGRotateTransform.hxx
     SGScaleTransform.hxx
     SGText.hxx
index a4fb94c9fc2b6561ffca032da2e56fef961d3bd5..4cb710f44d3e0f2100547e50da954d2095f70a85 100644 (file)
@@ -47,6 +47,7 @@
 #include <simgear/scene/util/SGSceneFeatures.hxx>
 #include <simgear/scene/util/SGStateAttributeVisitor.hxx>
 #include <simgear/scene/util/SGTextureStateAttributeVisitor.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
 
 #include <simgear/structure/exception.hxx>
@@ -56,7 +57,6 @@
 
 #include "BoundingVolumeBuildVisitor.hxx"
 #include "model.hxx"
-#include "SGReaderWriterXMLOptions.hxx"
 
 using namespace std;
 using namespace osg;
@@ -410,8 +410,8 @@ struct ACOptimizePolicy : public OptimizeModelPolicy {
                 && group->getNumChildren() == 1)
                 optimized = static_cast<Node*>(group->getChild(0));
         }
-        const SGReaderWriterXMLOptions* sgopt
-            = dynamic_cast<const SGReaderWriterXMLOptions*>(opt);
+        const SGReaderWriterOptions* sgopt
+            = dynamic_cast<const SGReaderWriterOptions*>(opt);
         if (sgopt && sgopt->getInstantiateEffects())
             optimized = instantiateEffects(optimized.get(), sgopt);
         return optimized.release();
index ab128df9adbec548ae999d267f5bbd23bb19fe81..81ccd85a52b49d95d09e128938deeeca2e8ef2d4 100644 (file)
 #include <simgear/props/props_io.hxx>
 #include <simgear/props/condition.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
 #include "modellib.hxx"
 #include "SGReaderWriterXML.hxx"
-#include "SGReaderWriterXMLOptions.hxx"
 
 #include "animation.hxx"
 #include "particles.hxx"
@@ -207,8 +207,8 @@ sgLoad3DModel_internal(const SGPath& path,
       return NULL;
     }
     
-    const SGReaderWriterXMLOptions* xmlOptions;
-    xmlOptions = dynamic_cast<const SGReaderWriterXMLOptions*>(options_);
+    const SGReaderWriterOptions* xmlOptions;
+    xmlOptions = dynamic_cast<const SGReaderWriterOptions*>(options_);
 
     SGSharedPtr<SGPropertyNode> prop_root;
     osg::Node *(*load_panel)(SGPropertyNode *)=0;
@@ -218,7 +218,7 @@ sgLoad3DModel_internal(const SGPath& path,
     SGPath modelDir(modelpath.dir());
     
     if (xmlOptions) {
-        prop_root = xmlOptions->getPropRoot();
+        prop_root = xmlOptions->getPropertyNode();
         load_panel = xmlOptions->getLoadPanel();
         data = xmlOptions->getModelData();
     }
@@ -268,9 +268,9 @@ sgLoad3DModel_internal(const SGPath& path,
         // model without wrapper
     }
 
-    osg::ref_ptr<SGReaderWriterXMLOptions> options
-    = new SGReaderWriterXMLOptions(*options_);
-    options->setPropRoot(prop_root);
+    osg::ref_ptr<SGReaderWriterOptions> options
+    = new SGReaderWriterOptions(*options_);
+    options->setPropertyNode(prop_root);
     options->setLoadPanel(load_panel);
     
     // Assume that textures are in
@@ -353,9 +353,9 @@ sgLoad3DModel_internal(const SGPath& path,
           continue;
         }
 
-        osg::ref_ptr<SGReaderWriterXMLOptions> options;
-        options = new SGReaderWriterXMLOptions(*options_);
-        options->setPropRoot(prop_root);
+        osg::ref_ptr<SGReaderWriterOptions> options;
+        options = new SGReaderWriterOptions(*options_);
+        options->setPropertyNode(prop_root);
         options->setLoadPanel(load_panel);
         
         try {
diff --git a/simgear/scene/model/SGReaderWriterXMLOptions.hxx b/simgear/scene/model/SGReaderWriterXMLOptions.hxx
deleted file mode 100644 (file)
index 9c20361..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (C) 2007 Tim Moore timoore@redhat.com
-// Copyright (C) 2008 Till Busch buti@bux.at
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-#ifndef SGREADERWRITERXMLOPTIONS_HXX
-#define SGREADERWRITERXMLOPTIONS_HXX 1
-
-#include <osgDB/Registry>
-#include <simgear/scene/model/modellib.hxx>
-#include <simgear/props/props.hxx>
-
-class SGPropertyNode;
-
-namespace simgear
-{
-class SGModelData;
-
-class SGReaderWriterXMLOptions : public osgDB::ReaderWriter::Options
-{
-public:
-    typedef osg::Node *(*panel_func)(SGPropertyNode *);
-    META_Object(simgear, SGReaderWriterXMLOptions);
-
-    SGReaderWriterXMLOptions():
-        osgDB::ReaderWriter::Options(),
-        _prop_root(0),
-        _load_panel(0),
-        _model_data(0),
-        _instantiateEffects(false)
-    {}
-
-    SGReaderWriterXMLOptions(const std::string& str):
-        osgDB::ReaderWriter::Options(str),
-        _prop_root(0),
-        _load_panel(0),
-        _model_data(0),
-        _instantiateEffects(false)        
-    {}
-
-    SGReaderWriterXMLOptions(const SGReaderWriterXMLOptions& options,
-                             const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
-        osgDB::ReaderWriter::Options(options, copyop),
-        _prop_root(options._prop_root),
-        _load_panel(options._load_panel),
-        _model_data(options._model_data),
-        _instantiateEffects(options._instantiateEffects)
-    {}
-
-    SGReaderWriterXMLOptions(const osgDB::ReaderWriter::Options& options,
-                             const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
-        osgDB::ReaderWriter::Options(options, copyop),
-        _prop_root(0),
-        _load_panel(0),
-        _model_data(0),
-        _instantiateEffects(false)
-    {}
-
-    SGPropertyNode *getPropRoot() const {
-        return _prop_root;
-    }
-    panel_func getLoadPanel() const {
-        return _load_panel;
-    }
-    SGModelData *getModelData() const {
-        return _model_data.get();
-    }
-    bool getInstantiateEffects() const
-    {
-        return _instantiateEffects;
-    }
-
-    void setPropRoot(SGPropertyNode *p) {
-        _prop_root=p;
-    }
-    void setLoadPanel(panel_func pf) {
-        _load_panel=pf;
-    }
-    void setModelData(SGModelData *d) {
-        _model_data=d;
-    }
-    void setInstantiateEffects(bool doit)
-    {
-        _instantiateEffects = doit;
-    }
-    
-    
-protected:
-    virtual ~SGReaderWriterXMLOptions() {}
-
-    SGPropertyNode_ptr _prop_root;
-    osg::Node *(*_load_panel)(SGPropertyNode *);
-    osg::ref_ptr<SGModelData> _model_data;
-    bool _instantiateEffects;
-};
-
-}
-#endif
index 648b670aaf7ee4ad3032b0fb8989464f52d20027..ef9e11c6f6d040e18478d1ac3f3cac5faf74d3df 100644 (file)
@@ -25,7 +25,7 @@
 #include <simgear/scene/util/SGSceneUserData.hxx>
 #include <simgear/scene/util/CopyOp.hxx>
 #include <simgear/scene/util/SplicingVisitor.hxx>
-
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
 #include <simgear/structure/exception.hxx>
 #include <simgear/structure/Singleton.hxx>
@@ -33,7 +33,6 @@
 #include <simgear/props/props_io.hxx>
 #include <simgear/props/condition.hxx>
 
-#include "SGReaderWriterXMLOptions.hxx"
 #include "model.hxx"
 
 using std::vector;
@@ -210,7 +209,7 @@ class MakeEffectVisitor : public SplicingVisitor
 public:
     typedef std::map<string, SGPropertyNode_ptr> EffectMap;
     using SplicingVisitor::apply;
-    MakeEffectVisitor(const SGReaderWriterXMLOptions* options = 0)
+    MakeEffectVisitor(const SGReaderWriterOptions* options = 0)
         : _options(options)
     {
     }
@@ -226,7 +225,7 @@ public:
 protected:
     EffectMap _effectMap;
     SGPropertyNode_ptr _currentEffectParent;
-    osg::ref_ptr<const SGReaderWriterXMLOptions> _options;
+    osg::ref_ptr<const SGReaderWriterOptions> _options;
 };
 
 void MakeEffectVisitor::apply(osg::Group& node)
@@ -309,7 +308,7 @@ protected:
 
 ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
                                  PropertyList& effectProps,
-                                 const SGReaderWriterXMLOptions* options)
+                                 const SGReaderWriterOptions* options)
 {
     SGPropertyNode_ptr defaultEffectPropRoot;
     MakeEffectVisitor visitor(options);
index c2097fdcd52930cab553b80cd5cae13b53cc4ea7..2761d09e4699ed1a053a6754ee6ddc87df5843d5 100644 (file)
@@ -25,7 +25,7 @@
 
 namespace simgear
 {
-class SGReaderWriterXMLOptions;
+class SGReaderWriterOptions;
 }
 
 osg::Texture2D*
@@ -102,7 +102,7 @@ public:
 osg::ref_ptr<osg::Node>
 instantiateEffects(osg::Node* model,
                    PropertyList& effectProps,
-                   const SGReaderWriterXMLOptions* options);
+                   const SGReaderWriterOptions* options);
 
 /**
  * Transform an OSG subgraph by substituting the Effects and
@@ -115,7 +115,7 @@ instantiateEffects(osg::Node* model,
 
 inline osg::ref_ptr<osg::Node>
 instantiateEffects(osg::Node* model,
-                   const SGReaderWriterXMLOptions* options)
+                   const SGReaderWriterOptions* options)
 {
     PropertyList effectProps;
     return instantiateEffects(model, effectProps, options);
index 7bf6ce0f20e6503aacfaff022d83c86862bcb778..5fa40fca2e5b296f24ec315face10c32949033e0 100644 (file)
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/model/ModelRegistry.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/misc/ResourceManager.hxx>
 
 #include "SGReaderWriterXML.hxx"
-#include "SGReaderWriterXMLOptions.hxx"
 
 #include "modellib.hxx"
 
@@ -87,7 +87,7 @@ SGModelLib::~SGModelLib()
 
 namespace
 {
-osg::Node* loadFile(const string& path, SGReaderWriterXMLOptions* options)
+osg::Node* loadFile(const string& path, SGReaderWriterOptions* options)
 {
     using namespace osg;
     using namespace osgDB;
@@ -107,8 +107,8 @@ SGModelLib::loadModel(const string &path,
                        SGModelData *data,
                        bool load2DPanels)
 {
-    osg::ref_ptr<SGReaderWriterXMLOptions> opt = new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()->getOptions()));
-    opt->setPropRoot(prop_root ? prop_root: static_propRoot.get());
+    osg::ref_ptr<SGReaderWriterOptions> opt = new SGReaderWriterOptions(*(osgDB::Registry::instance()->getOptions()));
+    opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     
     if (load2DPanels) {
@@ -130,10 +130,10 @@ SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root,
     proxyNode->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER);
     proxyNode->setFileName(0, path);
 
-    osg::ref_ptr<SGReaderWriterXMLOptions> opt
-        = new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()
+    osg::ref_ptr<SGReaderWriterOptions> opt
+        = new SGReaderWriterOptions(*(osgDB::Registry::instance()
                                          ->getOptions()));
-    opt->setPropRoot(prop_root ? prop_root: static_propRoot.get());
+    opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     opt->setLoadPanel(static_panelFunc);
     if (SGPath(path).lower_extension() == "ac")
@@ -156,10 +156,10 @@ SGModelLib::loadPagedModel(const string &path, SGPropertyNode *prop_root,
     plod->setFileName(0, path);
     plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
 
-    osg::ref_ptr<SGReaderWriterXMLOptions> opt
-        = new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()
+    osg::ref_ptr<SGReaderWriterOptions> opt
+        = new SGReaderWriterOptions(*(osgDB::Registry::instance()
                                          ->getOptions()));
-    opt->setPropRoot(prop_root ? prop_root: static_propRoot.get());
+    opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     opt->setLoadPanel(static_panelFunc);
     if (SGPath(path).lower_extension() == "ac")
index 6cd0a93cdeb7945519d20a153745064e7734102c..e05301afb18f70573842e759bc393e1ad5d069de 100644 (file)
@@ -45,7 +45,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/SGReaderWriterOptions.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/scene/util/SGUpdateVisitor.hxx>
 
@@ -112,8 +112,8 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def
                  texture);
         ref_ptr<osgDB::ReaderWriter::Options> options
             = makeOptionsFromPath(texture_root);
-        ref_ptr<SGReaderWriterXMLOptions> sgOptions
-            = new SGReaderWriterXMLOptions(*options.get());
+        ref_ptr<SGReaderWriterOptions> sgOptions
+            = new SGReaderWriterOptions(*options.get());
         if ((effect = makeEffect(pcloudEffect, true, sgOptions.get())))
             effectMap.insert(EffectMap::value_type(texture, effect));
     } else {
index e9fa8359a91c992f94ad1f90e4d1fd84e5da4571..635eb9549e2c4b6675bc7a4beca85b02ce251a7c 100644 (file)
@@ -8,7 +8,6 @@ set(HEADERS
     SGModelBin.hxx
     SGOceanTile.hxx
     SGReaderWriterBTG.hxx
-    SGReaderWriterBTGOptions.hxx
     SGTexturedTriangleBin.hxx
     SGTriangleBin.hxx
     SGVasiDrawable.hxx
index ad3a6774769c0cce68afd072016bb434e914d21f..05f6d74ff713741696400c2b371c6f20781231d2 100644 (file)
@@ -19,8 +19,8 @@
 #include <osgDB/Registry>
 
 #include <simgear/scene/model/ModelRegistry.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
-#include "SGReaderWriterBTGOptions.hxx"
 #include "SGReaderWriterBTG.hxx"
 #include "obj.hxx"
 
@@ -29,6 +29,7 @@ using namespace simgear;
 SGReaderWriterBTG::SGReaderWriterBTG()
 {
     supportsExtension("btg", "SimGear btg database format");
+    // supportsExtension("btg.gz", "SimGear btg database format");
 }
 
 SGReaderWriterBTG::~SGReaderWriterBTG()
@@ -43,8 +44,8 @@ const char* SGReaderWriterBTG::className() const
 bool
 SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
 {
-    std::string lowercase_ext = osgDB::convertToLowerCase(extension);
-    if (lowercase_ext == "gz")
+    // trick the osg extensions match algorithm to accept btg.gz files.
+    if (osgDB::convertToLowerCase(extension) == "gz")
         return true;
     return osgDB::ReaderWriter::acceptsExtension(extension);
 }
@@ -54,18 +55,24 @@ SGReaderWriterBTG::readNode(const std::string& fileName,
                             const osgDB::ReaderWriter::Options* options) const
 {
     SGMaterialLib* matlib = 0;
-    bool calcLights = false;
     bool useRandomObjects = false;
     bool useRandomVegetation = false;
-    const SGReaderWriterBTGOptions* btgOptions
-        = dynamic_cast<const SGReaderWriterBTGOptions*>(options);
-    if (btgOptions) {
-        matlib = btgOptions->getMatlib();
-        calcLights = btgOptions->getCalcLights();
-        useRandomObjects = btgOptions->getUseRandomObjects();
-        useRandomVegetation = btgOptions->getUseRandomVegetation();
+    const SGReaderWriterOptions* sgOptions;
+    sgOptions = dynamic_cast<const SGReaderWriterOptions*>(options);
+    if (sgOptions) {
+        matlib = sgOptions->getMaterialLib();
+        SGPropertyNode* propertyNode = sgOptions->getPropertyNode().get();
+        if (propertyNode) {
+            useRandomObjects
+                = propertyNode->getBoolValue("/sim/rendering/random-objects",
+                                             useRandomObjects);
+            useRandomVegetation
+                = propertyNode->getBoolValue("/sim/rendering/random-vegetation",
+                                             useRandomVegetation);
+        }
     }
-    osg::Node* result = SGLoadBTG(fileName, matlib, calcLights,
+
+    osg::Node* result = SGLoadBTG(fileName, matlib,
                                   useRandomObjects,
                                   useRandomVegetation);
     if (result)
diff --git a/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx b/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx
deleted file mode 100644 (file)
index 097d3fc..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2007 Tim Moore timoore@redhat.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-#ifndef SGREADERWRITERBTGOPTIONS_HXX
-#define SGREADERWRITERBTGOPTIONS_HXX
-
-#include <osgDB/ReaderWriter>
-#include <simgear/scene/tgdb/obj.hxx>
-class SGReaderWriterBTGOptions : public osgDB::ReaderWriter::Options {
-public:
-    META_Object(simgear,SGReaderWriterBTGOptions);
-    SGReaderWriterBTGOptions(const std::string& str = std::string()) :
-        osgDB::ReaderWriter::Options(str),
-        _matlib(0), _calcLights(true),
-        _useRandomObjects(false),
-        _useRandomVegetation(false)
-    {}
-
-    SGReaderWriterBTGOptions(const SGReaderWriterBTGOptions& options,
-            const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
-        osgDB::ReaderWriter::Options(options, copyop),
-        _matlib(options._matlib), _calcLights(options._calcLights),
-        _useRandomObjects(options._useRandomObjects),
-        _useRandomVegetation(options._useRandomVegetation)
-    {
-    }
-    SGMaterialLib* getMatlib() const { return _matlib; }
-    void setMatlib (SGMaterialLib* matlib) { _matlib = matlib; }
-    bool getCalcLights() const { return _calcLights; }
-    void setCalcLights(bool calcLights)  { _calcLights = calcLights; }
-    bool getUseRandomObjects() const { return _useRandomObjects; }
-    bool getUseRandomVegetation() const { return _useRandomVegetation; }
-    void setUseRandomObjects(bool useRandomObjects)
-    {
-        _useRandomObjects = useRandomObjects;
-    }
-    void setUseRandomVegetation(bool useRandomVegetation)
-    {
-        _useRandomVegetation = useRandomVegetation;
-    }
-
-protected:
-    virtual ~SGReaderWriterBTGOptions() {}
-    SGMaterialLib* _matlib;
-    bool _calcLights;
-    bool _useRandomObjects;
-    bool _useRandomVegetation;
-};
-#endif
index 6c7c54c21580f33c8a17faf3e1e353435bad9381..1c219bfb9175686bea57362695fc2481aed07da3 100644 (file)
@@ -49,7 +49,7 @@
 #include <simgear/scene/model/ModelRegistry.hxx>
 #include <simgear/scene/tgdb/apt_signs.hxx>
 #include <simgear/scene/tgdb/obj.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
 #include "ReaderWriterSTG.hxx"
 #include "TileEntry.hxx"
@@ -288,27 +288,26 @@ TileEntry::loadTileByFileName(const string& fileName,
         }
     }
 
-    const SGReaderWriterBTGOptions* btgOpt;
-    btgOpt = dynamic_cast<const SGReaderWriterBTGOptions *>(options);
-    osg::ref_ptr<SGReaderWriterBTGOptions> opt;
+    const SGReaderWriterOptions* btgOpt;
+    btgOpt = dynamic_cast<const SGReaderWriterOptions*>(options);
+    osg::ref_ptr<SGReaderWriterOptions> opt;
     if (btgOpt)
-        opt = new SGReaderWriterBTGOptions(*btgOpt);
+        opt = new SGReaderWriterOptions(*btgOpt);
     else
-        opt = new SGReaderWriterBTGOptions;
+        opt = new SGReaderWriterOptions;
 
     // obj_load() will generate ground lighting for us ...
     osg::Group* new_tile = new osg::Group;
 
     if (found_tile_base) {
         // load tile if found ...
-        opt->setCalcLights(true);
         obj_load( object_base.str(), new_tile, true, opt.get());
 
     } else {
         // ... or generate an ocean tile on the fly
         SG_LOG(SG_TERRAIN, SG_INFO, "  Generating ocean tile");
         if ( !SGGenTile( path_list[0], tile_bucket,
-                        opt->getMatlib(), new_tile ) ) {
+                        opt->getMaterialLib(), new_tile ) ) {
             SG_LOG( SG_TERRAIN, SG_ALERT,
                     "Warning: failed to generate ocean tile!" );
         }
@@ -322,7 +321,6 @@ TileEntry::loadTileByFileName(const string& fileName,
         if (obj->type == OBJECT) {
             SGPath custom_path = obj->path;
             custom_path.append( obj->name );
-            opt->setCalcLights(true);
             obj_load( custom_path.str(), new_tile, false, opt.get());
 
         } else if (obj->type == OBJECT_SHARED || obj->type == OBJECT_STATIC) {
@@ -366,9 +364,9 @@ TileEntry::loadTileByFileName(const string& fileName,
 
             osg::Node *custom_obj = 0;
             if (obj->type == OBJECT_SIGN)
-                custom_obj = SGMakeSign(opt->getMatlib(), custom_path.str(), obj->name);
+                custom_obj = SGMakeSign(opt->getMaterialLib(), custom_path.str(), obj->name);
             else
-                custom_obj = SGMakeRunwaySign(opt->getMatlib(), custom_path.str(), obj->name);
+                custom_obj = SGMakeRunwaySign(opt->getMaterialLib(), custom_path.str(), obj->name);
 
             // wire the pieces together
             if ( custom_obj != NULL ) {
index 6e16dc7077d05b95f0ff02a8c7232885093b09b2..d080ff33ef84f1b1a6fd5d33bd0c862ebaf10e79 100644 (file)
@@ -579,7 +579,7 @@ typedef QuadTreeBuilder<osg::LOD*, ModelLOD, MakeQuadLeaf, AddModelLOD,
                         GetModelLODCoord>  RandomObjectsQuadtree;
 
 osg::Node*
-SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool use_random_objects, bool use_random_vegetation)
+SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool use_random_objects, bool use_random_vegetation)
 {
   SGBinObject tile;
   if (!tile.read_bin(path))
@@ -669,38 +669,36 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
     } 
   }
 
-  if (calc_lights) {
-    // FIXME: ugly, has a side effect
-    if (matlib)
-      tileGeometryBin.computeRandomSurfaceLights(matlib);
-
-    if (tileGeometryBin.tileLights.getNumLights() > 0
-        || tileGeometryBin.randomTileLights.getNumLights() > 0) {
-      osg::Group* groundLights0 = new osg::Group;
-      groundLights0->setStateSet(lightManager->getGroundLightStateSet());
-      groundLights0->setNodeMask(GROUNDLIGHTS0_BIT);
-      osg::Geode* geode = new osg::Geode;
-      geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
-      geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
-      groundLights0->addChild(geode);
-      lightGroup->addChild(groundLights0);
-    }
-    if (tileGeometryBin.randomTileLights.getNumLights() > 0) {
-      osg::Group* groundLights1 = new osg::Group;
-      groundLights1->setStateSet(lightManager->getGroundLightStateSet());
-      groundLights1->setNodeMask(GROUNDLIGHTS1_BIT);
-      osg::Group* groundLights2 = new osg::Group;
-      groundLights2->setStateSet(lightManager->getGroundLightStateSet());
-      groundLights2->setNodeMask(GROUNDLIGHTS2_BIT);
-      osg::Geode* geode = new osg::Geode;
-      geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 2, -0.15f));
-      groundLights1->addChild(geode);
-      lightGroup->addChild(groundLights1);
-      geode = new osg::Geode;
-      geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights));
-      groundLights2->addChild(geode);
-      lightGroup->addChild(groundLights2);
-    }
+  // FIXME: ugly, has a side effect
+  if (matlib)
+    tileGeometryBin.computeRandomSurfaceLights(matlib);
+
+  if (tileGeometryBin.tileLights.getNumLights() > 0
+      || tileGeometryBin.randomTileLights.getNumLights() > 0) {
+    osg::Group* groundLights0 = new osg::Group;
+    groundLights0->setStateSet(lightManager->getGroundLightStateSet());
+    groundLights0->setNodeMask(GROUNDLIGHTS0_BIT);
+    osg::Geode* geode = new osg::Geode;
+    geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
+    geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
+    groundLights0->addChild(geode);
+    lightGroup->addChild(groundLights0);
+  }
+  if (tileGeometryBin.randomTileLights.getNumLights() > 0) {
+    osg::Group* groundLights1 = new osg::Group;
+    groundLights1->setStateSet(lightManager->getGroundLightStateSet());
+    groundLights1->setNodeMask(GROUNDLIGHTS1_BIT);
+    osg::Group* groundLights2 = new osg::Group;
+    groundLights2->setStateSet(lightManager->getGroundLightStateSet());
+    groundLights2->setNodeMask(GROUNDLIGHTS2_BIT);
+    osg::Geode* geode = new osg::Geode;
+    geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 2, -0.15f));
+    groundLights1->addChild(geode);
+    lightGroup->addChild(groundLights1);
+    geode = new osg::Geode;
+    geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights));
+    groundLights2->addChild(geode);
+    lightGroup->addChild(groundLights2);
   }
 
   if (!tileGeometryBin.vasiLights.empty()) {
index 126ed6ccab3645d05fe7afe7f38accb8f4039cef..cdced8b697c26f703ff3f8fd6ce3075b220fa35a 100644 (file)
@@ -56,6 +56,6 @@ inline bool SGGenTile( const std::string&, const SGBucket& b,
 }
 
 osg::Node*
-SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool use_random_objects, bool use_random_vegetation);
+SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool use_random_objects, bool use_random_vegetation);
 
 #endif // _SG_OBJ_HXX
index 84f0b5560d0721771008ca684d2b590cde8daa5e..6f9193a5ec641b081e1d2c6bef094d7b5172b17c 100644 (file)
@@ -10,6 +10,7 @@ set(HEADERS
     SGEnlargeBoundingBox.hxx
     SGNodeMasks.hxx
     SGPickCallback.hxx
+    SGReaderWriterOptions.hxx
     SGSceneFeatures.hxx
     SGSceneUserData.hxx
     SGStateAttributeVisitor.hxx
diff --git a/simgear/scene/util/SGReaderWriterOptions.hxx b/simgear/scene/util/SGReaderWriterOptions.hxx
new file mode 100644 (file)
index 0000000..29ff31e
--- /dev/null
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 Tim Moore timoore@redhat.com
+// Copyright (C) 2008 Till Busch buti@bux.at
+// Copyright (C) 2011 Mathias Froehlich
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+
+#ifndef SGREADERWRITEROPTIONS_HXX
+#define SGREADERWRITEROPTIONS_HXX 1
+
+#include <osgDB/Options>
+#include <simgear/scene/model/modellib.hxx>
+#include <simgear/props/props.hxx>
+
+class SGPropertyNode;
+class SGMaterialLib;
+
+namespace simgear
+{
+
+class SGReaderWriterOptions : public osgDB::Options {
+public:
+    SGReaderWriterOptions() :
+        _materialLib(0),
+        _load_panel(0),
+        _model_data(0),
+        _instantiateEffects(false)
+    { }
+    SGReaderWriterOptions(const std::string& str) :
+        osgDB::ReaderWriter::Options(str),
+        _materialLib(0),
+        _load_panel(0),
+        _model_data(0),
+        _instantiateEffects(false)
+    { }
+    SGReaderWriterOptions(const osgDB::Options& options,
+                          const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
+        osgDB::ReaderWriter::Options(options, copyop),
+        _materialLib(0),
+        _load_panel(0),
+        _model_data(0),
+        _instantiateEffects(false)
+    { }
+    SGReaderWriterOptions(const SGReaderWriterOptions& options,
+                          const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
+        osgDB::ReaderWriter::Options(options, copyop),
+        _propertyNode(options._propertyNode),
+        _materialLib(options._materialLib),
+        _load_panel(options._load_panel),
+        _model_data(options._model_data),
+        _instantiateEffects(options._instantiateEffects)
+    { }
+
+    META_Object(simgear, SGReaderWriterOptions);
+
+    const SGSharedPtr<SGPropertyNode>& getPropertyNode() const
+    { return _propertyNode; }
+    void setPropertyNode(const SGSharedPtr<SGPropertyNode>& propertyNode)
+    { _propertyNode = propertyNode; }
+
+    SGMaterialLib* getMaterialLib() const
+    { return _materialLib; }
+    void setMaterialLib(SGMaterialLib* materialLib)
+    { _materialLib = materialLib; }
+
+    typedef osg::Node *(*panel_func)(SGPropertyNode *);
+
+    panel_func getLoadPanel() const
+    { return _load_panel; }
+    void setLoadPanel(panel_func pf)
+    { _load_panel=pf; }
+
+    SGModelData *getModelData() const
+    { return _model_data.get(); }
+    void setModelData(SGModelData *modelData)
+    { _model_data=modelData; }
+
+    bool getInstantiateEffects() const
+    { return _instantiateEffects; }
+    void setInstantiateEffects(bool instantiateEffects)
+    { _instantiateEffects = instantiateEffects; }
+
+protected:
+    virtual ~SGReaderWriterOptions() {}
+
+private:
+    SGSharedPtr<SGPropertyNode> _propertyNode;
+    SGMaterialLib* _materialLib;
+    osg::Node *(*_load_panel)(SGPropertyNode *);
+    osg::ref_ptr<SGModelData> _model_data;
+    bool _instantiateEffects;
+};
+
+}
+
+#endif