#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>
}
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);
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)
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)
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) {
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)
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)
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;
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[] =
void MaterialBuilder::buildAttribute(Effect* effect, Pass* pass,
const SGPropertyNode* prop,
- const osgDB::ReaderWriter::Options* options)
+ const SGReaderWriterXMLOptions* options)
{
if (!isAttributeActive(effect, prop))
return;
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;
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;
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;
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;
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;
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();
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;
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)
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)
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;
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);
// 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;
{
class Technique;
class Effect;
+class SGReaderWriterXMLOptions;
/**
* Object to be initialized at some point after an effect -- and its
/**
* 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
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
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);
# include <simgear_config.h>
#endif
+#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/math/SGMath.hxx>
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);
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)
{
#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>
// 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);
void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
const SGPropertyNode* prop,
- const osgDB::ReaderWriter::Options* options)
+ const SGReaderWriterXMLOptions* options)
{
if (!isAttributeActive(effect, prop))
return;
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;
}
void setAttrs(const TexTuple& attrs, Texture* tex,
- const osgDB::ReaderWriter::Options* options)
+ const SGReaderWriterXMLOptions* options)
{
const string& imageName = attrs.get<0>();
if (imageName.empty()) {
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;
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);
{
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();
}
{
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();
}
{
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,
// 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);
};
#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>
Effect* makeEffect(const string& name,
bool realizeTechniques,
- const osgDB::ReaderWriter::Options* options)
+ const SGReaderWriterXMLOptions* options)
{
{
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
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");
#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>
////////////////////////////////////////////////////////////////////////
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();
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)
{
}
////////////////////////////////////////////////////////////////////////
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)
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);
->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());
}
}
#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>
*/
SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
+ SGMaterial(const simgear::SGReaderWriterXMLOptions*,
+ const SGPropertyNode *props);
/**
* Destructor.
*/
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:
// 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);
};
#ifndef SGREADERWRITERXMLOPTIONS_HXX
#define SGREADERWRITERXMLOPTIONS_HXX 1
-#include <osgDB/ReaderWriter>
+#include <osgDB/Registry>
#include <simgear/scene/model/modellib.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/props/condition.hxx>
+#include "SGReaderWriterXMLOptions.hxx"
#include "model.hxx"
using std::vector;
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)
{
}
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)
ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
PropertyList& effectProps,
- const osgDB::ReaderWriter::Options* options)
+ const SGReaderWriterXMLOptions* options)
{
SGPropertyNode_ptr defaultEffectPropRoot;
MakeEffectVisitor visitor(options);
#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,
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
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);
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();
}
}
#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>
"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();