Fix effects code to work with OSG 2.8.2-rc4
This commit is contained in:
@@ -669,9 +669,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||
if (sitr != shaderMap.end()) {
|
||||
program->addShader(sitr->second.get());
|
||||
} else {
|
||||
string fileName = osgDB::Registry::instance()
|
||||
->findDataFile(shaderName, options,
|
||||
osgDB::CASE_SENSITIVE);
|
||||
string fileName = osgDB::findDataFile(shaderName, options);
|
||||
if (!fileName.empty()) {
|
||||
ref_ptr<Shader> shader = new Shader(stype);
|
||||
if (shader->loadShaderSourceFromFile(fileName)) {
|
||||
|
||||
@@ -128,8 +128,7 @@ Effect* makeEffect(const string& name,
|
||||
string effectFileName(name);
|
||||
effectFileName += ".eff";
|
||||
string absFileName
|
||||
= osgDB::Registry::instance()->findDataFile(effectFileName, options,
|
||||
osgDB::CASE_SENSITIVE);
|
||||
= osgDB::findDataFile(effectFileName, options);
|
||||
if (absFileName.empty())
|
||||
return 0;
|
||||
SGPropertyNode_ptr effectProps = new SGPropertyNode();
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Texture2D>
|
||||
#include <osgDB/Options>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileUtils>
|
||||
@@ -68,12 +68,12 @@ using namespace simgear;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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();
|
||||
@@ -91,7 +91,7 @@ SGMaterial::~SGMaterial (void)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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)
|
||||
@@ -104,14 +104,11 @@ SGMaterial::read_properties(const osgDB::Options* options,
|
||||
}
|
||||
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() ) {
|
||||
@@ -142,8 +139,7 @@ SGMaterial::read_properties(const osgDB::Options* options,
|
||||
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
|
||||
@@ -246,7 +242,8 @@ Effect* SGMaterial::get_effect(int n)
|
||||
return _status[i].effect.get();
|
||||
}
|
||||
|
||||
void SGMaterial::buildEffectProperties(const osgDB::Options* options)
|
||||
void SGMaterial::buildEffectProperties(const osgDB::ReaderWriter::Options*
|
||||
options)
|
||||
{
|
||||
using namespace osg;
|
||||
SGPropertyNode_ptr propRoot = new SGPropertyNode();
|
||||
|
||||
@@ -39,17 +39,13 @@
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class StateSet;
|
||||
}
|
||||
|
||||
namespace osgDB
|
||||
{
|
||||
class Options;
|
||||
}
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||
@@ -88,7 +84,7 @@ public:
|
||||
* state information for the material. This node is usually
|
||||
* loaded from the $FG_ROOT/materials.xml file.
|
||||
*/
|
||||
SGMaterial( const osgDB::Options*, const SGPropertyNode *props);
|
||||
SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -260,11 +256,11 @@ protected:
|
||||
|
||||
struct _internal_state {
|
||||
_internal_state(simgear::Effect *e, const std::string &t, bool l,
|
||||
const osgDB::Options *o);
|
||||
const osgDB::ReaderWriter::Options *o);
|
||||
osg::ref_ptr<simgear::Effect> effect;
|
||||
std::string texture_path;
|
||||
bool effect_realized;
|
||||
osg::ref_ptr<const osgDB::Options> options;
|
||||
osg::ref_ptr<const osgDB::ReaderWriter::Options> options;
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -344,9 +340,9 @@ private:
|
||||
// Internal constructors and methods.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void read_properties(const osgDB::Options* options,
|
||||
void read_properties(const osgDB::ReaderWriter::Options* options,
|
||||
const SGPropertyNode *props);
|
||||
void buildEffectProperties(const osgDB::Options* options);
|
||||
void buildEffectProperties(const osgDB::ReaderWriter::Options* options);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <osgDB/Options>
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
@@ -71,8 +71,9 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath,
|
||||
<< ex.getMessage() );
|
||||
throw;
|
||||
}
|
||||
osg::ref_ptr<osgDB::Options> options = new osgDB::Options;
|
||||
options->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> options
|
||||
= new osgDB::ReaderWriter::Options;
|
||||
options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
|
||||
options->setDatabasePath(fg_root);
|
||||
int nMaterials = materials.nChildren();
|
||||
for (int i = 0; i < nMaterials; i++) {
|
||||
|
||||
Reference in New Issue
Block a user