Dump texture attributes of StateSet into effect property tree
Also, decode blend function.
This commit is contained in:
@@ -922,6 +922,17 @@ bool makeParametersFromStateSet(SGPropertyNode* paramRoot, const StateSet* ss)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
paramRoot->getChild("cull-face", 0, true)->setStringValue(cullFaceString);
|
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
|
// Walk the techniques property tree, building techniques and
|
||||||
|
|||||||
@@ -71,5 +71,8 @@ Effect* makeEffect(const std::string& name,
|
|||||||
Effect* makeEffect(SGPropertyNode* prop,
|
Effect* makeEffect(SGPropertyNode* prop,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const osgDB::ReaderWriter::Options* options = 0);
|
const osgDB::ReaderWriter::Options* options = 0);
|
||||||
|
|
||||||
|
bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
|
||||||
|
const osg::StateSet* ss);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
#include <simgear/structure/OSGUtils.hxx>
|
||||||
|
|
||||||
#include "Noise.hxx"
|
#include "Noise.hxx"
|
||||||
|
|
||||||
@@ -283,4 +283,26 @@ namespace
|
|||||||
TextureBuilder::Registrar installNoise("noise", new NoiseBuilder);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#ifndef SIMGEAR_TEXTUREBUILDER_HXX
|
#ifndef SIMGEAR_TEXTUREBUILDER_HXX
|
||||||
#define SIMGEAR_TEXTUREBUILDER_HXX 1
|
#define SIMGEAR_TEXTUREBUILDER_HXX 1
|
||||||
|
|
||||||
|
#include <osg/StateSet>
|
||||||
#include <osg/Texture>
|
#include <osg/Texture>
|
||||||
#include "EffectBuilder.hxx"
|
#include "EffectBuilder.hxx"
|
||||||
|
|
||||||
@@ -30,5 +31,7 @@ public:
|
|||||||
const SGPropertyNode*props,
|
const SGPropertyNode*props,
|
||||||
const osgDB::ReaderWriter::Options* options);
|
const osgDB::ReaderWriter::Options* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool makeTextureParameters(SGPropertyNode* paramRoot, const osg::StateSet* ss);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user