diff --git a/src/osgPlugins/ive/PagedLOD.cpp b/src/osgPlugins/ive/PagedLOD.cpp index ae2e397af..0d17b9233 100644 --- a/src/osgPlugins/ive/PagedLOD.cpp +++ b/src/osgPlugins/ive/PagedLOD.cpp @@ -97,6 +97,17 @@ void PagedLOD::read(DataInputStream* in){ else throw Exception("Group::read(): Could not cast this osg::Group to an osg::Node."); + + if (getDatabasePath().empty() && in->getOptions()) + { + const std::string& path = in->getOptions()->getDatabasePath(); + if (!path.empty()) + { + setDatabasePath(path); + } + } + + setRadius(in->readFloat()); setNumChildrenThatCannotBeExpired(in->readUInt()); diff --git a/src/osgPlugins/ive/ReaderWriterIVE.cpp b/src/osgPlugins/ive/ReaderWriterIVE.cpp index 423c87f4d..3a37e11c0 100644 --- a/src/osgPlugins/ive/ReaderWriterIVE.cpp +++ b/src/osgPlugins/ive/ReaderWriterIVE.cpp @@ -28,8 +28,18 @@ class IVEReaderWriter : public ReaderWriter std::string fileName = osgDB::findDataFile( file ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; + // code for setting up the database path so that any paged + // databases can be automatically located. + osg::ref_ptr local_opt = const_cast(options); + if (!local_opt) local_opt = new Options; + + if (local_opt.valid() && local_opt->getDatabasePath().empty()) + { + local_opt->setDatabasePath(osgDB::getFilePath(fileName)); + } + std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); - return readNode(istream,options); + return readNode(istream,local_opt.get()); } virtual ReadResult readNode(std::istream& fin, const Options* options) diff --git a/src/osgPlugins/net/ReaderWriterNET.cpp b/src/osgPlugins/net/ReaderWriterNET.cpp index d04ff9891..dee497e2a 100644 --- a/src/osgPlugins/net/ReaderWriterNET.cpp +++ b/src/osgPlugins/net/ReaderWriterNET.cpp @@ -308,12 +308,23 @@ class NetReader : public osgDB::ReaderWriter } while( linebuff[0] != '\r' ); + // code for setting up the database path so that any paged + // databases can be automatically located. + osg::ref_ptr local_opt = const_cast(options); + if (!local_opt) local_opt = new Options; + + if (local_opt.valid() && local_opt->getDatabasePath().empty()) + { + local_opt->setDatabasePath(osgDB::getFilePath(inFileName)); + } + + osg::notify(osg::DEBUG_INFO) << "osgPlugin .net: " << fileName << " fetched from server." << std::endl; if( reader != 0L ) - readResult = readFile(objectType, reader, sio, options ); + readResult = readFile(objectType, reader, sio, local_opt.get() ); if( !localCacheDir.empty() && cacheMode & Write ) { diff --git a/src/osgPlugins/osg/PagedLOD.cpp b/src/osgPlugins/osg/PagedLOD.cpp index 3c106aef0..1b4edcf28 100644 --- a/src/osgPlugins/osg/PagedLOD.cpp +++ b/src/osgPlugins/osg/PagedLOD.cpp @@ -1,4 +1,5 @@ #include "osg/PagedLOD" +#include "osg/Notify" #include "osgDB/Registry" #include "osgDB/Input" @@ -26,6 +27,15 @@ bool PagedLOD_readLocalData(Object& obj, Input& fr) bool iteratorAdvanced = false; PagedLOD& lod = static_cast(obj); + + if (lod.getDatabasePath().empty() && fr.getOptions()) + { + const std::string& path = fr.getOptions()->getDatabasePath(); + if (!path.empty()) + { + lod.setDatabasePath(path); + } + } unsigned int num; if (fr[0].matchWord("NumChildrenThatCannotBeExpired") && fr[1].getUInt(num)) diff --git a/src/osgPlugins/osg/ReaderWriterOSG.cpp b/src/osgPlugins/osg/ReaderWriterOSG.cpp index ffef9db89..ae599ca8a 100644 --- a/src/osgPlugins/osg/ReaderWriterOSG.cpp +++ b/src/osgPlugins/osg/ReaderWriterOSG.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -34,10 +35,20 @@ class OSGReaderWriter : public ReaderWriter std::string fileName = osgDB::findDataFile( file ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; + // code for setting up the database path so that any paged + // databases can be automatically located. + osg::ref_ptr local_opt = const_cast(opt); + if (!local_opt) local_opt = new Options; + + if (local_opt.valid() && local_opt->getDatabasePath().empty()) + { + local_opt->setDatabasePath(osgDB::getFilePath(fileName)); + } + std::ifstream fin(fileName.c_str()); if (fin) { - return readNode(fin, opt); + return readNode(fin, local_opt.get()); } return 0L; @@ -49,7 +60,7 @@ class OSGReaderWriter : public ReaderWriter Input fr; fr.attach(&fin); fr.setOptions(options); - + typedef std::vector NodeList; NodeList nodeList;