Moved the responsibility for finding file to load on to the ReaderWriter plugins,

instead of osgDB::Registry where it original lay.  This has been done to allow
fileName strings to be encode data rather than just file names, such as one
requires when using PagedLOD along with plugins for doing dynamic tesselation.
This commit is contained in:
Robert Osfield
2003-12-08 11:24:43 +00:00
parent 3e7fadb2ec
commit 83bf813e58
41 changed files with 489 additions and 367 deletions

View File

@@ -153,6 +153,7 @@ EXAMPLE_DIRS = \
osgpagedlod\
osgpick\
osgpoints\
# osgphotoalbum\
osgprerender\
osgprerendercubemap\
osgreflect\

View File

@@ -1,5 +1,6 @@
#include <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include "SlideShowConstructor.h"
@@ -442,12 +443,14 @@ void ReaderWriterSS3D::parseSlide (SlideShowConstructor& constructor, xmlDocPtr
return;
}
osgDB::ReaderWriter::ReadResult ReaderWriterSS3D::readNode(const std::string& fileName,
osgDB::ReaderWriter::ReadResult ReaderWriterSS3D::readNode(const std::string& file,
const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if (!acceptsExtension(ext))
return ReadResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

View File

@@ -61,6 +61,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Referenced
enum ReadStatus
{
FILE_NOT_HANDLED,
FILE_NOT_FOUND,
FILE_LOADED,
ERROR_IN_READING_FILE
};
@@ -93,6 +94,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Referenced
bool success() const { return _status==FILE_LOADED; }
bool error() const { return _status==ERROR_IN_READING_FILE; }
bool notHandled() const { return _status==FILE_NOT_HANDLED; }
bool notFound() const { return _status==FILE_NOT_FOUND; }
protected:

View File

@@ -34,7 +34,7 @@ class OSGUTIL_EXPORT TriStripVisitor : public osg::NodeVisitor
/// default to traversing all children.
TriStripVisitor() :
osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ),
_cacheSize( 24 ),
_cacheSize( 16 ),
_minStripSize( 2 )
{}

View File

@@ -37,9 +37,6 @@
bool osgDB::fileExists(const std::string& filename)
{
// hack for getting TXP plugin to utilise PagedLOD.
if (getLowerCaseFileExtension(filename)=="txp") return true;
return access( filename.c_str(), F_OK ) == 0;
}

View File

@@ -325,7 +325,7 @@ void Registry::addDotOsgWrapper(DotOsgWrapper* wrapper)
const osg::Object* proto = wrapper->getPrototype();
_objectWrapperMap[name] = wrapper;
if (wrapper->getReadWriteMode()==DotOsgWrapper::READ_AND_WRITE) _classNameWrapperMap[name] = wrapper;
if (wrapper->getReadWriteMode()==DotOsgWrapper::READ_AND_WRITE) _classNameWrapperMap[name] = wrapper;
if (proto)
{
@@ -468,7 +468,7 @@ std::string Registry::createLibraryNameForNodeKit(const std::string& name)
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__ // [
return "cyg"+name+".dll";
return "cyg"+name+".dll";
#elif defined(__MINGW32__)
return "lib"+name+".dll";
#else
@@ -570,17 +570,17 @@ ReaderWriter* Registry::getReaderWriterForExtension(const std::string& ext)
struct concrete_wrapper: basic_type_wrapper
{
concrete_wrapper(const osg::Object *myobj) : myobj_(myobj) {}
bool matches(const osg::Object *proto) const
{
return myobj_->isSameKindAs(proto);
}
const osg::Object *myobj_;
concrete_wrapper(const osg::Object *myobj) : myobj_(myobj) {}
bool matches(const osg::Object *proto) const
{
return myobj_->isSameKindAs(proto);
}
const osg::Object *myobj_;
};
osg::Object* Registry::readObjectOfType(const osg::Object& compObj,Input& fr)
{
return readObjectOfType(concrete_wrapper(&compObj), fr);
return readObjectOfType(concrete_wrapper(&compObj), fr);
}
osg::Object* Registry::readObjectOfType(const basic_type_wrapper &btw,Input& fr)
@@ -980,16 +980,16 @@ bool Registry::writeObject(const osg::Object& obj,Output& fw)
}
std::string classname = obj.className();
std::string libraryName = obj.libraryName();
std::string compositeName = libraryName + "::" + classname;
std::string libraryName = obj.libraryName();
std::string compositeName = libraryName + "::" + classname;
// try composite name first
DotOsgWrapperMap::iterator itr = _classNameWrapperMap.find(compositeName);
// try composite name first
DotOsgWrapperMap::iterator itr = _classNameWrapperMap.find(compositeName);
// composite name not found, try simple class name
if (itr == _classNameWrapperMap.end()) {
itr = _classNameWrapperMap.find(classname);
}
// composite name not found, try simple class name
if (itr == _classNameWrapperMap.end()) {
itr = _classNameWrapperMap.find(classname);
}
if (itr==_classNameWrapperMap.end())
{
@@ -1148,11 +1148,8 @@ ReaderWriter::ReadResult Registry::readObject(const std::string& fileName)
return results.front();
}
ReaderWriter::ReadResult Registry::readObject(const std::string& fileName,bool useObjectCache)
ReaderWriter::ReadResult Registry::readObject(const std::string& file,bool useObjectCache)
{
std::string file = findDataFile( fileName );
if (file.empty()) return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
if (useObjectCache)
{
// search for entry in the object cache.
@@ -1286,12 +1283,8 @@ ReaderWriter::ReadResult Registry::readImage(const std::string& fileName)
}
ReaderWriter::ReadResult Registry::readImage(const std::string& fileName,bool useObjectCache)
ReaderWriter::ReadResult Registry::readImage(const std::string& file,bool useObjectCache)
{
std::string file = findDataFile( fileName );
if (file.empty())
file = fileName;
// return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
if (useObjectCache)
{
@@ -1314,8 +1307,8 @@ ReaderWriter::ReadResult Registry::readImage(const std::string& fileName,bool us
notify(INFO)<<"Adding to cache image "<<file<<std::endl;
addEntryToObjectCache(file,rr.getObject());
}
else
return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
else
return ReaderWriter::ReadResult("Warning: file \""+file+"\" not found.");
return rr;
@@ -1430,13 +1423,8 @@ ReaderWriter::ReadResult Registry::readHeightField(const std::string& fileName)
}
ReaderWriter::ReadResult Registry::readHeightField(const std::string& fileName,bool useObjectCache)
ReaderWriter::ReadResult Registry::readHeightField(const std::string& file,bool useObjectCache)
{
std::string file = findDataFile( fileName );
if (file.empty())
file = fileName;
// return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
if (useObjectCache)
{
// search for entry in the object cache.
@@ -1458,8 +1446,8 @@ ReaderWriter::ReadResult Registry::readHeightField(const std::string& fileName,b
notify(INFO)<<"Adding to cache HeightField "<<file<<std::endl;
addEntryToObjectCache(file,rr.getObject());
}
else
return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
else
return ReaderWriter::ReadResult("Warning: file \""+file+"\" not found.");
return rr;
@@ -1587,12 +1575,8 @@ ReaderWriter::ReadResult Registry::readNode(const std::string& fileName)
return results.front();
}
ReaderWriter::ReadResult Registry::readNode(const std::string& fileName,bool useObjectCache)
ReaderWriter::ReadResult Registry::readNode(const std::string& file,bool useObjectCache)
{
std::string file = findDataFile( fileName );
if (file.empty()) return ReaderWriter::ReadResult("Warning: file \""+fileName+"\" not found.");
if (useObjectCache)
{
// search for entry in the object cache.

View File

@@ -3,6 +3,7 @@
#include <osg/Geometry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <iostream>
@@ -22,10 +23,13 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension,"asc");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::cout << "try to read file "<<fileName<<std::endl;

View File

@@ -20,12 +20,14 @@ ReaderWriterIV::ReaderWriterIV()
// Read file and convert to OSG
osgDB::ReaderWriter::ReadResult
ReaderWriterIV::readNode(const std::string& fileName,
ReaderWriterIV::readNode(const std::string& file,
const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if (!acceptsExtension(ext))
return ReadResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO) << "osgDB::ReaderWriterIV::readNode() Reading file "
<< fileName.data() << std::endl;

View File

@@ -6,6 +6,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
/****************************************************************************
*
@@ -318,12 +319,14 @@ class ReaderWriterBMP : public osgDB::ReaderWriter
virtual const char* className() { return "BMP Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"bmp"); }
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;
int height_ret;

View File

@@ -20,6 +20,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <stdio.h>
@@ -324,8 +325,14 @@ class ReaderWriterDDS : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"dds");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::Image* osgImage = ReadDDSFile(fileName.c_str());
if (osgImage==NULL) return ReadResult::FILE_NOT_HANDLED;
return osgImage;

View File

@@ -36,6 +36,7 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <assert.h>
#include <map>
@@ -69,12 +70,14 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterDirectX> g_readerWriter_DirectX_Pro
// Read node
osgDB::ReaderWriter::ReadResult ReaderWriterDirectX::readNode(const std::string& fileName,
osgDB::ReaderWriter::ReadResult ReaderWriterDirectX::readNode(const std::string& file,
const osgDB::ReaderWriter::Options* options)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if (!acceptsExtension(ext))
return ReadResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO) << "ReaderWriterDirectX::readNode(" << fileName.c_str() << ")\n";

View File

@@ -799,20 +799,25 @@ class ReaderWriterDW : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"dw");
}
virtual ReadResult readNode(const std::string& fileName,const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options*)
{
_dwobj obj;
enum reading {NONE, MATERIAL, OBJECT};
//unsigned short nrecs=0; // number of records read after a divider (numVerts, numFaces, numOpenings...)
int nexpected=0; // number of records to be read in a block
dwmaterial *matpalet=NULL;
int nmat=-1; // current element of matpalet being modified
int nmn=0; // number of materials found
reading rdg=NONE;
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
_dwobj obj;
enum reading {NONE, MATERIAL, OBJECT};
//unsigned short nrecs=0; // number of records read after a divider (numVerts, numFaces, numOpenings...)
int nexpected=0; // number of records to be read in a block
dwmaterial *matpalet=NULL;
int nmat=-1; // current element of matpalet being modified
int nmn=0; // number of materials found
reading rdg=NONE;
char buff[256];
notify(INFO)<< "ReaderWriterDW::readNode( "<<fileName.c_str()<<" )\n";

View File

@@ -37,6 +37,7 @@
#include <osg/GL>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <iostream>
@@ -748,11 +749,14 @@ class ReaderWriterATTR : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"attr");
}
virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
// options
char buf[256];
int version=0;

View File

@@ -13,6 +13,7 @@
#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
using namespace flt;
@@ -22,10 +23,13 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readObject(const std::string& f
}
osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
{
if( !acceptsExtension(osgDB::getFileExtension(fileName) ))
return ReadResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::ref_ptr<FltFile> read = new FltFile;

View File

@@ -1,4 +1,5 @@
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include "FreeTypeLibrary.h"
@@ -21,10 +22,13 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension,"fnt"); // Windows bitmap fonts
}
virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osgText::Font* font = FreeTypeLibrary::instance()->getFont(fileName,0);

View File

@@ -5,6 +5,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/ImageOptions>
#include <gdal_priv.h>
@@ -18,11 +19,14 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"gdal") || osgDB::equalCaseInsensitive(extension,"gdal");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
{
//std::string ext = osgDB::getFileExtension(fileName);
//std::string ext = osgDB::getFileExtension(file);
//if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
initGDAL();
std::auto_ptr<GDALDataset> dataset((GDALDataset*)GDALOpen(fileName.c_str(),GA_ReadOnly));
@@ -46,10 +50,10 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
osgDB::ImageOptions::TexCoordRange* texCoordRange = 0;
const osgDB::ImageOptions* imageOptions = dynamic_cast<const osgDB::ImageOptions*>(options);
osgDB::ImageOptions* imageOptions = dynamic_cast<osgDB::ImageOptions*>(const_cast<osgDB::ReaderWriter::Options*>(options));
if (imageOptions)
{
std::cout<<"Got ImageOptions"<<std::endl;
osg::notify(osg::INFO)<<"Got ImageOptions"<<std::endl;
int margin = 0;
switch(imageOptions->_sourceImageWindowMode)
@@ -71,7 +75,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
((double)(windowY+windowHeight) -(desiredY+desiredHeight))/(double)windowHeight,
(desiredWidth)/(double)windowWidth,
(desiredHeight)/(double)windowHeight);
std::cout<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
osg::notify(osg::INFO)<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
}
break;
case(osgDB::ImageOptions::PIXEL_WINDOW):
@@ -85,6 +89,13 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
break;
}
// reapply the window coords to the pixel window so that calling code
// knows the original pixel size
imageOptions->_sourcePixelWindow.windowX = windowX;
imageOptions->_sourcePixelWindow.windowY = windowY;
imageOptions->_sourcePixelWindow.windowWidth = windowWidth;
imageOptions->_sourcePixelWindow.windowHeight = windowHeight;
switch(imageOptions->_destinationImageWindowMode)
{
case(osgDB::ImageOptions::RATIO_WINDOW):
@@ -111,31 +122,31 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
// windowWidth = destWidth;
// windowHeight = destHeight;
std::cout << " windowX = "<<windowX<<std::endl;
std::cout << " windowY = "<<windowY<<std::endl;
std::cout << " windowWidth = "<<windowWidth<<std::endl;
std::cout << " windowHeight = "<<windowHeight<<std::endl;
osg::notify(osg::INFO) << " windowX = "<<windowX<<std::endl;
osg::notify(osg::INFO) << " windowY = "<<windowY<<std::endl;
osg::notify(osg::INFO) << " windowWidth = "<<windowWidth<<std::endl;
osg::notify(osg::INFO) << " windowHeight = "<<windowHeight<<std::endl;
std::cout << std::endl;
osg::notify(osg::INFO) << std::endl;
std::cout << " destX = "<<destX<<std::endl;
std::cout << " destY = "<<destY<<std::endl;
std::cout << " destWidth = "<<destWidth<<std::endl;
std::cout << " destHeight = "<<destHeight<<std::endl;
osg::notify(osg::INFO) << " destX = "<<destX<<std::endl;
osg::notify(osg::INFO) << " destY = "<<destY<<std::endl;
osg::notify(osg::INFO) << " destWidth = "<<destWidth<<std::endl;
osg::notify(osg::INFO) << " destHeight = "<<destHeight<<std::endl;
std::cout << std::endl;
osg::notify(osg::INFO) << std::endl;
std::cout << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
std::cout << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
osg::notify(osg::INFO) << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
osg::notify(osg::INFO) << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
double geoTransform[6];
if (dataset->GetGeoTransform(geoTransform)==CE_None)
{
std::cout << " GetGeoTransform "<< std::endl;
std::cout << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
std::cout << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
std::cout << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
osg::notify(osg::INFO) << " GetGeoTransform "<< std::endl;
osg::notify(osg::INFO) << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
osg::notify(osg::INFO) << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
osg::notify(osg::INFO) << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
}
int numBands = dataset->GetRasterCount();
@@ -159,12 +170,12 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
GDALRasterBand* band = dataset->GetRasterBand(b);
std::cout << " Band "<<b<<std::endl;
osg::notify(osg::INFO) << " Band "<<b<<std::endl;
std::cout << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
std::cout << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
std::cout << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
std::cout << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
osg::notify(osg::INFO) << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
osg::notify(osg::INFO) << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
osg::notify(osg::INFO) << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
osg::notify(osg::INFO) << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
if (band->GetColorInterpretation()==GCI_GrayIndex) bandGray = band;
else if (band->GetColorInterpretation()==GCI_RedBand) bandRed = band;
@@ -180,12 +191,12 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
// minmax[1] = band->GetMaximum(&gotMax);
// if (!(gotMin && gotMax))
// {
// std::cout<<" computing min max"<<std::endl;
// osg::notify(osg::INFO)<<" computing min max"<<std::endl;
// GDALComputeRasterMinMax(band,TRUE,minmax);
// }
//
// std::cout << " min "<<minmax[0]<<std::endl;
// std::cout << " max "<<minmax[1]<<std::endl;
// osg::notify(osg::INFO) << " min "<<minmax[0]<<std::endl;
// osg::notify(osg::INFO) << " max "<<minmax[1]<<std::endl;
if (dataType==0)
{
@@ -232,7 +243,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
pixelFormat = GL_RGBA;
internalFormat = GL_RGBA;
std::cout << "reading RGBA"<<std::endl;
osg::notify(osg::INFO) << "reading RGBA"<<std::endl;
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
@@ -251,7 +262,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
pixelFormat = GL_RGB;
internalFormat = GL_RGB;
std::cout << "reading RGB"<<std::endl;
osg::notify(osg::INFO) << "reading RGB"<<std::endl;
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
@@ -270,7 +281,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
pixelFormat = GL_LUMINANCE_ALPHA;
internalFormat = GL_LUMINANCE_ALPHA;
std::cout << "reading grey + alpha"<<std::endl;
osg::notify(osg::INFO) << "reading grey + alpha"<<std::endl;
bandGray->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
@@ -285,7 +296,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
pixelFormat = GL_LUMINANCE;
internalFormat = GL_LUMINANCE;
std::cout << "reading grey"<<std::endl;
osg::notify(osg::INFO) << "reading grey"<<std::endl;
bandGray->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
}
@@ -299,7 +310,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
pixelFormat = GL_ALPHA;
internalFormat = GL_ALPHA;
std::cout << "reading alpha"<<std::endl;
osg::notify(osg::INFO) << "reading alpha"<<std::endl;
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
@@ -307,7 +318,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
}
else
{
std::cout << "not found any usable bands in file."<<std::endl;
osg::notify(osg::INFO) << "not found any usable bands in file."<<std::endl;
}
@@ -364,7 +375,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
const osgDB::ImageOptions* imageOptions = dynamic_cast<const osgDB::ImageOptions*>(options);
if (imageOptions)
{
std::cout<<"Got ImageOptions"<<std::endl;
osg::notify(osg::INFO)<<"Got ImageOptions"<<std::endl;
int margin = 0;
switch(imageOptions->_sourceImageWindowMode)
@@ -386,7 +397,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
((double)(windowY+windowHeight) -(desiredY+desiredHeight))/(double)windowHeight,
(desiredWidth)/(double)windowWidth,
(desiredHeight)/(double)windowHeight);
std::cout<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
osg::notify(osg::INFO)<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
}
break;
case(osgDB::ImageOptions::PIXEL_WINDOW):
@@ -426,30 +437,30 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
// windowWidth = destWidth;
// windowHeight = destHeight;
std::cout << " windowX = "<<windowX<<std::endl;
std::cout << " windowY = "<<windowY<<std::endl;
std::cout << " windowWidth = "<<windowWidth<<std::endl;
std::cout << " windowHeight = "<<windowHeight<<std::endl;
osg::notify(osg::INFO) << " windowX = "<<windowX<<std::endl;
osg::notify(osg::INFO) << " windowY = "<<windowY<<std::endl;
osg::notify(osg::INFO) << " windowWidth = "<<windowWidth<<std::endl;
osg::notify(osg::INFO) << " windowHeight = "<<windowHeight<<std::endl;
std::cout << std::endl;
osg::notify(osg::INFO) << std::endl;
std::cout << " destX = "<<destX<<std::endl;
std::cout << " destY = "<<destY<<std::endl;
std::cout << " destWidth = "<<destWidth<<std::endl;
std::cout << " destHeight = "<<destHeight<<std::endl;
osg::notify(osg::INFO) << " destX = "<<destX<<std::endl;
osg::notify(osg::INFO) << " destY = "<<destY<<std::endl;
osg::notify(osg::INFO) << " destWidth = "<<destWidth<<std::endl;
osg::notify(osg::INFO) << " destHeight = "<<destHeight<<std::endl;
std::cout << std::endl;
osg::notify(osg::INFO) << std::endl;
std::cout << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
std::cout << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
osg::notify(osg::INFO) << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
osg::notify(osg::INFO) << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
double geoTransform[6];
std::cout << " GetGeoTransform == "<< dataset->GetGeoTransform(geoTransform)<<" == CE_None"<<std::endl;
std::cout << " GetGeoTransform "<< std::endl;
std::cout << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
std::cout << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
std::cout << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
osg::notify(osg::INFO) << " GetGeoTransform == "<< dataset->GetGeoTransform(geoTransform)<<" == CE_None"<<std::endl;
osg::notify(osg::INFO) << " GetGeoTransform "<< std::endl;
osg::notify(osg::INFO) << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
osg::notify(osg::INFO) << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
osg::notify(osg::INFO) << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
double TopLeft[2],BottomLeft[2],BottomRight[2],TopRight[2];
@@ -463,12 +474,12 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
TopRight[1] = TopLeft[1]+geoTransform[4]*(dataWidth-1);
std::cout << "TopLeft "<<TopLeft[0]<<"\t"<<TopLeft[1]<<std::endl;
std::cout << "BottomLeft "<<BottomLeft[0]<<"\t"<<BottomLeft[1]<<std::endl;
std::cout << "BottomRight "<<BottomRight[0]<<"\t"<<BottomRight[1]<<std::endl;
std::cout << "TopRight "<<TopRight[0]<<"\t"<<TopRight[1]<<std::endl;
osg::notify(osg::INFO) << "TopLeft "<<TopLeft[0]<<"\t"<<TopLeft[1]<<std::endl;
osg::notify(osg::INFO) << "BottomLeft "<<BottomLeft[0]<<"\t"<<BottomLeft[1]<<std::endl;
osg::notify(osg::INFO) << "BottomRight "<<BottomRight[0]<<"\t"<<BottomRight[1]<<std::endl;
osg::notify(osg::INFO) << "TopRight "<<TopRight[0]<<"\t"<<TopRight[1]<<std::endl;
std::cout<<" GDALGetGCPCount "<<dataset->GetGCPCount()<<std::endl;
osg::notify(osg::INFO)<<" GDALGetGCPCount "<<dataset->GetGCPCount()<<std::endl;
int numBands = dataset->GetRasterCount();
@@ -484,21 +495,21 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
GDALRasterBand* band = dataset->GetRasterBand(b);
std::cout << " Band "<<b<<std::endl;
osg::notify(osg::INFO) << " Band "<<b<<std::endl;
std::cout << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
std::cout << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
std::cout << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
std::cout << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
osg::notify(osg::INFO) << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
osg::notify(osg::INFO) << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
osg::notify(osg::INFO) << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
osg::notify(osg::INFO) << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
std::cout << std::endl;
std::cout << " GetNoDataValue() = "<< band->GetNoDataValue()<<std::endl;
std::cout << " GetMinimum() = "<< band->GetMinimum()<<std::endl;
std::cout << " GetMaximum() = "<< band->GetMaximum()<<std::endl;
std::cout << " GetOffset() = "<< band->GetOffset()<<std::endl;
std::cout << " GetScale() = "<< band->GetScale()<<std::endl;
std::cout << " GetUnitType() = '"<< band->GetUnitType()<<"'"<<std::endl;
osg::notify(osg::INFO) << std::endl;
osg::notify(osg::INFO) << " GetNoDataValue() = "<< band->GetNoDataValue()<<std::endl;
osg::notify(osg::INFO) << " GetMinimum() = "<< band->GetMinimum()<<std::endl;
osg::notify(osg::INFO) << " GetMaximum() = "<< band->GetMaximum()<<std::endl;
osg::notify(osg::INFO) << " GetOffset() = "<< band->GetOffset()<<std::endl;
osg::notify(osg::INFO) << " GetScale() = "<< band->GetScale()<<std::endl;
osg::notify(osg::INFO) << " GetUnitType() = '"<< band->GetUnitType()<<"'"<<std::endl;
if (band->GetColorInterpretation()==GCI_GrayIndex) bandGray = band;
@@ -515,12 +526,12 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
// minmax[1] = band->GetMaximum(&gotMax);
// if (!(gotMin && gotMax))
// {
// std::cout<<" computing min max"<<std::endl;
// osg::notify(osg::INFO)<<" computing min max"<<std::endl;
// GDALComputeRasterMinMax(band,TRUE,minmax);
// }
//
// std::cout << " min "<<minmax[0]<<std::endl;
// std::cout << " max "<<minmax[1]<<std::endl;
// osg::notify(osg::INFO) << " min "<<minmax[0]<<std::endl;
// osg::notify(osg::INFO) << " max "<<minmax[1]<<std::endl;
}
@@ -553,7 +564,7 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
// }
// now need to flip since the OSG's origin is in lower left corner.
std::cout<<"flipping"<<std::endl;
osg::notify(osg::INFO)<<"flipping"<<std::endl;
unsigned int copy_r = hf->getNumRows()-1;
for(unsigned int r=0;r<copy_r;++r,--copy_r)
{

View File

@@ -32,6 +32,7 @@
#include <osgSim/LightPointNode>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
@@ -399,11 +400,14 @@ 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& fileName, const Options*)
virtual ReadResult readNode(const std::string& file, const Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream fin(fileName.c_str(), std::ios::binary | std::ios::in );
if (fin.is_open() )
{ // read the input file.

View File

@@ -4,6 +4,7 @@
#include <osg/GL>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
@@ -323,12 +324,14 @@ class ReaderWriterGIF : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"gif");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;
int height_ret;

View File

@@ -4,6 +4,7 @@
#include <osg/Notify>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
using namespace osg;
@@ -19,10 +20,13 @@ class IVEReaderWriter : public ReaderWriter
return equalCaseInsensitive(extension,"ive");
}
virtual ReadResult readNode(const std::string& fileName, const Options* options)
virtual ReadResult readNode(const std::string& file, const Options* options)
{
std::string ext = getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
return readNode(istream,options);

View File

@@ -178,13 +178,16 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension,"jpc");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
if(!osgDB::fileExists(fileName))
std::string fileName = osgDB::findDataFile( file );
if(fileName.empty())
{
// note from Robert, Dec03, I find returning a valid image when no
// file exists a bit odd...
osg::Image *img = new osg::Image;
img->setFileName(fileName);
return img;

View File

@@ -5,6 +5,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
/****************************************************************************
*
@@ -279,11 +280,14 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"jpeg") || osgDB::equalCaseInsensitive(extension,"jpg");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;
int height_ret;

View File

@@ -86,7 +86,7 @@ class ReaderWriter3DS : public osgDB::ReaderWriter
virtual const char* className() { return "3DS Auto Studio Reader"; }
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"3ds"); }
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*);
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*);
typedef std::vector<int> FaceList;
typedef std::map<std::string,osg::StateSet*> GeoStateMap;
@@ -394,9 +394,15 @@ osg::Node* ReaderWriter3DS::processNode(StateSetMap drawStateMap,Lib3dsFile *f,L
}
osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
osgDB::ReaderWriter::ReadResult ReaderWriter3DS::readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
Lib3dsFile *f = lib3ds_file_load(fileName.c_str());
if (f==NULL) return ReadResult::FILE_NOT_HANDLED;

View File

@@ -191,10 +191,14 @@ public:
return osgDB::equalCaseInsensitive(extension,"logo");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO)<< "ReaderWriterLOGO::readNode( "<<fileName.c_str()<<" )\n";
osg::Geode *geode = new osg::Geode;

View File

@@ -29,6 +29,7 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgUtil/SmoothingVisitor>
#include <osgUtil/Tesselator>
@@ -46,8 +47,14 @@ public:
return osgDB::equalCaseInsensitive(extension,"lwo") || osgDB::equalCaseInsensitive(extension,"lw") || osgDB::equalCaseInsensitive(extension,"geo");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* 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 );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
ReadResult result = readNode_LWO1(fileName,options);
if (result.success()) return result;

View File

@@ -23,6 +23,7 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <string.h>
#include <fcntl.h>
@@ -59,9 +60,15 @@ public:
osgDB::RegisterReaderWriterProxy<ReaderWriterMD2> g_readerWriter_MD2_Proxy;
osgDB::ReaderWriter::ReadResult
ReaderWriterMD2::readNode (const std::string& filename,
ReaderWriterMD2::readNode (const std::string& file,
const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string filename = osgDB::findDataFile( file );
if (filename.empty()) return ReadResult::FILE_NOT_FOUND;
return load_md2 (filename.data());
}

View File

@@ -152,11 +152,13 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterOBJ> g_objReaderWriterProxy;
// read file and convert to OSG.
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
GLMmodel* obj = glmReadOBJ((char*) fileName.c_str());
if (!obj)

View File

@@ -1,10 +1,11 @@
#include "osg/Image"
#include "osg/Group"
#include <osg/Image>
#include <osg/Group>
#include "osgDB/FileNameUtils"
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
using namespace osg;
using namespace osgDB;
@@ -21,11 +22,14 @@ class OSGReaderWriter : public ReaderWriter
virtual ReadResult readObject(const std::string& fileName, const Options* opt) { return readNode(fileName,opt); }
virtual ReadResult readNode(const std::string& fileName, const Options* opt)
virtual ReadResult readNode(const std::string& file, const Options* opt)
{
std::string ext = getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream fin(fileName.c_str());
if (fin)
{

View File

@@ -30,11 +30,14 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"osgtgz");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO)<<"sgReaderWriterOSGTGZ::readNode( "<<fileName.c_str()<<" )\n";
char dirname[128];

View File

@@ -94,8 +94,11 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
false;
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) fileName = file; // let Peformer see if it can file the filep
osg::notify(osg::INFO)<<"ReaderWriterPFB::readImage( "<<fileName.c_str()<<" )\n";
initPerformer();
@@ -146,11 +149,14 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
return ReadResult::FILE_NOT_HANDLED;
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO)<<"ReaderWriterPFB::readNode( "<<fileName.c_str()<<" )\n";
initPerformer();

View File

@@ -5,6 +5,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
/****************************************************************************
*
@@ -193,8 +194,13 @@ class ReaderWriterPIC : public osgDB::ReaderWriter
virtual const char* className() { return "PIC Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"pic"); }
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;

View File

@@ -5,6 +5,7 @@
#include <osg/Endian>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
using namespace osg;
@@ -35,11 +36,13 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
virtual const char* className() { return "PNG Image Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"png"); }
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
if( !acceptsExtension(osgDB::getFileExtension(fileName) ))
return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
int trans = PNG_ALPHA;
FILE *fp = NULL;

View File

@@ -6,6 +6,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <stdio.h>
@@ -24,10 +25,13 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension, "pbm");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
if( !acceptsExtension(osgDB::getFileExtension(fileName) ))
return ReadResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
FILE *fp = NULL;
char line[300];

View File

@@ -28,7 +28,7 @@ class ReaderWriterQT : public osgDB::ReaderWriter
virtual bool acceptsExtension(const std::string& extension)
{
// this should be the only image importer required on the Mac
// dont know what else it supports, but these will do
// dont know what else it supports, but these will do
return osgDB::equalCaseInsensitive(extension,"rgb") ||
osgDB::equalCaseInsensitive(extension,"rgba") ||
osgDB::equalCaseInsensitive(extension,"jpg") ||
@@ -43,110 +43,113 @@ class ReaderWriterQT : public osgDB::ReaderWriter
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
long origWidth, origHeight,buffWidth,buffHeight,buffDepth,origDepth;
// NOTE - implememntation means that this will always return 32 bits, so it is hard to work out if
// an image was monochrome. So it will waste texture memory unless it gets a monochrome hint.
unsigned char *pixels = LoadBufferFromDarwinPath ( fileName.c_str(), &origWidth,&origHeight,&origDepth,
&buffWidth,&buffHeight,
&buffDepth);
// IMPORTANT -
// origDepth in BYTES, buffDepth in BITS
if (pixels == 0) {
std::cerr << "LoadBufferFromDarwinPath failed " << fileName.c_str() << QTfailureMessage() << std::endl;
return 0;
}
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
long origWidth, origHeight,buffWidth,buffHeight,buffDepth,origDepth;
// NOTE - implememntation means that this will always return 32 bits, so it is hard to work out if
// an image was monochrome. So it will waste texture memory unless it gets a monochrome hint.
unsigned int pixelFormat;
switch(origDepth) {
case 1 :
pixelFormat = GL_RGB;
break;
case 2 :
pixelFormat = GL_LUMINANCE_ALPHA;
break;
case 3 :
pixelFormat = GL_RGB;
break;
case 4 :
pixelFormat = GL_RGBA;
break;
default :
std::cerr << "Unknown file type in " << fileName.c_str() << " with " << origDepth << std::endl;
pixelFormat = (GLenum)-1;
return 0;
break;
}
{
unsigned char *srcp=pixels, *dstp=pixels;
unsigned char *pixels = LoadBufferFromDarwinPath ( fileName.c_str(), &origWidth,&origHeight,&origDepth,
&buffWidth,&buffHeight,
&buffDepth);
// IMPORTANT -
// origDepth in BYTES, buffDepth in BITS
if (pixels == 0) {
std::cerr << "LoadBufferFromDarwinPath failed " << fileName.c_str() << QTfailureMessage() << std::endl;
return 0;
}
unsigned int pixelFormat;
switch(origDepth) {
case 1 :
pixelFormat = GL_RGB;
break;
case 2 :
pixelFormat = GL_LUMINANCE_ALPHA;
break;
case 3 :
pixelFormat = GL_RGB;
break;
case 4 :
pixelFormat = GL_RGBA;
break;
default :
std::cerr << "Unknown file type in " << fileName.c_str() << " with " << origDepth << std::endl;
pixelFormat = (GLenum)-1;
return 0;
break;
}
{
unsigned char *srcp=pixels, *dstp=pixels;
int i, j;
int i, j;
// swizzle entire image in-place
for (i=0; i<buffHeight; i++ ) {
unsigned char r, g, b, a;
switch (origDepth) {
/*
since 8-bit tgas will get expanded into colour, have to use RGB code for 8-bit images
case 1 :
for (j=0; j<buffWidth; j++ ) {
dstp[0]=srcp[2];
srcp+=4;
dstp++;
}
break;
*/
case 2 :
for (j=0; j<buffWidth; j++ ) {
dstp[1]=srcp[0];
dstp[0]=srcp[2];
srcp+=4;
dstp+=2;
}
break;
case 1 :
case 3 :
for (j=0; j<buffWidth; j++ ) {
dstp[0]=srcp[1];
dstp[1]=srcp[2];
dstp[2]=srcp[3];
srcp+=4;
dstp+=3;
}
break;
case 4 :
for (j=0; j<buffWidth; j++ ) {
r=srcp[1];
g=srcp[2];
b=srcp[3];
a=srcp[0];
dstp[0]=r;
dstp[1]=g;
dstp[2]=b;
dstp[3]=a;
srcp+=4;
dstp+=4;
}
break;
default :
// std::cerr << "ERROR IN RETURNED PIXEL DEPTH, CANNOT COPE" << std::endl;
return 0;
break;
}
}
}
// swizzle entire image in-place
for (i=0; i<buffHeight; i++ ) {
unsigned char r, g, b, a;
switch (origDepth) {
/*
since 8-bit tgas will get expanded into colour, have to use RGB code for 8-bit images
case 1 :
for (j=0; j<buffWidth; j++ ) {
dstp[0]=srcp[2];
srcp+=4;
dstp++;
}
break;
*/
case 2 :
for (j=0; j<buffWidth; j++ ) {
dstp[1]=srcp[0];
dstp[0]=srcp[2];
srcp+=4;
dstp+=2;
}
break;
case 1 :
case 3 :
for (j=0; j<buffWidth; j++ ) {
dstp[0]=srcp[1];
dstp[1]=srcp[2];
dstp[2]=srcp[3];
srcp+=4;
dstp+=3;
}
break;
case 4 :
for (j=0; j<buffWidth; j++ ) {
r=srcp[1];
g=srcp[2];
b=srcp[3];
a=srcp[0];
dstp[0]=r;
dstp[1]=g;
dstp[2]=b;
dstp[3]=a;
srcp+=4;
dstp+=4;
}
break;
default :
// std::cerr << "ERROR IN RETURNED PIXEL DEPTH, CANNOT COPE" << std::endl;
return 0;
break;
}
}
}
Image* image = new Image();
image->setFileName(fileName.c_str());
@@ -155,8 +158,8 @@ class ReaderWriterQT : public osgDB::ReaderWriter
pixelFormat,
GL_UNSIGNED_BYTE,
pixels,
osg::Image::USE_NEW_DELETE );
osg::Image::USE_NEW_DELETE );
notify(INFO) << "image read ok "<<buffWidth<<" "<<buffHeight<<std::endl;
return image;
}

