Moved plugins across to using ReaderWriter::Options* for search paths in addition
to standard osgDB::DataFilePaths
This commit is contained in:
@@ -82,26 +82,7 @@ extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,CaseSen
|
||||
/** Search for specified file in file system, checking first the database path set in the Options structure, then the DataFilePathList for possible paths,
|
||||
* returning the full path of the first valid file found, return an empty string if no string is found.
|
||||
*/
|
||||
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,ReaderWriter::Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
|
||||
|
||||
/** Convinience class for pushing a path on construction, and popping the path
|
||||
* and destruction. This helps keep the addition of a path local to a block
|
||||
* of code, even in the presence of exceptions.*/
|
||||
|
||||
class PushAndPopDataPath
|
||||
{
|
||||
public:
|
||||
PushAndPopDataPath(const std::string& path)
|
||||
{
|
||||
getDataFilePathList().push_front(path);
|
||||
}
|
||||
|
||||
~PushAndPopDataPath()
|
||||
{
|
||||
getDataFilePathList().pop_front();
|
||||
}
|
||||
};
|
||||
|
||||
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const ReaderWriter::Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
|
||||
|
||||
inline void setLibraryFilePathList(const FilePathList& filepaths) { osgDB::Registry::instance()->setLibraryFilePathList(filepaths); }
|
||||
|
||||
|
||||
@@ -171,17 +171,13 @@ std::string osgDB::findFileInPath(const std::string& filename, const FilePathLis
|
||||
if (filename.empty())
|
||||
return filename;
|
||||
|
||||
if(fileExists(filename))
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl;
|
||||
return filename;
|
||||
}
|
||||
|
||||
for(FilePathList::const_iterator itr=filepath.begin();
|
||||
itr!=filepath.end();
|
||||
++itr)
|
||||
{
|
||||
std::string path = *itr + '/'+ filename;
|
||||
osg::notify(osg::DEBUG_INFO) << "itr='" <<*itr<< "'\n";
|
||||
std::string path = itr->empty() ? filename : *itr + '/'+ filename;
|
||||
osg::notify(osg::DEBUG_INFO) << "FindFileInPath() : trying " << path << " ...\n";
|
||||
if(fileExists(path))
|
||||
{
|
||||
@@ -202,15 +198,22 @@ std::string osgDB::findFileInPath(const std::string& filename, const FilePathLis
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
std::string osgDB::findDataFile(const std::string& filename,CaseSensitivity caseSensitivity)
|
||||
{
|
||||
return findDataFile(filename,static_cast<ReaderWriter::Options*>(0),caseSensitivity);
|
||||
}
|
||||
|
||||
OSGDB_EXPORT std::string osgDB::findDataFile(const std::string& filename,ReaderWriter::Options* options, CaseSensitivity caseSensitivity)
|
||||
OSGDB_EXPORT std::string osgDB::findDataFile(const std::string& filename,const ReaderWriter::Options* options, CaseSensitivity caseSensitivity)
|
||||
{
|
||||
if (filename.empty()) return filename;
|
||||
|
||||
if(fileExists(filename))
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl;
|
||||
return filename;
|
||||
}
|
||||
|
||||
std::string fileFound;
|
||||
|
||||
if (options && !options->getDatabasePathList().empty())
|
||||
@@ -220,16 +223,36 @@ OSGDB_EXPORT std::string osgDB::findDataFile(const std::string& filename,ReaderW
|
||||
}
|
||||
|
||||
const FilePathList& filepath = Registry::instance()->getDataFilePathList();
|
||||
|
||||
fileFound = findFileInPath(filename, filepath,caseSensitivity);
|
||||
if (!fileFound.empty()) return fileFound;
|
||||
if (!filepath.empty())
|
||||
{
|
||||
fileFound = findFileInPath(filename, filepath,caseSensitivity);
|
||||
if (!fileFound.empty()) return fileFound;
|
||||
}
|
||||
|
||||
|
||||
// if a directory is included in the filename, get just the (simple) filename itself and try that
|
||||
std::string simpleFileName = getSimpleFileName(filename);
|
||||
if (simpleFileName!=filename)
|
||||
{
|
||||
fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity);
|
||||
if (!fileFound.empty()) return fileFound;
|
||||
|
||||
if(fileExists(simpleFileName))
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl;
|
||||
return simpleFileName;
|
||||
}
|
||||
|
||||
if (options && !options->getDatabasePathList().empty())
|
||||
{
|
||||
fileFound = findFileInPath(simpleFileName, options->getDatabasePathList(), caseSensitivity);
|
||||
if (!fileFound.empty()) return fileFound;
|
||||
}
|
||||
|
||||
if (!filepath.empty())
|
||||
{
|
||||
fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity);
|
||||
if (!fileFound.empty()) return fileFound;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return empty string.
|
||||
@@ -247,6 +270,12 @@ std::string osgDB::findLibraryFile(const std::string& filename,CaseSensitivity c
|
||||
if (!fileFound.empty())
|
||||
return fileFound;
|
||||
|
||||
if(fileExists(filename))
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl;
|
||||
return filename;
|
||||
}
|
||||
|
||||
// if a directory is included in the filename, get just the (simple) filename itself and try that
|
||||
std::string simpleFileName = getSimpleFileName(filename);
|
||||
if (simpleFileName!=filename)
|
||||
|
||||
@@ -23,12 +23,12 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
|
||||
osgDB::equalCaseInsensitive(extension,"asc");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::cout << "try to read file "<<fileName<<std::endl;
|
||||
|
||||
@@ -22,12 +22,12 @@ ReaderWriterIV::ReaderWriterIV()
|
||||
// Read file and convert to OSG
|
||||
osgDB::ReaderWriter::ReadResult
|
||||
ReaderWriterIV::readNode(const std::string& file,
|
||||
const osgDB::ReaderWriter::Options*)
|
||||
const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO) << "osgDB::ReaderWriterIV::readNode() Reading file "
|
||||
|
||||
@@ -76,11 +76,11 @@ class ReaderWriterAC : public osgDB::ReaderWriter
|
||||
{
|
||||
return osgDB::equalCaseInsensitive(extension,"ac");
|
||||
}
|
||||
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
osg::Group *grp; // holder for all loaded objects
|
||||
// GWM added Dec 2003 - get full path name (change in osgDB handling of files).
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
|
||||
// Anders Backmann - correct return if path not found
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
@@ -319,12 +319,12 @@ class ReaderWriterBMP : public osgDB::ReaderWriter
|
||||
virtual const char* className() const { return "BMP Image Reader"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"bmp"); }
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -721,7 +721,7 @@ public:
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream stream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
@@ -76,7 +76,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterDirectX::readNode(const std::string&
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO) << "ReaderWriterDirectX::readNode(" << fileName.c_str() << ")\n";
|
||||
|
||||
@@ -799,13 +799,13 @@ class ReaderWriterDW : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"dw");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ FltFile::FltFile(
|
||||
TexturePool* pTexturePool,
|
||||
MaterialPool* pMaterialPool,
|
||||
LtPtAppearancePool* pLtPtAppearancePool,
|
||||
LtPtAnimationPool* pLtPtAnimationPool)
|
||||
LtPtAnimationPool* pLtPtAnimationPool,
|
||||
osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
_useTextureAlphaForTransparancyBinning = true;
|
||||
_doUnitsConversion = true;
|
||||
@@ -93,6 +94,8 @@ FltFile::FltFile(
|
||||
|
||||
// instances are always internally defined
|
||||
setInstancePool( new InstancePool );
|
||||
|
||||
_options = options;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,17 +157,12 @@ bool FltFile::readModel(const std::string& fileName)
|
||||
bool FltFile::readFile(const std::string& fileName)
|
||||
{
|
||||
|
||||
// havn't found file, look in OSGFILEPATH
|
||||
std::string foundFileName = osgDB::findDataFile(fileName, _options.get());
|
||||
if (foundFileName.empty()) return false;
|
||||
|
||||
FileInput fin;
|
||||
if (!fin.open(fileName))
|
||||
{
|
||||
// havn't found file, look in OSGFILEPATH
|
||||
std::string foundFileName = osgDB::findDataFile(fileName);
|
||||
|
||||
if (foundFileName.empty()) return false;
|
||||
if (!fin.open(foundFileName)) return false;
|
||||
}
|
||||
|
||||
osg::notify(osg::INFO) << "Loading " << fileName << " ... " << std::endl;
|
||||
if (!fin.open(foundFileName)) return false;
|
||||
|
||||
Record* pRec = fin.readCreateRecord(this);
|
||||
if (pRec == NULL)
|
||||
@@ -234,39 +232,63 @@ bool FltFile::readFile(const std::string& fileName)
|
||||
}
|
||||
}
|
||||
|
||||
#if REGISTER_FLT
|
||||
pExternalFltFile = Registry::instance()->getFltFile(filename);
|
||||
|
||||
#if REGISTER_FLT
|
||||
bool registerFLT = true;
|
||||
#else
|
||||
bool registerFLT = false;
|
||||
#endif
|
||||
|
||||
pExternalFltFile = registerFLT ? Registry::instance()->getFltFile(filename) : NULL;
|
||||
|
||||
if (pExternalFltFile == NULL)
|
||||
{
|
||||
//Path for Nested external references
|
||||
std::string filePath = osgDB::getFilePath(filename);
|
||||
std::string pushAndPopPath;
|
||||
//If absolute path
|
||||
if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) ||
|
||||
(filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) )
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options;
|
||||
|
||||
if (_pFltFile->getOptions())
|
||||
{
|
||||
pushAndPopPath = filePath;
|
||||
options = _pFltFile->getOptions();
|
||||
}
|
||||
else
|
||||
{
|
||||
osgDB::FilePathList fpl = osgDB::getDataFilePathList();
|
||||
pushAndPopPath = fpl.empty() ? "." : fpl.front();
|
||||
if(pushAndPopPath.empty()) pushAndPopPath = ".";
|
||||
pushAndPopPath += "/" + filePath;
|
||||
}
|
||||
osgDB::PushAndPopDataPath tmpfile(pushAndPopPath);
|
||||
options = new osgDB::ReaderWriter::Options;
|
||||
|
||||
//Path for Nested external references
|
||||
std::string filePath = osgDB::getFilePath(filename);
|
||||
std::string pushAndPopPath;
|
||||
//If absolute path
|
||||
if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) ||
|
||||
(filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) )
|
||||
{
|
||||
pushAndPopPath = filePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
osgDB::FilePathList fpl = osgDB::getDataFilePathList();
|
||||
pushAndPopPath = fpl.empty() ? "." : fpl.front();
|
||||
pushAndPopPath += "/" + filePath;
|
||||
}
|
||||
|
||||
char optionsString[256];
|
||||
sprintf(optionsString,"FLT_VER %d",rec.getFlightVersion());
|
||||
options->setOptionString(optionsString);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Create local path"<<pushAndPopPath<<std::endl;
|
||||
|
||||
options->getDatabasePathList().push_back(pushAndPopPath);
|
||||
}
|
||||
|
||||
pExternalFltFile = new FltFile( pColorPool, pTexturePool, pMaterialPool,
|
||||
pLtPtAppearancePool, pLtPtAnimationPool );
|
||||
pLtPtAppearancePool, pLtPtAnimationPool, options.get() );
|
||||
|
||||
if (registerFLT)
|
||||
{
|
||||
Registry::instance()->addFltFile(filename, pExternalFltFile);
|
||||
}
|
||||
|
||||
pExternalFltFile->readModel(filename);
|
||||
}
|
||||
Registry::instance()->addFltFile(filename, pExternalFltFile);
|
||||
#else
|
||||
pExternalFltFile = new FltFile( pColorPool, pTexturePool, pMaterialPool,
|
||||
pLtPtAppearancePool, pLtPtAnimationPool );
|
||||
pExternalFltFile->readModel(filename);
|
||||
#endif
|
||||
|
||||
rec.setExternal(pExternalFltFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ class FltFile : public osg::Referenced
|
||||
TexturePool* pTexturePool = NULL,
|
||||
MaterialPool* pMaterialPool = NULL,
|
||||
LtPtAppearancePool* pLtPtAppearancePool = NULL,
|
||||
LtPtAnimationPool* pLtPtAnimationPool = NULL);
|
||||
LtPtAnimationPool* pLtPtAnimationPool = NULL,
|
||||
osgDB::ReaderWriter::Options* options =NULL);
|
||||
|
||||
virtual osg::Object* readObject(const std::string& fileName);
|
||||
virtual osg::Node* readNode(const std::string& fileName);
|
||||
@@ -72,6 +73,10 @@ class FltFile : public osg::Referenced
|
||||
int getFlightVersion() const;
|
||||
inline HeaderRecord* getHeaderRecord() { return _headerRecord.get(); }
|
||||
void getOrigin( double& latitude, double& longitude ) const;
|
||||
|
||||
void setOptions(osgDB::ReaderWriter::Options* options) { _options = options; }
|
||||
osgDB::ReaderWriter::Options* getOptions() { return _options.get(); }
|
||||
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -94,6 +99,8 @@ class FltFile : public osg::Referenced
|
||||
|
||||
std::string _directory;
|
||||
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> _options;
|
||||
|
||||
osg::ref_ptr<ColorPool> _colorPool;
|
||||
osg::ref_ptr<TexturePool> _texturePool;
|
||||
osg::ref_ptr<LightPool> _lightPool;
|
||||
|
||||
@@ -54,15 +54,7 @@ bool FileInput::eof()
|
||||
bool FileInput::open(const std::string& fileName)
|
||||
{
|
||||
_file=::fopen( fileName.c_str(), "rb");
|
||||
if (_file == NULL)
|
||||
{
|
||||
// ok havn't found file, resort to using findFile...
|
||||
std::string newFileName = osgDB::findDataFile(fileName);
|
||||
|
||||
if (newFileName.empty()) return false;
|
||||
_file=::fopen( newFileName.c_str(), "rb");
|
||||
if (_file == NULL) return false;
|
||||
}
|
||||
if (_file == NULL) return false;
|
||||
_eof = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ ColorPool::ColorName* ColorPool::getColorName(int nIndex)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
flt::AttrData* TexturePool::getTexture(int nIndex, int fltVersion)
|
||||
flt::AttrData* TexturePool::getTexture(int nIndex, osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
TexturePaletteMap::iterator fitr = _textureMap.find(nIndex);
|
||||
if (fitr != _textureMap.end())
|
||||
@@ -145,24 +145,13 @@ flt::AttrData* TexturePool::getTexture(int nIndex, int fltVersion)
|
||||
unsigned int unit = 0;
|
||||
|
||||
// Read texture and attribute file
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(textureName);
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(textureName, options ? options : osgDB::Registry::instance()->getOptions());
|
||||
if (image.valid())
|
||||
{
|
||||
std::string attrName(textureName);
|
||||
attrName += ".attr";
|
||||
|
||||
// Read attribute file
|
||||
char options[256];
|
||||
sprintf(options,"FLT_VER %d",fltVersion);
|
||||
|
||||
// Add this line to save the existing options
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> oldOptions = osgDB::Registry::instance()->getOptions();
|
||||
|
||||
osgDB::Registry::instance()->setOptions(new osgDB::ReaderWriter::Options(options));
|
||||
textureAttrData = dynamic_cast<flt::AttrData*>(osgDB::readObjectFile(attrName));
|
||||
|
||||
// Changed this line to restore the old options
|
||||
osgDB::Registry::instance()->setOptions( oldOptions.get() ); // Restore options
|
||||
textureAttrData = dynamic_cast<flt::AttrData*>(osgDB::readObjectFile(attrName, options ? options : osgDB::Registry::instance()->getOptions() ));
|
||||
|
||||
// if not found create default StateSet for the AttrData
|
||||
if (textureAttrData == NULL)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <osg/Group>
|
||||
#include <osgSim/BlinkSequence>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include "AttrData.h"
|
||||
|
||||
#include <string>
|
||||
@@ -66,7 +68,7 @@ class TexturePool : public osg::Referenced
|
||||
|
||||
TexturePool() {}
|
||||
|
||||
flt::AttrData* getTexture(int nIndex, int fltVersion);
|
||||
flt::AttrData* getTexture(int nIndex, osgDB::ReaderWriter::Options* options);
|
||||
std::string* getTextureName(int nIndex);
|
||||
void addTexture(int nIndex, flt::AttrData* attrdata);
|
||||
void addTextureName(int nIndex, const std::string& name);
|
||||
|
||||
@@ -749,12 +749,12 @@ class ReaderWriterATTR : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"attr");
|
||||
}
|
||||
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
// options
|
||||
|
||||
@@ -28,7 +28,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& fil
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::ref_ptr<FltFile> read = new FltFile;
|
||||
@@ -54,8 +54,15 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& fil
|
||||
read->setDesiredUnits( FltFile::ConvertToNauticalMiles );
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getDesiredUnits()=" << read->getDesiredUnitsString() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
osg::ref_ptr<ReaderWriter::Options> local_options = options ?
|
||||
static_cast<ReaderWriter::Options*>(options->clone(osg::CopyOp(osg::CopyOp::SHALLOW_COPY))) :
|
||||
new ReaderWriter::Options;
|
||||
local_options->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
read->setOptions(local_options.get());
|
||||
|
||||
osg::Node* node = read->readNode(fileName);
|
||||
|
||||
flt::Registry::instance()->clearObjectCache();
|
||||
|
||||
@@ -1541,7 +1541,7 @@ void ConvertFromFLT::setTexture ( FaceRecord *rec, SFace *pSFace, osg::StateSet
|
||||
if (pTexturePool)
|
||||
{
|
||||
int nIndex = (int)pSFace->iTexturePattern;
|
||||
flt::AttrData *textureAttrData = pTexturePool->getTexture(nIndex,rec->getFlightVersion());
|
||||
flt::AttrData *textureAttrData = pTexturePool->getTexture(nIndex,rec->getFltFile()->getOptions());
|
||||
|
||||
osg::StateSet *textureStateSet;
|
||||
if (textureAttrData)
|
||||
@@ -1561,7 +1561,7 @@ void ConvertFromFLT::setTexture ( FaceRecord *rec, SFace *pSFace, osg::StateSet
|
||||
flt::AttrData *detailTextureAttrData = NULL;
|
||||
if (pSFace->iDetailTexturePattern != -1) {
|
||||
int nIndex2 = (int)pSFace->iDetailTexturePattern;
|
||||
detailTextureAttrData = pTexturePool->getTexture(nIndex2,rec->getFlightVersion());
|
||||
detailTextureAttrData = pTexturePool->getTexture(nIndex2,rec->getFltFile()->getOptions());
|
||||
if (detailTextureAttrData && detailTextureAttrData->stateset) {
|
||||
osg::Texture2D *detTexture = dynamic_cast<osg::Texture2D*>(detailTextureAttrData->stateset->getTextureAttribute( 0, osg::StateAttribute::TEXTURE));
|
||||
textureStateSet->setTextureAttributeAndModes(1,detTexture,osg::StateAttribute::ON);
|
||||
@@ -1679,9 +1679,9 @@ ConvertFromFLT::addMultiTexture( DynGeoSet* dgset, MultiTextureRecord* mtr )
|
||||
}
|
||||
|
||||
// Get the texture attribute data from the texture pool
|
||||
flt::AttrData *textureAttrData = dynamic_cast<flt::AttrData *> (pTexturePool->getTexture((int)mt->data[l].texture,mtr->getFlightVersion()));
|
||||
flt::AttrData *textureAttrData = dynamic_cast<flt::AttrData *> (pTexturePool->getTexture((int)mt->data[l].texture,mtr->getFltFile()->getOptions()));
|
||||
|
||||
CERR << "pTexturePool->getTexture((int)mt->data[l].texture): " << pTexturePool->getTexture((int)mt->data[l].texture,mtr->getFlightVersion()) << "\n";
|
||||
CERR << "pTexturePool->getTexture((int)mt->data[l].texture): " << pTexturePool->getTexture((int)mt->data[l].texture,mtr->getFltFile()->getOptions()) << "\n";
|
||||
if (!textureAttrData)
|
||||
{
|
||||
CERR << "unable to set up multi-texture layer." << std::endl;
|
||||
@@ -2424,27 +2424,6 @@ osg::Group* ConvertFromFLT::visitMatrix(osg::Group& osgParent, const osg::Group&
|
||||
|
||||
osg::Group* ConvertFromFLT::visitExternal(osg::Group& osgParent, ExternalRecord* rec)
|
||||
{
|
||||
// SExternalReference *pSExternal = (SExternalReference*)rec->getData();
|
||||
|
||||
std::string filePath = osgDB::getFilePath(rec->getFilename());
|
||||
std::string pushAndPopPath;
|
||||
//If absolute path
|
||||
if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) ||
|
||||
(filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) )
|
||||
{
|
||||
pushAndPopPath = filePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
osgDB::FilePathList fpl = osgDB::getDataFilePathList();
|
||||
pushAndPopPath = fpl.empty() ? "." : fpl.front();
|
||||
if(pushAndPopPath.empty()) pushAndPopPath = ".";
|
||||
pushAndPopPath += "/" + filePath;
|
||||
}
|
||||
|
||||
osgDB::PushAndPopDataPath tmpfile(pushAndPopPath);
|
||||
//osgDB::PushAndPopDataPath tmpfile(osgDB::getFilePath(rec->getFilename()));
|
||||
|
||||
|
||||
FltFile* pFile = rec->getExternal();
|
||||
osg::Group* external = NULL;
|
||||
|
||||
@@ -22,12 +22,12 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter
|
||||
osgDB::equalCaseInsensitive(extension,"fnt"); // Windows bitmap fonts
|
||||
}
|
||||
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osgText::Font* font = FreeTypeLibrary::instance()->getFont(fileName,0);
|
||||
|
||||
@@ -30,7 +30,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
|
||||
osg::notify(osg::INFO) << "GDAL : " << file << std::endl;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
initGDAL();
|
||||
|
||||
@@ -400,12 +400,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
|
||||
virtual ReadResult readObject(const std::string& fileName, const Options* opt) { return readNode(fileName,opt); }
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream fin(fileName.c_str(), std::ios::binary | std::ios::in );
|
||||
|
||||
@@ -324,12 +324,12 @@ class ReaderWriterGIF : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"gif");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -30,7 +30,7 @@ class IVEReaderWriter : public ReaderWriter
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
// code for setting up the database path so that any paged
|
||||
|
||||
@@ -194,7 +194,7 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter
|
||||
std::string ext = osgDB::getFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if(fileName.empty())
|
||||
{
|
||||
// note from Robert, Dec03, I find returning a valid image when no
|
||||
|
||||
@@ -434,12 +434,12 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"jpeg") || osgDB::equalCaseInsensitive(extension,"jpg");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -84,7 +84,6 @@ class PrintVisitor : public NodeVisitor
|
||||
int _step;
|
||||
};
|
||||
|
||||
typedef std::map<std::string,osg::StateSet*> StateSetMap;
|
||||
class ReaderWriter3DS : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
@@ -94,25 +93,32 @@ class ReaderWriter3DS : public osgDB::ReaderWriter
|
||||
virtual const char* className() const { return "3DS Auto Studio Reader"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"3ds"); }
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*);
|
||||
|
||||
typedef std::vector<int> FaceList;
|
||||
typedef std::map<std::string,osg::StateSet*> GeoStateMap;
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options);
|
||||
|
||||
protected:
|
||||
|
||||
osg::Texture2D* createTexture(Lib3dsTextureMap *texture,const char* label,bool& transparancy);
|
||||
osg::StateSet* createStateSet(Lib3dsMaterial *materials);
|
||||
osg::Drawable* createDrawable(Lib3dsMesh *meshes,FaceList& faceList, Lib3dsMatrix* matrix);
|
||||
|
||||
std::string _directory;
|
||||
bool _useSmoothingGroups;
|
||||
bool _usePerVertexNormals;
|
||||
class ReaderObject
|
||||
{
|
||||
public:
|
||||
ReaderObject();
|
||||
|
||||
typedef std::map<std::string,osg::StateSet*> StateSetMap;
|
||||
typedef std::vector<int> FaceList;
|
||||
typedef std::map<std::string,osg::StateSet*> GeoStateMap;
|
||||
|
||||
// MIKEC
|
||||
osg::Node* processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, Lib3dsMatrix* matrix);
|
||||
osg::Node* processNode(StateSetMap drawStateMap,Lib3dsFile *f,Lib3dsNode *node);
|
||||
osg::Texture2D* createTexture(Lib3dsTextureMap *texture,const char* label,bool& transparancy, const osgDB::ReaderWriter::Options* options);
|
||||
osg::StateSet* createStateSet(Lib3dsMaterial *materials, const osgDB::ReaderWriter::Options* options);
|
||||
osg::Drawable* createDrawable(Lib3dsMesh *meshes,FaceList& faceList, Lib3dsMatrix* matrix);
|
||||
|
||||
std::string _directory;
|
||||
bool _useSmoothingGroups;
|
||||
bool _usePerVertexNormals;
|
||||
|
||||
// MIKEC
|
||||
osg::Node* processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, Lib3dsMatrix* matrix);
|
||||
osg::Node* processNode(StateSetMap drawStateMap,Lib3dsFile *f,Lib3dsNode *node);
|
||||
};
|
||||
};
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
@@ -120,6 +126,10 @@ class ReaderWriter3DS : public osgDB::ReaderWriter
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriter3DS> g_readerWriter_3DS_Proxy;
|
||||
|
||||
ReaderWriter3DS::ReaderWriter3DS()
|
||||
{
|
||||
}
|
||||
|
||||
ReaderWriter3DS::ReaderObject::ReaderObject()
|
||||
{
|
||||
_useSmoothingGroups = true;
|
||||
_usePerVertexNormals = true;
|
||||
@@ -201,7 +211,7 @@ void print(Lib3dsNode *node, int level) {
|
||||
// Transforms points by matrix if 'matrix' is not NULL
|
||||
// Creates a Geode and Geometry (as parent,child) and adds the Geode to 'parent' parameter iff 'parent' is non-NULL
|
||||
// Returns ptr to the Geode
|
||||
osg::Node* ReaderWriter3DS::processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, Lib3dsMatrix* matrix) {
|
||||
osg::Node* ReaderWriter3DS::ReaderObject::processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, Lib3dsMatrix* matrix) {
|
||||
typedef std::vector<int> FaceList;
|
||||
typedef std::map<std::string,FaceList> MaterialFaceMap;
|
||||
MaterialFaceMap materialFaceMap;
|
||||
@@ -286,7 +296,7 @@ How to cope with pivot points in 3ds (short version)
|
||||
Tranform the node by the node matrix, which does the orientation about the pivot point, (and currently) transforms the object back by a translation to the PP.
|
||||
|
||||
*/
|
||||
osg::Node* ReaderWriter3DS::processNode(StateSetMap drawStateMap,Lib3dsFile *f,Lib3dsNode *node) {
|
||||
osg::Node* ReaderWriter3DS::ReaderObject::processNode(StateSetMap drawStateMap,Lib3dsFile *f,Lib3dsNode *node) {
|
||||
|
||||
osg::Group* group=NULL;// created on demand if we find we have children to group together
|
||||
|
||||
@@ -406,13 +416,13 @@ osg::Node* ReaderWriter3DS::processNode(StateSetMap drawStateMap,Lib3dsFile *f,L
|
||||
}
|
||||
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
Lib3dsFile *f = lib3ds_file_load(fileName.c_str());
|
||||
@@ -424,16 +434,18 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
// but is VERY necessary if you want to use pivot points...
|
||||
lib3ds_file_eval(f,0.0f); // second param is time 't' for animated files
|
||||
|
||||
_directory = osgDB::getFilePath(fileName);
|
||||
ReaderObject reader;
|
||||
|
||||
reader._directory = osgDB::getFilePath(fileName);
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
group->setName(fileName);
|
||||
|
||||
StateSetMap drawStateMap;
|
||||
ReaderObject::StateSetMap drawStateMap;
|
||||
|
||||
for (Lib3dsMaterial *mat=f->materials; mat; mat=mat->next)
|
||||
{
|
||||
drawStateMap[mat->name] = createStateSet(mat);
|
||||
drawStateMap[mat->name] = reader.createStateSet(mat, options);
|
||||
}
|
||||
|
||||
/*{
|
||||
@@ -463,11 +475,11 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
|
||||
if (traverse_nodes) { // old method
|
||||
for (Lib3dsMesh *mesh=f->meshes; mesh; mesh=mesh->next) {
|
||||
processMesh(drawStateMap,group,mesh,NULL);
|
||||
reader.processMesh(drawStateMap,group,mesh,NULL);
|
||||
}
|
||||
} else { // new method
|
||||
for(Lib3dsNode *node=f->nodes; node; node=node->next) {
|
||||
group->addChild(processNode(drawStateMap,f,node));
|
||||
group->addChild(reader.processNode(drawStateMap,f,node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,7 +497,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fil
|
||||
/**
|
||||
use matrix to pretransform geometry, or NULL to do nothing
|
||||
*/
|
||||
osg::Drawable* ReaderWriter3DS::createDrawable(Lib3dsMesh *m,FaceList& faceList,Lib3dsMatrix *matrix)
|
||||
osg::Drawable* ReaderWriter3DS::ReaderObject::createDrawable(Lib3dsMesh *m,FaceList& faceList,Lib3dsMatrix *matrix)
|
||||
{
|
||||
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
@@ -636,7 +648,7 @@ osg::Drawable* ReaderWriter3DS::createDrawable(Lib3dsMesh *m,FaceList& faceLis
|
||||
}
|
||||
|
||||
|
||||
osg::Texture2D* ReaderWriter3DS::createTexture(Lib3dsTextureMap *texture,const char* label,bool& transparancy)
|
||||
osg::Texture2D* ReaderWriter3DS::ReaderObject::createTexture(Lib3dsTextureMap *texture,const char* label,bool& transparancy, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
if (texture && *(texture->name))
|
||||
{
|
||||
@@ -644,7 +656,7 @@ osg::Texture2D* ReaderWriter3DS::createTexture(Lib3dsTextureMap *texture,const
|
||||
if (fileName.empty())
|
||||
{
|
||||
// file not found in .3ds file's directory, so we'll look in the datafile path list.
|
||||
fileName = osgDB::findDataFile(texture->name,osgDB::CASE_INSENSITIVE);
|
||||
fileName = osgDB::findDataFile(texture->name,options, osgDB::CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
if (fileName.empty())
|
||||
@@ -696,7 +708,7 @@ osg::Texture2D* ReaderWriter3DS::createTexture(Lib3dsTextureMap *texture,const
|
||||
}
|
||||
|
||||
|
||||
osg::StateSet* ReaderWriter3DS::createStateSet(Lib3dsMaterial *mat)
|
||||
osg::StateSet* ReaderWriter3DS::ReaderObject::createStateSet(Lib3dsMaterial *mat, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
if (mat==NULL) return NULL;
|
||||
|
||||
@@ -722,7 +734,7 @@ osg::StateSet* ReaderWriter3DS::createStateSet(Lib3dsMaterial *mat)
|
||||
stateset->setAttribute(material);
|
||||
|
||||
bool textureTransparancy=false;
|
||||
osg::Texture2D* texture1_map = createTexture(&(mat->texture1_map),"texture1_map",textureTransparancy);
|
||||
osg::Texture2D* texture1_map = createTexture(&(mat->texture1_map),"texture1_map",textureTransparancy, options);
|
||||
if (texture1_map)
|
||||
{
|
||||
stateset->setTextureAttributeAndModes(0,texture1_map,osg::StateAttribute::ON);
|
||||
|
||||
@@ -191,12 +191,12 @@ public:
|
||||
return osgDB::equalCaseInsensitive(extension,"logo");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO)<< "ReaderWriterLOGO::readNode( "<<fileName.c_str()<<" )\n";
|
||||
|
||||
@@ -241,9 +241,9 @@ osg::Group *Converter::convert(const iff::Chunk_list &data)
|
||||
return convert(obj);
|
||||
}
|
||||
|
||||
osg::Group *Converter::convert(const std::string &filename)
|
||||
osg::Group *Converter::convert(const std::string &filename, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string file = osgDB::findDataFile(filename);
|
||||
std::string file = osgDB::findDataFile(filename, options);
|
||||
if (file.empty()) return 0;
|
||||
|
||||
std::ifstream ifs(file.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Group>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace lwosg
|
||||
@@ -37,7 +39,7 @@ namespace lwosg
|
||||
|
||||
osg::Group *convert(Object &obj);
|
||||
osg::Group *convert(const iff::Chunk_list &data);
|
||||
osg::Group *convert(const std::string &filename);
|
||||
osg::Group *convert(const std::string &filename, const osgDB::ReaderWriter::Options* options);
|
||||
|
||||
inline osg::Group *get_root() { return root_.get(); }
|
||||
inline const osg::Group *get_root() const { return root_.get(); }
|
||||
|
||||
@@ -53,27 +53,27 @@ public:
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
ReadResult result = readNode_LWO1(fileName,options);
|
||||
if (result.success()) return result;
|
||||
|
||||
if (!options || options->getOptionString() != "USE_OLD_READER") {
|
||||
ReadResult result = readNode_LWO2(fileName, options);
|
||||
if (result.success()) return result;
|
||||
}
|
||||
if (!options || options->getOptionString() != "USE_OLD_READER") {
|
||||
ReadResult result = readNode_LWO2(fileName, options);
|
||||
if (result.success()) return result;
|
||||
}
|
||||
|
||||
return readNode_old_LWO2(fileName, options);
|
||||
return readNode_old_LWO2(fileName, options);
|
||||
}
|
||||
|
||||
lwosg::Converter::Options parse_options(const Options *options) const;
|
||||
lwosg::Converter::Options parse_options(const Options *options) const;
|
||||
|
||||
virtual ReadResult readNode_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*);
|
||||
virtual ReadResult readNode_old_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*);
|
||||
virtual ReadResult readNode_old_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*);
|
||||
virtual ReadResult readNode_LWO1(const std::string& fileName, const osgDB::ReaderWriter::Options*);
|
||||
|
||||
protected:
|
||||
@@ -84,25 +84,25 @@ protected:
|
||||
|
||||
lwosg::Converter::Options ReaderWriterLWO::parse_options(const Options *options) const
|
||||
{
|
||||
lwosg::Converter::Options conv_options;
|
||||
lwosg::Converter::Options conv_options;
|
||||
|
||||
if (options) {
|
||||
std::istringstream iss(options->getOptionString());
|
||||
std::string opt;
|
||||
while (iss >> opt) {
|
||||
if (opt == "FORCE_ARB_COMPRESSION") conv_options.force_arb_compression = true;
|
||||
if (opt == "USE_OSGFX") conv_options.use_osgfx = true;
|
||||
if (opt == "NO_LIGHTMODEL_ATTRIBUTE") conv_options.apply_light_model = false;
|
||||
if (opt == "MAX_TEXTURE_UNITS") {
|
||||
int n;
|
||||
if (iss >> n) {
|
||||
conv_options.max_tex_units = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (options) {
|
||||
std::istringstream iss(options->getOptionString());
|
||||
std::string opt;
|
||||
while (iss >> opt) {
|
||||
if (opt == "FORCE_ARB_COMPRESSION") conv_options.force_arb_compression = true;
|
||||
if (opt == "USE_OSGFX") conv_options.use_osgfx = true;
|
||||
if (opt == "NO_LIGHTMODEL_ATTRIBUTE") conv_options.apply_light_model = false;
|
||||
if (opt == "MAX_TEXTURE_UNITS") {
|
||||
int n;
|
||||
if (iss >> n) {
|
||||
conv_options.max_tex_units = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return conv_options;
|
||||
return conv_options;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,15 +111,15 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterLWO> g_lwoReaderWriterProxy;
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO2(const std::string &fileName, const osgDB::ReaderWriter::Options *options)
|
||||
{
|
||||
lwosg::Converter::Options conv_options = parse_options(options);
|
||||
lwosg::Converter::Options conv_options = parse_options(options);
|
||||
|
||||
lwosg::Converter converter(conv_options);
|
||||
osg::ref_ptr<osg::Node> node = converter.convert(fileName);
|
||||
if (node.valid()) {
|
||||
return node.take();
|
||||
}
|
||||
lwosg::Converter converter(conv_options);
|
||||
osg::ref_ptr<osg::Node> node = converter.convert(fileName, options);
|
||||
if (node.valid()) {
|
||||
return node.take();
|
||||
}
|
||||
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ public:
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile(file);
|
||||
std::string fileName = osgDB::findDataFile(file, options);
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
lwosg::SceneLoader::Options conv_options = parse_options(options);
|
||||
|
||||
lwosg::SceneLoader scene_loader(conv_options);
|
||||
osg::ref_ptr<osg::Node> node = scene_loader.load(fileName);
|
||||
osg::ref_ptr<osg::Node> node = scene_loader.load(fileName, options);
|
||||
if (node.valid()) {
|
||||
return node.take();
|
||||
}
|
||||
|
||||
@@ -80,12 +80,12 @@ SceneLoader::SceneLoader(const Options &options)
|
||||
{
|
||||
}
|
||||
|
||||
osg::Group *SceneLoader::load(const std::string &filename, bool search)
|
||||
osg::Group *SceneLoader::load(const std::string &filename, const osgDB::ReaderWriter::Options *options, bool search)
|
||||
{
|
||||
std::string fname;
|
||||
|
||||
if (search) {
|
||||
fname = osgDB::findDataFile(filename);
|
||||
fname = osgDB::findDataFile(filename, options);
|
||||
if (fname.empty()) return 0;
|
||||
} else {
|
||||
fname = filename;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -60,7 +62,7 @@ namespace lwosg
|
||||
SceneLoader();
|
||||
SceneLoader(const Options &options);
|
||||
|
||||
osg::Group *load(const std::string &filename, bool search = false);
|
||||
osg::Group *load(const std::string &filename, const osgDB::ReaderWriter::Options *options, bool search = false);
|
||||
|
||||
inline osg::Group *get_root() { return root_.get(); }
|
||||
inline const osg::Group *get_root() const { return root_.get(); }
|
||||
|
||||
@@ -61,12 +61,12 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterMD2> g_readerWriter_MD2_Proxy;
|
||||
|
||||
osgDB::ReaderWriter::ReadResult
|
||||
ReaderWriterMD2::readNode (const std::string& file,
|
||||
const osgDB::ReaderWriter::Options*)
|
||||
const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string filename = osgDB::findDataFile( file );
|
||||
std::string filename = osgDB::findDataFile( file, options );
|
||||
if (filename.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
return load_md2 (filename.data());
|
||||
|
||||
@@ -21,12 +21,12 @@ class ReaderWriterMPEG : public osgDB::ReaderWriter
|
||||
osgDB::equalCaseInsensitive(extension,"mpv");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::MpegImageStream* mpeg = new osg::MpegImageStream(fileName.c_str());
|
||||
|
||||
@@ -446,12 +446,12 @@ osg::Node* ReaderWriterOBJ::convertModelToSceneGraph(obj::Model& model)
|
||||
|
||||
|
||||
// read file and convert to OSG.
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil
|
||||
|
||||
obj::Model model;
|
||||
model.setDatabasePath(osgDB::getFilePath(fileName.c_str()));
|
||||
model.readOBJ(fin);
|
||||
model.readOBJ(fin, options);
|
||||
|
||||
osg::Node* node = convertModelToSceneGraph(model);
|
||||
return node;
|
||||
@@ -470,12 +470,12 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(std::istream& fin, const Options*)
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(std::istream& fin, const Options* options)
|
||||
{
|
||||
if (fin)
|
||||
{
|
||||
obj::Model model;
|
||||
model.readOBJ(fin);
|
||||
model.readOBJ(fin, options);
|
||||
|
||||
osg::Node* node = convertModelToSceneGraph(model);
|
||||
return node;
|
||||
|
||||
@@ -260,7 +260,7 @@ bool Model::readMTL(std::istream& fin)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Model::readOBJ(std::istream& fin)
|
||||
bool Model::readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Reading OBJ file"<<std::endl;
|
||||
|
||||
@@ -390,7 +390,7 @@ bool Model::readOBJ(std::istream& fin)
|
||||
else if (strncmp(line,"mtllib ",7)==0)
|
||||
{
|
||||
|
||||
std::string fileName = osgDB::findDataFile( line+7 );
|
||||
std::string fileName = osgDB::findDataFile( line+7, options );
|
||||
if (!fileName.empty())
|
||||
{
|
||||
std::ifstream mfin(fileName.c_str());
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
|
||||
namespace obj
|
||||
{
|
||||
@@ -157,7 +159,7 @@ public:
|
||||
const std::string& getDatabasePath() const { return databasePath; }
|
||||
|
||||
bool readMTL(std::istream& fin);
|
||||
bool readOBJ(std::istream& fin);
|
||||
bool readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* options);
|
||||
|
||||
bool readline(std::istream& fin, char* line, const int LINE_SIZE);
|
||||
void addElement(Element* element);
|
||||
|
||||
@@ -32,18 +32,14 @@ class OSGReaderWriter : public ReaderWriter
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, opt );
|
||||
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<Options> local_opt = const_cast<Options*>(opt);
|
||||
if (!local_opt) local_opt = new Options;
|
||||
osg::ref_ptr<Options> local_opt = opt ? static_cast<Options*>(opt->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
|
||||
|
||||
if (local_opt.valid() && local_opt->getDatabasePathList().empty())
|
||||
{
|
||||
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
}
|
||||
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
|
||||
std::ifstream fin(fileName.c_str());
|
||||
if (fin)
|
||||
|
||||
@@ -17,13 +17,13 @@ public:
|
||||
return osgDB::equalCaseInsensitive(extension,"osga");
|
||||
}
|
||||
|
||||
virtual ReadResult openArchive(const std::string& file,ArchiveStatus status, unsigned int indexBlockSize = 4096, const Options* = NULL)
|
||||
virtual ReadResult openArchive(const std::string& file,ArchiveStatus status, unsigned int indexBlockSize = 4096, const Options* options=NULL)
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty())
|
||||
{
|
||||
if (status==READ) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
@@ -30,12 +30,12 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"osgtgz");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file,options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO)<<"sgReaderWriterOSGTGZ::readNode( "<<fileName.c_str()<<" )\n";
|
||||
@@ -75,7 +75,8 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
|
||||
|
||||
osg::Group *grp = new osg::Group;
|
||||
|
||||
osgDB::PushAndPopDataPath tmppath(dirname );
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_options = options ? static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options;
|
||||
local_options->getDatabasePathList().push_front(dirname);
|
||||
|
||||
osgDB::DirectoryContents contents = osgDB::getDirectoryContents(dirname);
|
||||
for(osgDB::DirectoryContents::iterator itr = contents.begin();
|
||||
@@ -85,7 +86,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
|
||||
std::string file_ext = osgDB::getLowerCaseFileExtension(*itr);
|
||||
if (osgDB::equalCaseInsensitive(file_ext,"osg"))
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile( *itr );
|
||||
osg::Node *node = osgDB::readNodeFile( *itr, local_options.get() );
|
||||
grp->addChild( node );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
|
||||
false;
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) fileName = file; // let Peformer see if it can file the filep
|
||||
|
||||
osg::notify(osg::INFO)<<"ReaderWriterPFB::readImage( "<<fileName.c_str()<<" )\n";
|
||||
@@ -155,7 +155,7 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO)<<"ReaderWriterPFB::readNode( "<<fileName.c_str()<<" )\n";
|
||||
|
||||
@@ -194,12 +194,12 @@ class ReaderWriterPIC : public osgDB::ReaderWriter
|
||||
virtual const char* className() const { return "PIC Image Reader"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"pic"); }
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -36,12 +36,12 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
virtual const char* className() const { return "PNG Image Reader/Writer"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"png"); }
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
int trans = PNG_ALPHA;
|
||||
|
||||
@@ -25,12 +25,12 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
|
||||
osgDB::equalCaseInsensitive(extension, "pbm");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
FILE *fp = NULL;
|
||||
|
||||
@@ -355,12 +355,12 @@ class ReaderWriterRGB : public osgDB::ReaderWriter
|
||||
osgDB::equalCaseInsensitive(extension,"bw");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
rawImageRec *raw;
|
||||
|
||||
@@ -103,12 +103,12 @@ const float StlColorDepth = float(StlColorSize); // 2^5 - 1
|
||||
|
||||
// Read node
|
||||
osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& file,
|
||||
const osgDB::ReaderWriter::Options*)
|
||||
const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO) << "ReaderWriterSTL::readNode(" << fileName.c_str() << ")\n";
|
||||
|
||||
@@ -478,12 +478,12 @@ class ReaderWriterTGA : public osgDB::ReaderWriter
|
||||
virtual const char* className() const { return "TGA Image Reader"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"tga"); }
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -31,12 +31,17 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"tgz");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
osg::notify(osg::NOTICE)<<"file="<<file<<std::endl;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
|
||||
osg::notify(osg::NOTICE)<<"fileName="<<fileName<<std::endl;
|
||||
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO)<< "ReaderWriterTGZ::readNode( "<<fileName.c_str()<<" )\n";
|
||||
@@ -70,11 +75,20 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
|
||||
fileName.c_str(), dirname, dirname,
|
||||
fileName.c_str());
|
||||
#endif
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Running command '"<<command<<"'"<<std::endl;
|
||||
|
||||
system( command );
|
||||
|
||||
osg::Group *grp = new osg::Group;
|
||||
|
||||
osgDB::PushAndPopDataPath tmppath(dirname );
|
||||
osg::notify(osg::NOTICE)<<"Done"<<std::endl;
|
||||
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_options = options ? static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options;
|
||||
local_options->getDatabasePathList().push_front(dirname);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"local_options->getDatabasePathList().="<<local_options->getDatabasePathList().front()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"dirname="<<dirname<<std::endl;
|
||||
|
||||
// deactivate the automatic generation of images to geode's.
|
||||
bool prevCreateNodeFromImage = osgDB::Registry::instance()->getCreateNodeFromImage();
|
||||
@@ -90,7 +104,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
|
||||
*itr!=std::string(".") &&
|
||||
*itr!=std::string(".."))
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile(*itr);
|
||||
osg::Node *node = osgDB::readNodeFile(*itr, local_options.get());
|
||||
grp->addChild( node );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,12 +420,12 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
unsigned char *imageData = NULL;
|
||||
|
||||
@@ -29,7 +29,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::readNode(const std::string& fil
|
||||
// We load archive.txp
|
||||
if (strncmp(name.c_str(),"archive",7)==0)
|
||||
{
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::ref_ptr<TXPNode> txpNode = new TXPNode;
|
||||
|
||||
@@ -29,13 +29,13 @@ class ReaderWriterZIP : public osgDB::ReaderWriter
|
||||
return osgDB::equalCaseInsensitive(extension,"zip");
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(file);
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file );
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::notify(osg::INFO)<<"ReaderWriterZIP::readNode( "<<fileName.c_str()<<" )\n";
|
||||
@@ -67,7 +67,8 @@ class ReaderWriterZIP : public osgDB::ReaderWriter
|
||||
|
||||
osg::Group *grp = new osg::Group;
|
||||
|
||||
osgDB::PushAndPopDataPath tmppath(dirname );
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_options = options ? static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options;
|
||||
local_options->getDatabasePathList().push_front(dirname);
|
||||
|
||||
bool prevCreateNodeFromImage = osgDB::Registry::instance()->getCreateNodeFromImage();
|
||||
osgDB::Registry::instance()->setCreateNodeFromImage(false);
|
||||
@@ -82,7 +83,7 @@ class ReaderWriterZIP : public osgDB::ReaderWriter
|
||||
*itr!=std::string(".") &&
|
||||
*itr!=std::string(".."))
|
||||
{
|
||||
osg::Node *node = osgDB::readNodeFile( *itr );
|
||||
osg::Node *node = osgDB::readNodeFile( *itr, local_options.get() );
|
||||
grp->addChild( node );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user