osg::PagedLOD::s/getDatabasePath() and support in PagedLOD::traverse().
    osgDB::ReaderWriter::Options::s/getDatabasePath()
    osgDB::Input::s/getOptions()
    setting of osgDB::Input::setOptions() in ReaderWriterOSG.cpp
    src/osgPlugins/ive/DataInputStream::s/getOptions()
    setting of src/osgPlugins/ive/DataInputStream::setOptions() in ReaderWriterIVE.cpp
This commit is contained in:
Robert Osfield
2004-10-06 09:31:34 +00:00
parent debf8dceef
commit 7e4d34c57a
7 changed files with 85 additions and 7 deletions

View File

@@ -39,6 +39,38 @@ PagedLOD::PagedLOD(const PagedLOD& plod,const CopyOp& copyop):
{
}
void PagedLOD::setDatabasePath(const std::string& path)
{
_databasePath = path;
if (!_databasePath.empty())
{
char& lastCharacter = _databasePath[_databasePath.size()-1];
const char unixSlash = '/';
const char winSlash = '\\';
// make sure the last character is the appropriate slash
#ifdef WIN32
if (lastCharacter==unixSlash)
{
lastCharacter = winSlash;
}
else if (lastCharacter!=winSlash)
{
_databasePath += winSlash;
}
#else
if (lastCharacter==winSlash)
{
lastCharacter = unixSlash;
}
else if (lastCharacter!=unixSlash)
{
_databasePath += unixSlash;
}
#endif
}
}
void PagedLOD::traverse(NodeVisitor& nv)
{
@@ -98,7 +130,15 @@ void PagedLOD::traverse(NodeVisitor& nv)
// modify the priority according to the child's priority offset and scale.
priority = _perRangeDataList[numChildren]._priorityOffset + priority * _perRangeDataList[numChildren]._priorityScale;
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
if (_databasePath.empty())
{
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
}
else
{
// prepend the databasePath to the childs filename.
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
}
}

View File

@@ -13,15 +13,17 @@
#include <osg/Array>
#include <osg/Matrix>
#include <osg/Geometry>
#include <osg/Image>
#include <osg/StateSet>
#include <osg/ref_ptr>
#include <osgDB/ReaderWriter>
#include "IveVersion.h"
#include "DataTypeSize.h"
#include "Exception.h"
#include <osg/Image>
#include <osg/StateSet>
#include <osg/ref_ptr>
namespace ive{
@@ -30,6 +32,10 @@ class DataInputStream{
public:
DataInputStream(std::istream* istream);
~DataInputStream();
void setOptions(const osgDB::ReaderWriter::Options* options) { _options = options; }
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
unsigned int getVersion();
bool readBool();
char readChar();
@@ -92,6 +98,8 @@ private:
DrawableMap _drawableMap;
ShapeMap _shapeMap;
NodeMap _nodeMap;
osg::ref_ptr<const osgDB::ReaderWriter::Options> _options;
};

View File

@@ -32,7 +32,7 @@ class IVEReaderWriter : public ReaderWriter
return readNode(istream,options);
}
virtual ReadResult readNode(std::istream& fin, const Options*)
virtual ReadResult readNode(std::istream& fin, const Options* options)
{
#define IVE_CATCH_EXCEPTIONS
#ifdef IVE_CATCH_EXCEPTIONS
@@ -40,6 +40,7 @@ class IVEReaderWriter : public ReaderWriter
#endif
// Create datainputstream.
ive::DataInputStream in(&fin);
in.setOptions(options);
return in.readNode();
#ifdef IVE_CATCH_EXCEPTIONS

View File

@@ -43,11 +43,12 @@ class OSGReaderWriter : public ReaderWriter
}
virtual ReadResult readNode(std::istream& fin, const Options*)
virtual ReadResult readNode(std::istream& fin, const Options* options)
{
Input fr;
fr.attach(&fin);
fr.setOptions(options);
typedef std::vector<osg::Node*> NodeList;
NodeList nodeList;