View File

@@ -1,12 +1,13 @@
#include "osg/Image"
#include "osg/Notify"
#include <osg/Image>
#include <osg/Notify>
#include <osg/Geode>
#include "osg/GL"
#include <osg/GL>
#include "osgDB/FileNameUtils"
#include "osgDB/Registry"
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <stdio.h>
#include <stdlib.h>
@@ -354,10 +355,13 @@ class ReaderWriterRGB : public osgDB::ReaderWriter
osgDB::equalCaseInsensitive(extension,"bw");
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
rawImageRec *raw;

View File

@@ -5,6 +5,7 @@
#include <osgDB/Registry>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <stdio.h>
#include <assert.h>
@@ -477,8 +478,13 @@ class ReaderWriterTGA : public osgDB::ReaderWriter
virtual const char* className() { return "TGA Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) { return osgDB::equalCaseInsensitive(extension,"tga"); }
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;

View File

@@ -31,11 +31,14 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"tgz");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO)<< "ReaderWriterTGZ::readNode( "<<fileName.c_str()<<" )\n";
char dirname[128];

View File

@@ -6,6 +6,7 @@
#include <osg/GL>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <stdio.h>
@@ -411,8 +412,14 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
return false;
}
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
unsigned char *imageData = NULL;
int width_ret;
int height_ret;

