From e404b95dc33d2a079532271d2f23aa1b8aa5179e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 4 Sep 2005 06:36:52 +0000 Subject: [PATCH] Added support in osgTerrain/osgdem for setting the image format to use when writing tiles out to disk --- applications/osgdem/osgdem.cpp | 21 +++++++++++++++++++++ include/osgTerrain/DataSet | 4 ++++ src/osgTerrain/DataSet.cpp | 9 ++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/applications/osgdem/osgdem.cpp b/applications/osgdem/osgdem.cpp index 61f4c4823..1a3e3df08 100644 --- a/applications/osgdem/osgdem.cpp +++ b/applications/osgdem/osgdem.cpp @@ -164,6 +164,7 @@ int main( int argc, char **argv ) arguments.getApplicationUsage()->addCommandLineOption("-a ","Specify the archive to place the generated database"); arguments.getApplicationUsage()->addCommandLineOption("-o ","Specify the output master file to generate"); arguments.getApplicationUsage()->addCommandLineOption("-l ","Specify the number of PagedLOD levels to generate"); + arguments.getApplicationUsage()->addCommandLineOption("--image-ext ","Specify the Image format to output to via its plugin name, i.e. rgb, dds, jp2, jpeg."); arguments.getApplicationUsage()->addCommandLineOption("--levels ","Specify the range of lavels that the next source Texture or DEM will contribute to."); arguments.getApplicationUsage()->addCommandLineOption("--layer ","Specify the layer that the next source Texture will contribute to.."); arguments.getApplicationUsage()->addCommandLineOption("-e ","Extents of the model to generate"); @@ -296,6 +297,26 @@ int main( int argc, char **argv ) dataset->setRadiusToMaxVisibleDistanceRatio(radiusToMaxVisibleDistanceRatio); } + std::string image_ext; + while (arguments.read("--image-ext",image_ext)) + { + std::string::size_type dot = image_ext.find_last_of('.'); + if (dot!=std::string::npos) image_ext.erase(0,dot+1); + + osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension(image_ext); + if (rw) + { + image_ext.insert(0,"."); + dataset->setDestinationImageExtension(image_ext); + return 1; + } + else + { + std::cout<<"Error: can not find plugin to write out image with extension '"< _archive; std::string _tileBasename; std::string _tileExtension; + std::string _imageExtension; osg::Vec4 _defaultColor; DatabaseType _databaseType; GeometryType _geometryType; diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index a384bb7c0..285eb58fd 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -1508,9 +1508,7 @@ void DataSet::DestinationTile::allocate() imageData._imagery->_image = new osg::Image; - std::string imageExension(".dds"); // ".rgb" - //std::string imageExension(".jp2"); // ".rgb" - std::string imageName(_name+imageExension); + std::string imageName(_name+_dataSet->getDestinationImageExtension()); imageData._imagery->_image->setFileName(imageName.c_str()); imageData._imagery->_image->allocateImage(texture_numColumns,texture_numRows,1,_pixelFormat,GL_UNSIGNED_BYTE); @@ -3705,6 +3703,11 @@ DataSet::DataSet() _convertFromGeographicToGeocentric = false; + _tileBasename = "output"; + _tileExtension = ".ive"; + _imageExtension = ".dds"; + + _defaultColor.set(0.5f,0.5f,1.0f,1.0f); _databaseType = PagedLOD_DATABASE; _geometryType = POLYGONAL;