Also, decode blend function.
}
}
paramRoot->getChild("cull-face", 0, true)->setStringValue(cullFaceString);
+ const BlendFunc* blendFunc = getStateAttribute<BlendFunc>(ss);
+ if (blendFunc) {
+ string sourceMode = findName(blendFuncModes, blendFunc->getSource());
+ string destMode = findName(blendFuncModes, blendFunc->getDestination());
+ SGPropertyNode* blendNode = paramRoot->getChild("blend", 0, true);
+ blendNode->getChild("source", 0, true)->setStringValue(sourceMode);
+ blendNode->getChild("destination", 0, true)->setStringValue(destMode);
+ blendNode->getChild("mode", 0, true)->setValue(true);
+ }
+ makeTextureParameters(paramRoot, ss);
+ return true;
}
// Walk the techniques property tree, building techniques and
Effect* makeEffect(SGPropertyNode* prop,
bool realizeTechniques,
const osgDB::ReaderWriter::Options* options = 0);
+
+bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
+ const osg::StateSet* ss);
}
#endif
#include <simgear/scene/util/SGSceneFeatures.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
-
#include <simgear/math/SGMath.hxx>
+#include <simgear/structure/OSGUtils.hxx>
#include "Noise.hxx"
TextureBuilder::Registrar installNoise("noise", new NoiseBuilder);
}
+bool makeTextureParameters(SGPropertyNode* paramRoot, const StateSet* ss)
+{
+ const Texture* tex = getStateAttribute<Texture>(0, ss);
+ const Texture2D* texture = dynamic_cast<const Texture2D*>(tex);
+ if (!tex)
+ return false;
+ const Image* image = texture->getImage();
+ string imageName;
+ if (image)
+ imageName = image->getFileName();
+ string wrapS = findName(wrapModes, texture->getWrap(Texture::WRAP_S));
+ string wrapT = findName(wrapModes, texture->getWrap(Texture::WRAP_T));
+ string wrapR = findName(wrapModes, texture->getWrap(Texture::WRAP_R));
+ SGPropertyNode* texUnit = makeChild(paramRoot, "texture-unit");
+ makeChild(texUnit, "unit")->setValue(0);
+ makeChild(texUnit, "image")->setStringValue(imageName);
+ makeChild(texUnit, "wrap-s")->setStringValue(wrapS);
+ makeChild(texUnit, "wrap-t")->setStringValue(wrapT);
+ makeChild(texUnit, "wrap-r")->setStringValue(wrapR);
+ return true;
+}
+
}
#ifndef SIMGEAR_TEXTUREBUILDER_HXX
#define SIMGEAR_TEXTUREBUILDER_HXX 1
+#include <osg/StateSet>
#include <osg/Texture>
#include "EffectBuilder.hxx"
const SGPropertyNode*props,
const osgDB::ReaderWriter::Options* options);
};
+
+bool makeTextureParameters(SGPropertyNode* paramRoot, const osg::StateSet* ss);
}
#endif