]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/TextureBuilder.cxx
Merge branch 'timoore/effects-anim-rebase'
[simgear.git] / simgear / scene / material / TextureBuilder.cxx
index a924b95571055057d3e378b86ff0ba10ad7a439a..7dc7aed64b1e5d15284b9049eb1757c215ceaeac 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>
@@ -50,13 +51,14 @@ using namespace osg;
 using namespace effect;
 
 TexEnvCombine* buildTexEnvCombine(Effect* effect,
-                                  const SGPropertyNode* envProp);
+                                  const SGPropertyNode* envProp,
+                                  const SGReaderWriterXMLOptions* 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 osgDB::ReaderWriter::Options*
+                                            const SGReaderWriterXMLOptions*
                                             options)
 {
     return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
@@ -98,7 +100,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;
@@ -141,7 +143,8 @@ void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
     }
     const SGPropertyNode* combineProp = prop->getChild("texenv-combine");
     TexEnvCombine* combiner = 0;
-    if (combineProp && ((combiner = buildTexEnvCombine(effect, combineProp))))
+    if (combineProp && ((combiner = buildTexEnvCombine(effect, combineProp,
+                                                       options))))
         pass->setTextureAttributeAndModes(unit, combiner);
     const SGPropertyNode* tgenProp = prop->getChild("texgen");
     TexGen* tgen = 0;
@@ -177,7 +180,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 +216,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 +256,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 +265,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 +289,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 +307,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 +371,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,
@@ -443,7 +446,8 @@ EffectNameValue<TexEnvCombine::OperandParam> opParamInit[] =
 
 EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
 
-TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp)
+TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
+                                  const SGReaderWriterXMLOptions* options)
 {
     if (!isAttributeActive(effect, envProp))
         return 0;
@@ -538,7 +542,8 @@ TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp)
     const SGPropertyNode* colorNode = envProp->getChild("constant-color");
     if (colorNode)
         initFromParameters(effect, colorNode, result,
-                           &TexEnvCombine::setConstantColor, colorFields);
+                           &TexEnvCombine::setConstantColor, colorFields,
+                           options);
     return result;
 }