#include <osg/StateSet>
#include <osg/TexEnv>
#include <osg/Texture2D>
-#include <osgDB/Options>
+#include <osgDB/ReaderWriter>
#include <osgDB/ReadFile>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
////////////////////////////////////////////////////////////////////////
SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
- const osgDB::Options* o ) :
+ const osgDB::ReaderWriter::Options* o ) :
effect(e), texture_path(t), effect_realized(l), options(o)
{
}
-SGMaterial::SGMaterial( const osgDB::Options* options,
+SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
const SGPropertyNode *props )
{
init();
////////////////////////////////////////////////////////////////////////
void
-SGMaterial::read_properties(const osgDB::Options* options,
+SGMaterial::read_properties(const osgDB::ReaderWriter::Options* options,
const SGPropertyNode *props)
{
// Gather the path(s) to the texture(s)
}
SGPath tpath("Textures.high");
tpath.append(tname);
- osgDB::Registry* reg = osgDB::Registry::instance();
- string fullTexPath = reg->findDataFile(tpath.str(), options,
- osgDB::CASE_SENSITIVE);
+ string fullTexPath = osgDB::findDataFile(tpath.str(), options);
if (fullTexPath.empty()) {
tpath = SGPath("Textures");
tpath.append(tname);
- fullTexPath = reg->findDataFile(tpath.str(), options,
- osgDB::CASE_SENSITIVE);
+ fullTexPath = osgDB::findDataFile(tpath.str(), options);
}
if (!fullTexPath.empty() ) {
wrapv = props->getBoolValue("wrapv", true);
mipmap = props->getBoolValue("mipmap", true);
light_coverage = props->getDoubleValue("light-coverage", 0.0);
- tree_coverage = props->getDoubleValue("tree-coverage", 0.0);
+ wood_coverage = props->getDoubleValue("wood-coverage", 0.0);
+ wood_size = props->getDoubleValue("wood-size", 0.0);
+ tree_density = props->getDoubleValue("tree-density", 1.0);
tree_height = props->getDoubleValue("tree-height-m", 0.0);
tree_width = props->getDoubleValue("tree-width-m", 0.0);
tree_range = props->getDoubleValue("tree-range-m", 0.0);
tree_varieties = props->getIntValue("tree-varieties", 1);
+
const SGPropertyNode* treeTexNode = props->getChild("tree-texture");
if (treeTexNode) {
string treeTexPath = props->getStringValue("tree-texture");
- tree_texture = osgDB::Registry::instance()
- ->findDataFile(treeTexPath, options, osgDB::CASE_SENSITIVE);
+ tree_texture = osgDB::findDataFile(treeTexPath, options);
}
// surface values for use with ground reactions
return _status[i].effect.get();
}
-void SGMaterial::buildEffectProperties(const osgDB::Options* options)
+void SGMaterial::buildEffectProperties(const osgDB::ReaderWriter::Options*
+ options)
{
using namespace osg;
+ ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
SGPropertyNode_ptr propRoot = new SGPropertyNode();
makeChild(propRoot, "inherits-from")->setStringValue(effect);
SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
copyProperties(propRoot, effectProp);
SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0);
SGPropertyNode* texProp = makeChild(effectParamProp, "texture");
- SGPropertyNode* tex2dProp = makeChild(texProp, "texture2d");
- makeChild(tex2dProp, "image")->setStringValue(matState.texture_path);
- makeChild(tex2dProp, "filter")
+ makeChild(texProp, "image")->setStringValue(matState.texture_path);
+ makeChild(texProp, "filter")
->setStringValue(mipmap ? "linear-mipmap-linear" : "nearest");
- makeChild(tex2dProp, "wrap-s")
+ makeChild(texProp, "wrap-s")
->setStringValue(wrapu ? "repeat" : "clamp");
- makeChild(tex2dProp, "wrap-t")
+ makeChild(texProp, "wrap-t")
->setStringValue(wrapv ? "repeat" : "clamp");
matState.effect = makeEffect(effectProp, false, options);
+ matState.effect->setUserData(user.get());
}
}