View File

@@ -21,7 +21,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::readNode(const std::string& fil
if( !acceptsExtension(osgDB::getFileExtension(fileName) ))
return ReadResult::FILE_NOT_HANDLED;
osg::ref_ptr<txp::TerrapageNode> pager = new TerrapageNode;
osg::ref_ptr<txp::TerrapageNode> pager = new TerrapageNode;
pager->setDatabaseName(fileName);

View File

@@ -29,12 +29,15 @@ class ReaderWriterZIP : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension,"zip");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options*)
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::notify(osg::INFO)<<"ReaderWriterZIP::readNode( "<<fileName.c_str()<<" )\n";
char dirname[128];

View File

@@ -900,7 +900,7 @@ bool Optimizer::CombineStaticTransformsVisitor::removeTransforms(osg::Node* node
if (itr!=_transformSet.end()) _transformSet.erase(itr);
}
std::cout<<"Have found "<<_transformSet.size()<<" static Transform pairs to flatten"<<std::endl;
osg::notify(osg::INFO)<<"Have found "<<_transformSet.size()<<" static Transform pairs to flatten"<<std::endl;
bool transformRemoved = false;

View File

@@ -502,33 +502,6 @@ public:
};
// triangle functor.
struct TriangleAcumulatorFunctor
{
triangle_stripper::tri_stripper::indices in_indices;
const Vec3* _vbase;
TriangleAcumulatorFunctor() : _vbase(0) {}
void setCoords( const Vec3* vbase ) { _vbase = vbase; std::cout<<"set coords"<<std::endl;}
inline void operator() ( const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, bool treatVertexDataAsTemporary )
{
if (!treatVertexDataAsTemporary)
{
int p1 = (int)(&v1-_vbase);
int p2 = (int)(&v2-_vbase);
int p3 = (int)(&v3-_vbase);
if (p1==p2 || p1==p3 || p2==p3) return;
in_indices.push_back(p1);
in_indices.push_back(p2);
in_indices.push_back(p3);
}
}
};
void TriStripVisitor::stripify(Geometry& geom)
{
@@ -545,6 +518,11 @@ void TriStripVisitor::stripify(Geometry& geom)
if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
// no point tri stripping if we don't have enough vertices.
if (geom.getVertexArray()->getNumElements()<3) return;
// check to see if vertex attributes indices exists, if so expand them to remove them
if (geom.suitableForOptimization())
{
// removing coord indices
@@ -553,9 +531,10 @@ void TriStripVisitor::stripify(Geometry& geom)
}
// check for the existance of surface primitives
unsigned int numSurfacePrimitives = 0;
unsigned int numNonSurfacePrimitives = 0;
Geometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
Geometry::PrimitiveSetList::iterator itr;
for(itr=primitives.begin();
@@ -579,6 +558,7 @@ void TriStripVisitor::stripify(Geometry& geom)
}
}
// nothitng to tri strip leave.
if (!numSurfacePrimitives) return;
// compute duplicate vertices
@@ -673,17 +653,8 @@ void TriStripVisitor::stripify(Geometry& geom)
}
}
for(i=0;i<finalMapping.size();++i)
{
//std::cout<<" finalMapping["<<i<<"] = "<<finalMapping[i]<<std::endl;
}
RemapArray ra(copyMapping);
arrayComparitor.accept(ra);
TriangleIndexFunctor taf;
//taf._remapIndices.swap(remapDuplicatesToOrignals);
taf._remapIndices.swap(finalMapping);
Geometry::PrimitiveSetList new_primitives;
@@ -710,18 +681,31 @@ void TriStripVisitor::stripify(Geometry& geom)
}
}
if (!taf._in_indices.empty())
float minimum_ratio_of_indices_to_unique_vertices = 2.0;
float ratio_of_indices_to_unique_vertices = ((float)taf._in_indices.size()/(float)numUnique);
std::cout<<"Number of indices"<<taf._in_indices.size()<<" numUnique"<< numUnique << std::endl;
std::cout<<" ratio indices/numUnique"<< ratio_of_indices_to_unique_vertices << std::endl;
// only tri strip if there is point in doing so.
if (!taf._in_indices.empty() && ratio_of_indices_to_unique_vertices>=minimum_ratio_of_indices_to_unique_vertices)
{
int in_numVertices = -1;
std::cout<<" doing tri strip"<< std::endl;
unsigned int in_numVertices = 0;
for(triangle_stripper::tri_stripper::indices::iterator itr=taf._in_indices.begin();
itr!=taf._in_indices.end();
++itr)
{
if ((int)*itr>in_numVertices) in_numVertices=*itr;
if (*itr>in_numVertices) in_numVertices=*itr;
}
// the largest indice is in_numVertices, but indices start at 0
// so increment to give to the corrent number of verticies.
++in_numVertices;
++in_numVertices;
// remap any shared vertex attributes
RemapArray ra(copyMapping);
arrayComparitor.accept(ra);
triangle_stripper::tri_stripper stripifier(taf._in_indices);
stripifier.SetCacheSize(_cacheSize);
@@ -760,20 +744,28 @@ void TriStripVisitor::stripify(Geometry& geom)
}
geom.setPrimitiveSetList(new_primitives);
#if 0
// debugging code for indentifying the tri-strips.
osg::Vec4Array* colors = new osg::Vec4Array(new_primitives.size());
for(i=0;i<colors->size();++i)
{
(*colors)[i].set(((float)rand()/(float)RAND_MAX),
((float)rand()/(float)RAND_MAX),
((float)rand()/(float)RAND_MAX),
1.0f);
}
geom.setColorArray(colors);
geom.setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
#endif
#if 0
// debugging code for indentifying the tri-strips.
osg::Vec4Array* colors = new osg::Vec4Array(new_primitives.size());
for(i=0;i<colors->size();++i)
{
(*colors)[i].set(((float)rand()/(float)RAND_MAX),
((float)rand()/(float)RAND_MAX),
((float)rand()/(float)RAND_MAX),
1.0f);
}
geom.setColorArray(colors);
geom.setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
#endif
geom.setPrimitiveSetList(new_primitives);
}
else
{
std::cout<<" not doing tri strip *****************"<< std::endl;
}
}
void TriStripVisitor::stripify()