Converted plugins to use the new supportsExtension()/supportsOptions/supportsProtocl() methods

to help enable better querying of supported features
This commit is contained in:
Robert Osfield 2008-07-13 22:18:59 +00:00
parent cb98cddc31
commit 02b456bcfa
54 changed files with 421 additions and 323 deletions

View File

@ -37,8 +37,12 @@ ReaderWriter::~ReaderWriter()
bool ReaderWriter::acceptsExtension(const std::string& extension) const
{
// check for an exact match
std::string lowercase_ext = convertToLowerCase(extension);
return (_supportedExtensions.count(lowercase_ext)!=0);
if (_supportedExtensions.count(lowercase_ext)!=0) return true;
// if plugin supports wildcard extension then passthrough all types
return (_supportedExtensions.count("*")!=0);
}
void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description)

View File

@ -15,14 +15,15 @@ using namespace osg;
class ReaderWriter3DC : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "3DC point cloud reader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriter3DC()
{
return osgDB::equalCaseInsensitive(extension,"3dc") ||
osgDB::equalCaseInsensitive(extension,"asc");
supportsExtension("3dc","3DC point cloud format");
supportsExtension("asc","3DC point cloud format");
}
virtual const char* className() const { return "3DC point cloud reader"; }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);

View File

@ -91,7 +91,6 @@ class ReaderWriter3DS : public osgDB::ReaderWriter
ReaderWriter3DS();
virtual const char* className() const { return "3DS Auto Studio Reader"; }
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"3ds"); }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const;
@ -127,6 +126,8 @@ REGISTER_OSGPLUGIN(3ds, ReaderWriter3DS)
ReaderWriter3DS::ReaderWriter3DS()
{
supportsExtension("3ds","3D Studio model format");
setByteOrder();
#if 0

View File

@ -27,6 +27,8 @@ REGISTER_OSGPLUGIN(Inventor, ReaderWriterIV)
ReaderWriterIV::ReaderWriterIV()
{
supportsExtension("iv","Inventor format");
supportsExtension("wrl","VRML world file");
}
// Read file and convert to OSG

View File

@ -19,12 +19,6 @@ class ReaderWriterIV : public osgDB::ReaderWriter
return osgDB::equalCaseInsensitive(extension, "iv") ? true : false;
}
virtual bool acceptsExtension(const std::string& extension) const
{
return isInventorExtension(extension) ? true :
osgDB::equalCaseInsensitive(extension, "wrl") ? true : false;
}
virtual ReadResult readNode(const std::string& filename,
const osgDB::ReaderWriter::Options *) const;

View File

@ -40,6 +40,11 @@ class ReaderWriterATTR : public osgDB::ReaderWriter
{
public:
ReaderWriterATTR()
{
supportsExtension("attr","OpenFlight texture attribute format");
}
virtual const char* className() const { return "ATTR Image Attribute Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const

View File

@ -120,7 +120,24 @@ class FLTReaderWriter : public ReaderWriter
public:
FLTReaderWriter()
: _implicitPath( "." )
{}
{
supportsExtension("flt","OpenFlight format");
supportsOption("clampToEdge","");
supportsOption("keepExternalReferences","");
supportsOption("preserveFace","");
supportsOption("preserveObject","");
supportsOption("dofAnimation","");
supportsOption("billboardCenter","");
supportsOption("noTextureAlphaForTransparancyBinning","");
supportsOption("readObjectRecordData","");
supportsOption("noUnitsConversion","");
supportsOption("convertToFeet","");
supportsOption("convertToInches","");
supportsOption("convertToMeters","");
supportsOption("convertToKilometers","");
supportsOption("convertToNauticalMiles","");
}
virtual const char* className() const { return "FLT Reader/Writer"; }

View File

@ -315,8 +315,13 @@ int *numComponents_ret)
class ReaderWriterBMP : public osgDB::ReaderWriter
{
public:
ReaderWriterBMP()
{
supportsExtension("bmp","BMP Image format");
}
virtual const char* className() const { return "BMP Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"bmp"); }
ReadResult readBMPStream(std::istream& fin) const
{

View File

@ -22,18 +22,16 @@
class ReaderWriterQ3BSP: public osgDB::ReaderWriter
{
public:
ReaderWriterQ3BSP() { }
ReaderWriterQ3BSP()
{
supportsExtension("bsp","Quake3 BSP model format");
}
virtual const char* className() const
{
return "Quake3 BSP Reader";
}
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"bsp");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const;
private:

View File

@ -189,12 +189,13 @@ class ReaderWriterProducerCFG : public osgDB::ReaderWriter
{
public:
ReaderWriterProducerCFG()
{
supportsExtension("cfg","Producer camera configuration file");
}
virtual const char* className() { return "Producer cfg object reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension, "cfg");
}
virtual ReadResult readObject(const std::string& fileName, const Options* options = NULL) const
{

View File

@ -144,6 +144,7 @@ ReaderWriterCURL::ReaderWriterCURL()
{
supportsProtocol("http","Read from http port using libcurl.");
supportsExtension("curl","Psuedo file extension, used to select curl plugin.");
supportsExtension("*","Passes all read files to other plugins to handle actual model loading.");
supportsOption("OSG_CURL_PROXY","Specify the http proxy.");
supportsOption("OSG_CURL_PROXYPORT","Specify the http proxy oirt.");
}

View File

@ -15,15 +15,11 @@ class ReaderWriterDAE : public osgDB::ReaderWriter
public:
ReaderWriterDAE()
{
supportsExtension(EXTENSION_NAME,"COLLADA 1.4.x DAE format");
}
const char* className() const { return "COLLADA 1.4.x DAE reader/writer"; }
bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
ReadResult readNode(const std::string&, const Options*) const;
WriteResult writeNode(const osg::Node&, const std::string&, const Options*) const;

View File

@ -918,16 +918,17 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout)
class ReaderWriterDDS : public osgDB::ReaderWriter
{
public:
ReaderWriterDDS()
{
supportsExtension("dds","DDS image format");
}
virtual const char* className() const
{
return "DDS Image Reader/Writer";
}
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"dds");
}
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
return readImage(file,options);

View File

@ -792,13 +792,14 @@ void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *optio
class ReaderWriterDW : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "Design Workshop Database Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterDW()
{
return osgDB::equalCaseInsensitive(extension,"dw");
supportsExtension("dw","Designer Workbench model format");
}
virtual const char* className() const { return "Design Workshop Database Reader"; }
virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options* options) const
{

View File

@ -30,11 +30,12 @@ using namespace std;
class ReaderWriterdxf : public osgDB::ReaderWriter
{
public:
ReaderWriterdxf() { }
virtual const char* className() { return "Autodesk DXF Reader"; }
virtual bool acceptsExtension(const std::string& extension) const {
return osgDB::equalCaseInsensitive(extension,"dxf");
ReaderWriterdxf()
{
supportsExtension("dxf","Autodesk DXF format");
}
virtual const char* className() { return "Autodesk DXF Reader"; }
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const;
protected:
};

View File

@ -48,12 +48,14 @@ float Hue_2_RGB( float v1, float v2, float vH )
class ReaderWriterGDAL : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "GDAL Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterGDAL()
{
return osgDB::equalCaseInsensitive(extension,"gdal") || osgDB::equalCaseInsensitive(extension,"gdal");
supportsExtension("gdal","GDAL Image reader");
}
virtual const char* className() const { return "GDAL Image Reader"; }
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"gdal"))

View File

@ -2202,6 +2202,13 @@ void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a rec
class ReaderWriterGEO : public osgDB::ReaderWriter
{
public:
ReaderWriterGEO()
{
supportsExtension("gem","CarbonGraphics Geo model format");
supportsExtension("geo","CarbonGraphics Geo model format");
}
virtual const char* className() const { return "GEO Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const

View File

@ -67,7 +67,10 @@ public:
GifImageStream()
: _length(0), _dataNum(0), _frameNum(0),
_done(false), _currentLength(0), _multiplier(1.0),
osg::ImageStream() { _status=PAUSED; }
osg::ImageStream()
{
_status=PAUSED;
}
virtual Object* clone() const { return new GifImageStream; }
virtual bool isSameKindAs( const Object* obj ) const
{ return dynamic_cast<const GifImageStream*>(obj) != NULL; }
@ -559,12 +562,14 @@ GifImageStream** obj)
class ReaderWriterGIF : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "GIF Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterGIF()
{
return osgDB::equalCaseInsensitive(extension,"gif");
supportsExtension("gif","GIF Image format");
}
virtual const char* className() const { return "GIF Image Reader"; }
ReadResult readGIFStream(std::istream& fin) const
{
unsigned char *imageData = NULL;

View File

@ -10,6 +10,13 @@
class ReaderWriterGLSL : public osgDB::ReaderWriter
{
public:
ReaderWriterGLSL()
{
supportsExtension("gl","OpenGL Shader Language format");
supportsExtension("glsl","OpenGL Shader Language format");
}
virtual const char* className() const { return "GLSL Shader Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{

View File

@ -47,8 +47,16 @@
class ReaderWriterHDR : public osgDB::ReaderWriter
{
public:
ReaderWriterHDR()
{
supportsExtension("hdr","High Dynamic Range image format");
supportsOption("RGBMUL","");
supportsOption("RGB8","");
supportsOption("RAW","");
supportsOption("YFLIP","");
supportsOption("NO_YFLIP","");
}
virtual const char* className() { return "HDR Image Reader"; }
virtual bool acceptsExtension(const std::string &extension) const { return osgDB::equalCaseInsensitive(extension, "hdr"); }
virtual ReadResult readImage(const std::string &_file, const osgDB::ReaderWriter::Options *_opts) const
{

View File

@ -174,6 +174,9 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter
ReaderWriterJP2()
{
supportsExtension("jp2","Jpeg2000 image format");
supportsExtension("jpc","Jpeg2000 image format");
// little dance here to get around warnings created by jas_image_strtofmt use of char* rather than const char*
// as a parameted and modern compilers deprecating "jp2" string being treated as char*.
char* jp2 = strdup("jp2");
@ -183,12 +186,6 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter
virtual const char* className() const { return "RGB Image Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"jp2") ||
osgDB::equalCaseInsensitive(extension,"jpc");
}
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
return readImage(file,options);

View File

@ -612,6 +612,7 @@ int *numComponents_ret)
class ReaderWriterJPEG : public osgDB::ReaderWriter
{
WriteResult::WriteStatus write_JPEG_file (std::ostream &fout,int image_width,int image_height,JSAMPLE* image_buffer,int quality = 100) const
{
if ( (image_width == 0) || (image_height == 0) )
@ -740,12 +741,15 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
return 100;
}
public:
virtual const char* className() const { return "JPEG Image Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterJPEG()
{
return osgDB::equalCaseInsensitive(extension,"jpeg") || osgDB::equalCaseInsensitive(extension,"jpg");
supportsExtension("jpeg","JPEG image format");
supportsExtension("jpg","JPEG image format");
}
virtual const char* className() const { return "JPEG Image Reader/Writer"; }
ReadResult readJPGStream(std::istream& fin) const
{
unsigned char *imageData = NULL;

View File

@ -195,13 +195,13 @@ class Logos: public osg::Drawable
class LOGOReaderWriter : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "Logo Database Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
LOGOReaderWriter()
{
return osgDB::equalCaseInsensitive(extension,"logo");
supportsExtension("logo","Ascii logo placement format");
}
virtual const char* className() const { return "Logo Database Reader/Writer"; }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);

View File

@ -46,12 +46,14 @@
class ReaderWriterLWO : public osgDB::ReaderWriter
{
public:
ReaderWriterLWO() { }
ReaderWriterLWO()
{
supportsExtension("lwo","Lightwave object format");
supportsExtension("lw","Lightwave object format");
supportsExtension("geo","Lightwave geometry format");
}
virtual const char* className() const { return "Lightwave Object Reader"; }
virtual bool acceptsExtension(const std::string& extension) const {
return osgDB::equalCaseInsensitive(extension,"lwo") || osgDB::equalCaseInsensitive(extension,"lw") || osgDB::equalCaseInsensitive(extension,"geo");
}
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{

View File

@ -23,7 +23,10 @@
class ReaderWriterLWS : public osgDB::ReaderWriter
{
public:
ReaderWriterLWS() {}
ReaderWriterLWS()
{
supportsExtension("lws","Lightwave scene format");
}
virtual const char* className() const { return "ReaderWriterLWS"; }

View File

@ -43,16 +43,15 @@ static osg::Node* load_md2 (const char *filename, const osgDB::ReaderWriter::Opt
class ReaderWriterMD2 : public osgDB::ReaderWriter
{
public:
ReaderWriterMD2 () { }
ReaderWriterMD2 ()
{
supportsExtension("md2","Quak2 MD format");
}
virtual const char* className () const {
return "Quake MD2 Reader";
}
virtual bool acceptsExtension (const std::string& extension) const {
return osgDB::equalCaseInsensitive (extension, "md2") ? true : false;
}
virtual ReadResult readNode (const std::string& filename, const osgDB::ReaderWriter::Options* options) const;
};

View File

@ -86,7 +86,12 @@
class NetReader : public osgDB::ReaderWriter
{
public:
NetReader() {}
NetReader()
{
supportsProtocol("http","HTTP Protocol");
supportsExtension("net","Psuedo loader extension for selecting NET plugin");
supportsExtension("*","Passes all file loading onto other plugins");
}
virtual const char* className() const { return "HTTP Protocol Model Reader"; }

View File

@ -13,7 +13,10 @@
class NormalsReader: public osgDB::ReaderWriter
{
public:
NormalsReader() {}
NormalsReader()
{
supportsExtension("normals","Normals Pseudo loader");
}
virtual const char* className() { return "Normals Pseudo Loader"; }

View File

@ -52,12 +52,12 @@
class ReaderWriterOBJ : public osgDB::ReaderWriter
{
public:
ReaderWriterOBJ():_fixBlackMaterials(true) {}
ReaderWriterOBJ():_fixBlackMaterials(true)
{
supportsExtension("obj","Alias Wavefront OBJ format");
}
virtual const char* className() const { return "Wavefront OBJ Reader"; }
virtual bool acceptsExtension(const std::string& extension) const {
return osgDB::equalCaseInsensitive(extension,"obj");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const;

View File

@ -81,13 +81,11 @@ class ReaderWriterOGR : public osgDB::ReaderWriter
{
public:
ReaderWriterOGR() {}
virtual const char* className() const { return "OGR file reader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterOGR()
{
return osgDB::equalCaseInsensitive(extension,"ogr") ||
osgDB::equalCaseInsensitive(extension,"ogr");
supportsExtension("ogr","OGR file reader");
}
virtual const char* className() const { return "OGR file reader"; }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{

View File

@ -72,15 +72,14 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename
class ReaderWriterOsgShadow : public osgDB::ReaderWriter
{
public:
ReaderWriterOsgShadow() { }
ReaderWriterOsgShadow()
{
supportsExtension("osgShadow","OpenSceneGraph osgShadow extension to .osg ascii format");
supportsExtension("shadow","OpenSceneGraph osgShadow extension pseudo loader");
}
virtual const char* className() const { return "osgShadow pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive( extension, "osgShadow" ) || osgDB::equalCaseInsensitive( extension, "shadow" ) ;
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);

View File

@ -19,15 +19,12 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter
ReaderWriterTerrain()
{
supportsExtension("osgTerrain","OpenSceneGraph terrain extension to .osg ascii format");
supportsExtension("terrain","OpenSceneGraph terrain ascii format");
}
virtual const char* className() const { return "Terrain ReaderWriter"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive( extension, "osgTerrain" ) || osgDB::equalCaseInsensitive(extension,"terrain");
}
virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* opt) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);

View File

@ -23,15 +23,15 @@
class ReaderWriterOsgViewer : public osgDB::ReaderWriter
{
public:
ReaderWriterOsgViewer() { }
virtual const char* className() const { return "osgViewer configuration loader"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterOsgViewer()
{
return osgDB::equalCaseInsensitive( extension, "osgviewer" ) || osgDB::equalCaseInsensitive( extension, "view" ) ;
supportsExtension("osgviewer","OpenSceneGraph viewer configuration format");
supportsExtension("view","OpenSceneGraph viewer configuration format");
supportsOption("precision","Set the floating point precision of output");
supportsOption("OutputTextureFiles","Output texture image to file");
}
virtual const char* className() const { return "osgViewer configuration loader"; }
void setPrecision(osgDB::Output& fout, const osgDB::ReaderWriter::Options* options) const
{

View File

@ -9,13 +9,12 @@
class ReaderWriterOSGA : public osgDB::ReaderWriter
{
public:
ReaderWriterOSGA() { }
ReaderWriterOSGA()
{
supportsExtension("osga","OpenSceneGraph Archive format");
}
virtual const char* className() const { return "OpenSceneGraph Archive Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"osga");
}
virtual ReadResult openArchive(const std::string& file,ArchiveStatus status, unsigned int indexBlockSize = 4096, const Options* options=NULL) const
{

View File

@ -24,12 +24,14 @@ using namespace osg;
class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "OSGTGZ Database Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
sgReaderWriterOSGTGZ()
{
return osgDB::equalCaseInsensitive(extension,"osgtgz");
supportsExtension("osgtgz","OpenSceneGraph tar gzid'd archive format");
}
virtual const char* className() const { return "OSGTGZ Database Reader/Writer"; }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getFileExtension(file);

View File

@ -31,70 +31,6 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
void initPerformer();
virtual const char* className() const { return "Performer Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return
osgDB::equalCaseInsensitive(extension,"3ds") ? true :
osgDB::equalCaseInsensitive(extension,"arcinfo") ? true :
osgDB::equalCaseInsensitive(extension,"bin") ? true :
osgDB::equalCaseInsensitive(extension,"bpoly") ? true :
osgDB::equalCaseInsensitive(extension,"bw") ? true :
osgDB::equalCaseInsensitive(extension,"byu") ? true :
osgDB::equalCaseInsensitive(extension,"closest") ? true :
osgDB::equalCaseInsensitive(extension,"csb") ? true :
osgDB::equalCaseInsensitive(extension,"ct") ? true :
osgDB::equalCaseInsensitive(extension,"dem") ? true :
osgDB::equalCaseInsensitive(extension,"doublerot") ? true :
osgDB::equalCaseInsensitive(extension,"doublescale") ? true :
osgDB::equalCaseInsensitive(extension,"doubletrans") ? true :
osgDB::equalCaseInsensitive(extension,"dted") ? true :
osgDB::equalCaseInsensitive(extension,"dwb") ? true :
osgDB::equalCaseInsensitive(extension,"dxf") ? true :
osgDB::equalCaseInsensitive(extension,"evt") ? true :
osgDB::equalCaseInsensitive(extension,"flt") ? true :
osgDB::equalCaseInsensitive(extension,"gds") ? true :
osgDB::equalCaseInsensitive(extension,"gfo") ? true :
osgDB::equalCaseInsensitive(extension,"im") ? true :
osgDB::equalCaseInsensitive(extension,"irtp") ? true :
osgDB::equalCaseInsensitive(extension,"iv20") ? true :
osgDB::equalCaseInsensitive(extension,"iv") ? true :
osgDB::equalCaseInsensitive(extension,"lodfix") ? true :
osgDB::equalCaseInsensitive(extension,"lsa") ? true :
osgDB::equalCaseInsensitive(extension,"lsb") ? true :
osgDB::equalCaseInsensitive(extension,"medit") ? true :
osgDB::equalCaseInsensitive(extension,"m") ? true :
osgDB::equalCaseInsensitive(extension,"nff") ? true :
osgDB::equalCaseInsensitive(extension,"obj") ? true :
osgDB::equalCaseInsensitive(extension,"pegg") ? true :
osgDB::equalCaseInsensitive(extension,"pfb") ? true :
osgDB::equalCaseInsensitive(extension,"pfs") ? true :
osgDB::equalCaseInsensitive(extension,"phd") ? true :
osgDB::equalCaseInsensitive(extension,"poly") ? true :
osgDB::equalCaseInsensitive(extension,"post") ? true :
osgDB::equalCaseInsensitive(extension,"proc") ? true :
osgDB::equalCaseInsensitive(extension,"projtex") ? true :
osgDB::equalCaseInsensitive(extension,"pts") ? true :
osgDB::equalCaseInsensitive(extension,"rot") ? true :
osgDB::equalCaseInsensitive(extension,"scale") ? true :
osgDB::equalCaseInsensitive(extension,"sgf") ? true :
osgDB::equalCaseInsensitive(extension,"sgo") ? true :
osgDB::equalCaseInsensitive(extension,"so") ? true :
osgDB::equalCaseInsensitive(extension,"spf") ? true :
osgDB::equalCaseInsensitive(extension,"spherepatch3") ? true :
osgDB::equalCaseInsensitive(extension,"spherepatch") ? true :
osgDB::equalCaseInsensitive(extension,"sphere") ? true :
osgDB::equalCaseInsensitive(extension,"sponge") ? true :
osgDB::equalCaseInsensitive(extension,"star") ? true :
osgDB::equalCaseInsensitive(extension,"stla") ? true :
osgDB::equalCaseInsensitive(extension,"stlb") ? true :
osgDB::equalCaseInsensitive(extension,"substclip") ? true :
osgDB::equalCaseInsensitive(extension,"sv") ? true :
osgDB::equalCaseInsensitive(extension,"trans") ? true :
osgDB::equalCaseInsensitive(extension,"tri") ? true :
osgDB::equalCaseInsensitive(extension,"unc") ? true :
osgDB::equalCaseInsensitive(extension,"vct") ? true :
false;
}
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
@ -195,6 +131,66 @@ class ReaderWriterPFB : public osgDB::ReaderWriter
ReaderWriterPFB::ReaderWriterPFB()
{
supportsExtension("3ds","");
supportsExtension("arcinfo","");
supportsExtension("bin","");
supportsExtension("bpoly","");
supportsExtension("bw","");
supportsExtension("byu","");
supportsExtension("closest","");
supportsExtension("csb","");
supportsExtension("ct","");
supportsExtension("dem","");
supportsExtension("doublerot","");
supportsExtension("doublescale","");
supportsExtension("doubletrans","");
supportsExtension("dted","");
supportsExtension("dwb","");
supportsExtension("dxf","");
supportsExtension("evt","");
supportsExtension("flt","");
supportsExtension("gds","");
supportsExtension("gfo","");
supportsExtension("im","");
supportsExtension("irtp","");
supportsExtension("iv20","");
supportsExtension("iv","");
supportsExtension("lodfix","");
supportsExtension("lsa","");
supportsExtension("lsb","");
supportsExtension("medit","");
supportsExtension("m","");
supportsExtension("nff","");
supportsExtension("obj","");
supportsExtension("pegg","");
supportsExtension("pfb","");
supportsExtension("pfs","");
supportsExtension("phd","");
supportsExtension("poly","");
supportsExtension("post","");
supportsExtension("proc","");
supportsExtension("projtex","");
supportsExtension("pts","");
supportsExtension("rot","");
supportsExtension("scale","");
supportsExtension("sgf","");
supportsExtension("sgo","");
supportsExtension("so","");
supportsExtension("spf","");
supportsExtension("spherepatch3","");
supportsExtension("spherepatch","");
supportsExtension("sphere","");
supportsExtension("sponge","");
supportsExtension("star","");
supportsExtension("stla","");
supportsExtension("stlb","");
supportsExtension("substclip","");
supportsExtension("sv","");
supportsExtension("trans","");
supportsExtension("tri","");
supportsExtension("unc","");
supportsExtension("vct","");
_performerInitialised = false;
initPerformer();
}

View File

@ -191,8 +191,12 @@ int *numComponents_ret)
class ReaderWriterPIC : public osgDB::ReaderWriter
{
public:
ReaderWriterPIC()
{
supportsExtension("pic","PIC Image format");
}
virtual const char* className() const { return "PIC Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"pic"); }
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const
{

View File

@ -80,8 +80,12 @@ void png_flush_ostream(png_structp png_ptr)
class ReaderWriterPNG : public osgDB::ReaderWriter
{
public:
ReaderWriterPNG()
{
supportsExtension("png","PNG Image format");
}
virtual const char* className() const { return "PNG Image Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"png"); }
WriteResult::WriteStatus writePngStream(std::ostream& fout, const osg::Image& img, int compression_level) const
{

View File

@ -247,15 +247,15 @@ template <class T>
class ReaderWriterPNM : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "PNM Image Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterPNM()
{
return osgDB::equalCaseInsensitive(extension, "pnm") ||
osgDB::equalCaseInsensitive(extension, "ppm") ||
osgDB::equalCaseInsensitive(extension, "pgm") ||
osgDB::equalCaseInsensitive(extension, "pbm");
supportsExtension("pnm","PNM Image format");
supportsExtension("ppm","PNM Image format");
supportsExtension("pgm","PNM Image format");
supportsExtension("pbm","PNM Image format");
}
virtual const char* className() const { return "PNM Image Reader/Writer"; }
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{

View File

@ -76,7 +76,34 @@ class ReaderWriterQT : public osgDB::ReaderWriter
public:
ReaderWriterQT::ReaderWriterQT()
{
supportsExtension("mov","Movie format");
supportsExtension("mpg","Movie format");
supportsExtension("mpv","Movie format");
supportsExtension("mp4","Movie format");
supportsExtension("m4v","Movie format");
supportsExtension("dv","Movie format");
supportsExtension("avi","Movie format");
supportsExtension("flv","Movie format");
supportsExtension("swf","Movie format");
supportsExtension("live","Live video streaming");
#ifdef QT_HANDLE_IMAGES_ALSO
supportsExtension("rgb","rgb image format");
supportsExtension("rgba","rgba image format");
supportsExtension("jpg","jpg image format");
supportsExtension("jpeg","jpeg image format");
supportsExtension("tif","tif image format");
supportsExtension("tiff","tiff image format");
supportsExtension("gif","gif image format");
supportsExtension("png","png image format");
supportsExtension("pict","pict image format");
supportsExtension("pct","pct image format");
supportsExtension("tga","tga image format");
supportsExtension("psd","psd image format");
#endif
}
ReaderWriterQT::~ReaderWriterQT()
{
}

View File

@ -93,15 +93,13 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename
class ReaderWriterROT : public osgDB::ReaderWriter
{
public:
ReaderWriterROT() { }
ReaderWriterROT()
{
supportsExtension(EXTENSION_NAME,"Rotation pseudo loader");
}
virtual const char* className() const { return "rotation pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);

View File

@ -96,7 +96,10 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename
class ReaderWriterSCALE : public osgDB::ReaderWriter
{
public:
ReaderWriterSCALE() { }
ReaderWriterSCALE()
{
supportsExtension(EXTENSION_NAME,"Scale Pseudo loader");
}
virtual const char* className() const { return "scaling pseudo-loader"; }

View File

@ -45,16 +45,14 @@
class ReaderWriterSTL : public osgDB::ReaderWriter
{
public:
ReaderWriterSTL() {}
virtual const char* className() const {
return "STL Reader/Writer";
ReaderWriterSTL()
{
supportsExtension("stl","STL format");
supportsExtension("sta","STL format");
}
virtual bool acceptsExtension(const std::string& extension) const {
return
osgDB::equalCaseInsensitive(extension,"stl") ? true :
osgDB::equalCaseInsensitive(extension,"sta") ? true : false;
virtual const char* className() const {
return "STL Reader";
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const;

View File

@ -22,98 +22,96 @@
#include <osgDB/ImageOptions>
extern "C" {
#include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h>
#include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h>
}
class ReaderWriterSVG : public osgDB::ReaderWriter
{
public:
ReaderWriterSVG()
{
rsvg_init();
}
virtual const char* className() const { return "SVG Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"svg");
}
ReaderWriterSVG()
{
supportsExtension("svg","Scalar Vector Graphics format");
rsvg_init();
}
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
return readImage(file, options);
}
virtual const char* className() const { return "SVG Image Reader"; }
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
return readImage(file, options);
}
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
RsvgDimensionData dimensionData;
RsvgHandle* handle = rsvg_handle_new_from_file (file.c_str(), NULL);
rsvg_handle_get_dimensions( handle, &dimensionData);
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::Image *image;
if (options)
{
unsigned int w=0, h=0;
std::string op = options->getOptionString();
size_t i = op.find("x");
RsvgDimensionData dimensionData;
RsvgHandle* handle = rsvg_handle_new_from_file (file.c_str(), NULL);
rsvg_handle_get_dimensions( handle, &dimensionData);
std::stringstream ss1(op.substr(0, i));
std::stringstream ss2(op.substr(i+1, op.size()));
ss1 >> w;
ss1 >> h;
if (w==0 || h==0){
image = createImage(handle, dimensionData.width, dimensionData.height);
}
else{
image = createImage(handle, w, h);
}
}
else{
image = createImage(handle, dimensionData.width, dimensionData.height);
}
rsvg_handle_free(handle);
image->setFileName(file);
return image;
}
osg::Image *image;
if (options)
{
unsigned int w=0, h=0;
std::string op = options->getOptionString();
size_t i = op.find("x");
osg::Image* createImage(RsvgHandle *handle, unsigned int width, unsigned int height) const
{
RsvgDimensionData dimensionData;
rsvg_handle_get_dimensions( handle, &dimensionData);
// If image resollution < 128, cairo produces some artifacts.
// I don't know why, but we check the size...
if (width < 128) width = 128;
if (height < 128) height = 128;
width = osg::Image::computeNearestPowerOfTwo(width);
height = osg::Image::computeNearestPowerOfTwo(height);
osg::Image *image = new osg::Image();
image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
image->setPixelFormat(GL_BGRA);
std::stringstream ss1(op.substr(0, i));
std::stringstream ss2(op.substr(i+1, op.size()));
ss1 >> w;
ss1 >> h;
if (w==0 || h==0){
image = createImage(handle, dimensionData.width, dimensionData.height);
}
else{
image = createImage(handle, w, h);
}
}
else{
image = createImage(handle, dimensionData.width, dimensionData.height);
}
rsvg_handle_free(handle);
image->setFileName(file);
return image;
}
cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(image->data(),
CAIRO_FORMAT_ARGB32, width, height, image->getRowSizeInBytes());
cairo_t *cr = cairo_create(cairo_surface);
cairo_scale(cr,((float)width)/dimensionData.width, ((float)height)/dimensionData.height);
rsvg_handle_render_cairo(handle, cr);
osg::Image* createImage(RsvgHandle *handle, unsigned int width, unsigned int height) const
{
RsvgDimensionData dimensionData;
rsvg_handle_get_dimensions( handle, &dimensionData);
// If image resollution < 128, cairo produces some artifacts.
// I don't know why, but we check the size...
if (width < 128) width = 128;
if (height < 128) height = 128;
width = osg::Image::computeNearestPowerOfTwo(width);
height = osg::Image::computeNearestPowerOfTwo(height);
osg::Image *image = new osg::Image();
image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
image->setPixelFormat(GL_BGRA);
cairo_destroy(cr);
free(cairo_surface);
cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(image->data(),
CAIRO_FORMAT_ARGB32, width, height, image->getRowSizeInBytes());
cairo_t *cr = cairo_create(cairo_surface);
cairo_scale(cr,((float)width)/dimensionData.width, ((float)height)/dimensionData.height);
rsvg_handle_render_cairo(handle, cr);
image->flipVertical();
return image;
}
protected:
virtual ~ReaderWriterSVG()
{
rsvg_term();
}
cairo_destroy(cr);
free(cairo_surface);
image->flipVertical();
return image;
}
protected:
virtual ~ReaderWriterSVG()
{
rsvg_term();
}
};
// now register with Registry to instantiate the above

View File

@ -467,8 +467,13 @@ int headerlen)
class ReaderWriterTGA : public osgDB::ReaderWriter
{
public:
ReaderWriterTGA()
{
supportsExtension("tga","Tga Image format");
}
virtual const char* className() const { return "TGA Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"tga"); }
ReadResult readTGAStream(std::istream& fin) const
{

View File

@ -26,9 +26,9 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
public:
virtual const char* className() const { return "TGZ Database Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterTGZ()
{
return osgDB::equalCaseInsensitive(extension,"tgz");
supportsExtension("tgz","Tar gzip'd archive format");
}
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const

View File

@ -631,6 +631,13 @@ simage_tiff_load(std::istream& fin,
class ReaderWriterTIFF : public osgDB::ReaderWriter
{
public:
ReaderWriterTIFF()
{
supportsExtension("tiff","Tiff image format");
supportsExtension("tif","Tiff image format");
}
virtual const char* className() const { return "TIFF Image Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{

View File

@ -94,15 +94,13 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename
class ReaderWriterTRANS : public osgDB::ReaderWriter
{
public:
ReaderWriterTRANS() { }
ReaderWriterTRANS()
{
supportsExtension(EXTENSION_NAME,"Translation Psuedo loader.");
}
virtual const char* className() const { return "translation pseudo-loader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME );
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(fileName);

View File

@ -23,13 +23,13 @@
class ReaderWriterTXF : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "TXF Font Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterTXF()
{
return osgDB::equalCaseInsensitive(extension, "txf"); // GLU texture fonts
supportsExtension("txf","TXF Font format");
}
virtual const char* className() const { return "TXF Font Reader/Writer"; }
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);

View File

@ -53,16 +53,17 @@ namespace txp
class ReaderWriterTXP : public osgDB::ReaderWriter
{
public:
ReaderWriterTXP()
{
supportsExtension("txp","Terrapage txp format");
}
virtual const char* className() const
{
return "TXP Reader/Writer";
}
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"txp");
}
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
if( !acceptsExtension(osgDB::getFileExtension(file) ))

View File

@ -72,17 +72,15 @@ class ReaderWriterVRML2
{
public:
ReaderWriterVRML2()
{}
{
supportsExtension("wrl","VRML format");
}
virtual const char* className()
{
return "VRML2 Reader/Writer";
}
virtual bool acceptsExtension(const std::string& extension)
{
return osgDB::equalCaseInsensitive(extension, "wrl");
}
virtual ReadResult readNode(const std::string&, const osgDB::ReaderWriter::Options *options = NULL) const;

View File

@ -48,17 +48,15 @@
class ReaderWriterDirectX : public osgDB::ReaderWriter
{
public:
ReaderWriterDirectX() { }
ReaderWriterDirectX()
{
supportsExtension("x","DirectX scene format");
}
virtual const char* className() const {
return "DirectX Reader/Writer";
}
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"x");
}
virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const;
private:

View File

@ -311,6 +311,15 @@ class ReaderWriterXine : public osgDB::ReaderWriter
ReaderWriterXine()
{
supportsExtension("avi","");
supportsExtension("db","");
supportsExtension("flv","");
supportsExtension("mov","");
supportsExtension("mpg","Mpeg movie format");
supportsExtension("mpv","Mpeg movie format");
supportsExtension("wmv","");
supportsExtension("xine","Xine plugin Pseduo plugin");
_xine = xine_new();
const char* user_home = xine_get_homedir();
@ -336,18 +345,6 @@ class ReaderWriterXine : public osgDB::ReaderWriter
virtual const char* className() const { return "Xine ImageStream Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"mpg") ||
osgDB::equalCaseInsensitive(extension,"mpv") ||
osgDB::equalCaseInsensitive(extension,"db") ||
osgDB::equalCaseInsensitive(extension,"flv") ||
osgDB::equalCaseInsensitive(extension,"mov") ||
osgDB::equalCaseInsensitive(extension,"avi") ||
osgDB::equalCaseInsensitive(extension,"wmv") ||
osgDB::equalCaseInsensitive(extension,"xine");
}
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);

View File

@ -22,13 +22,14 @@
class ReaderWriterZIP : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "ZIP Database Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
ReaderWriterZIP()
{
return osgDB::equalCaseInsensitive(extension,"zip");
supportsExtension("zip","Zip archive format");
}
virtual const char* className() const { return "ZIP Database Reader/Writer"; }
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{