2003-10-28 00:07:21 +08:00
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
*
* This application is open source and may be redistributed and / or modified
* freely and without restriction , both in commericial and non commericial applications ,
* as long as this copyright notice is maintained .
*
* This application is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
*/
# include <osg/Texture2D>
# include <osg/Geometry>
# include <osg/State>
# include <osg/ShapeDrawable>
# include <osgDB/ReadFile>
# include <osgDB/WriteFile>
# include <osgDB/ImageOptions>
# include <osgDB/FileNameUtils>
2004-05-08 14:35:32 +08:00
# include <osgDB/FileUtils>
2003-10-28 00:07:21 +08:00
# include <osgUtil/Optimizer>
# include <osgUtil/TriStripVisitor>
# include <osgUtil/SmoothingVisitor>
# include <osgUtil/TangentSpaceGenerator>
# include <osgFX/BumpMapping>
# include <osgProducer/Viewer>
2004-01-29 23:47:06 +08:00
# include <osg/Switch>
2003-10-28 00:07:21 +08:00
2004-03-12 00:14:25 +08:00
# include <osgTerrain/DataSet>
2003-10-28 00:07:21 +08:00
2004-01-29 23:47:06 +08:00
# include <ogr_spatialref.h>
2004-03-29 18:45:58 +08:00
class GraphicsContext {
public :
GraphicsContext ( )
{
rs = new Producer : : RenderSurface ;
rs - > setWindowRectangle ( 0 , 0 , 1 , 1 ) ;
rs - > useBorder ( false ) ;
rs - > useConfigEventThread ( false ) ;
rs - > realize ( ) ;
std : : cout < < " Realized window " < < std : : endl ;
}
virtual ~ GraphicsContext ( )
{
}
private :
Producer : : ref_ptr < Producer : : RenderSurface > rs ;
} ;
2004-03-20 06:03:32 +08:00
2004-03-12 00:14:25 +08:00
char * SanitizeSRS ( const char * pszUserInput )
{
OGRSpatialReferenceH hSRS ;
char * pszResult = NULL ;
CPLErrorReset ( ) ;
hSRS = OSRNewSpatialReference ( NULL ) ;
if ( OSRSetFromUserInput ( hSRS , pszUserInput ) = = OGRERR_NONE )
OSRExportToWkt ( hSRS , & pszResult ) ;
else
{
CPLError ( CE_Failure , CPLE_AppDefined ,
" Translating source or target SRS failed: \n %s " ,
pszUserInput ) ;
exit ( 1 ) ;
}
OSRDestroySpatialReference ( hSRS ) ;
return pszResult ;
}
2004-04-23 05:51:06 +08:00
osg : : Matrixd computeGeoTransForRange ( double xMin , double xMax , double yMin , double yMax )
{
osg : : Matrixd matrix ;
matrix ( 0 , 0 ) = xMax - xMin ;
matrix ( 3 , 0 ) = xMin ;
matrix ( 1 , 1 ) = yMax - yMin ;
matrix ( 3 , 1 ) = yMin ;
return matrix ;
}
2003-10-28 00:07:21 +08:00
2004-03-31 23:50:30 +08:00
void ellipsodeTransformTest ( double latitude , double longitude , double height )
{
2004-04-30 06:23:55 +08:00
osg : : ref_ptr < osg : : EllipsoidModel > transform = new osg : : EllipsoidModel ;
2004-03-31 23:50:30 +08:00
double X , Y , Z ;
double newLat , newLong , newHeight ;
2004-04-30 06:23:55 +08:00
transform - > convertLatLongHeightToXYZ ( latitude , longitude , height ,
2004-03-31 23:50:30 +08:00
X , Y , Z ) ;
2004-04-30 06:23:55 +08:00
transform - > convertXYZToLatLongHeight ( X , Y , Z ,
2004-03-31 23:50:30 +08:00
newLat , newLong , newHeight ) ;
std : : cout < < " lat = " < < osg : : RadiansToDegrees ( latitude ) < < " \t long= " < < osg : : RadiansToDegrees ( longitude ) < < " \t " < < height < < std : : endl ;
std : : cout < < " X = " < < X < < " \t Y= " < < Y < < " \t Z= " < < Z < < std : : endl ;
std : : cout < < " lat = " < < osg : : RadiansToDegrees ( newLat ) < < " \t long= " < < osg : : RadiansToDegrees ( newLong ) < < " \t " < < newHeight < < std : : endl ;
}
2004-05-08 14:35:32 +08:00
void processFile ( std : : string filename ,
osgTerrain : : DataSet : : Source : : Type type ,
std : : string currentCS ,
osg : : Matrixd & geoTransform ,
bool geoTransformSet ,
bool geoTransformScale ,
osg : : ref_ptr < osgTerrain : : DataSet > dataset ) {
if ( filename . empty ( ) ) return ;
if ( osgDB : : fileType ( filename ) = = osgDB : : REGULAR_FILE ) {
osgTerrain : : DataSet : : Source * source = new osgTerrain : : DataSet : : Source ( type , filename ) ;
if ( source )
{
if ( ! currentCS . empty ( ) )
{
std : : cout < < " source->setCoordySystem " < < currentCS < < std : : endl ;
source - > setCoordinateSystemPolicy ( osgTerrain : : DataSet : : Source : : PREFER_CONFIG_SETTINGS ) ;
source - > setCoordinateSystem ( currentCS ) ;
}
if ( geoTransformSet )
{
std : : cout < < " source->setGeoTransform " < < geoTransform < < std : : endl ;
source - > setGeoTransformPolicy ( geoTransformScale ?
osgTerrain : : DataSet : : Source : : PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION :
osgTerrain : : DataSet : : Source : : PREFER_CONFIG_SETTINGS ) ;
source - > setGeoTransform ( geoTransform ) ;
}
dataset - > addSource ( source ) ;
}
} else if ( osgDB : : fileType ( filename ) = = osgDB : : DIRECTORY ) {
osgDB : : DirectoryContents dirContents = osgDB : : getDirectoryContents ( filename ) ;
// loop through directory contents and call processFile
std : : vector < std : : string > : : iterator i ;
std : : string fullfilename ;
for ( i = dirContents . begin ( ) ; i ! = dirContents . end ( ) ; + + i ) {
if ( ( * i ! = " . " ) & & ( * i ! = " .. " ) ) {
fullfilename = filename + ' / ' + * i ;
processFile ( fullfilename , type , currentCS , geoTransform , geoTransformSet , geoTransformScale , dataset ) ;
}
}
}
}
2003-11-25 19:40:10 +08:00
int main ( int argc , char * * argv )
2003-10-28 00:07:21 +08:00
{
2004-03-20 06:03:32 +08:00
2003-11-25 19:40:10 +08:00
// use an ArgumentParser object to manage the program arguments.
osg : : ArgumentParser arguments ( & argc , argv ) ;
2003-10-28 00:07:21 +08:00
2003-11-25 19:40:10 +08:00
// set up the usage document, in case we need to print out how to use this program.
arguments . getApplicationUsage ( ) - > setApplicationName ( arguments . getApplicationName ( ) ) ;
arguments . getApplicationUsage ( ) - > setDescription ( arguments . getApplicationName ( ) + " is the standard OpenSceneGraph example which loads and visualises 3d models. " ) ;
arguments . getApplicationUsage ( ) - > setCommandLineUsage ( arguments . getApplicationName ( ) + " [options] filename ... " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -d <filename> " , " Specify the digital elevation map input file to process " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -t <filename> " , " Specify the texture map input file to process " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -m <filename> " , " Specify the 3D database model input file to process " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -o <outputfile> " , " Specify the output master file to generate " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -l <numOfLevels> " , " Specify the number of PagedLOD levels to generate " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -e <x> <y> <w> <h> " , " Extents of the model to generate " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -h or --help " , " Display this information " ) ;
2004-03-12 06:04:41 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --o_cs <coordinates system string> " , " Set the output coordinates system. The string may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPS " ) ;
2004-06-09 18:03:01 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --o_wkt <WKT string> " , " Set the coordinates system of source imagery or DEM in WellKownText form. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --o_wkt-file <WKT file> " , " Set the coordinates system of source imagery or DEM by as file containing WellKownText definition. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --cs <coordinates system string> " , " Set the coordinates system of source imagery or DEM. The string may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPS " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --wkt <WKT string> " , " Set the coordinates system of source imagery or DEM in WellKownText form. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --wkt-file <WKT file> " , " Set the coordinates system of source imagery or DEM by as file containing WellKownText definition. " ) ;
2004-06-02 22:16:45 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --skirt-ratio <float> " , " Set the ratio of skirt height to tile size. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --HEIGHT_FIELD " , " Create a height field database " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --POLYGONAL " , " Create a height field database " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --LOD " , " Create a LOD'd database " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --PagedLOD " , " Create a PagedLOD'd database " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " -v " , " Set the vertical multiplier " ) ;
2004-06-06 22:28:29 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --compressed " , " Use OpenGL compression on destination imagery " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --RGB_16 " , " Use 16bit RGB destination imagery " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --RGB_24 " , " Use 24bit RGB destination imagery " ) ;
2004-06-09 18:03:01 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --max_visible_distance_of_top_level " , " Set the maximum visiable distance that the top most tile can be viewed at " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --radius_to_max_visible_distance_ratio " , " Set the maximum visiable distance ratio for all tiles apart from the top most tile. The maximum visuble distance is computed from the ratio * tile radius. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --no_mip_mapping " , " Disable mip mapping of textures " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --mip_mapping_hardware " , " Use mip mapped textures, and generate the mipmaps in hardware when available. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --mip_mapping_imagery " , " Use mip mapped textures, and generate the mipmaps in imagery. " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --max_anisotropy " , " Max anisotropy level to use when texturing, defaults to 1.0. " ) ;
2004-06-08 21:58:36 +08:00
// arguments.getApplicationUsage()->addCommandLineOption("","");
2003-10-28 00:07:21 +08:00
2003-11-25 19:40:10 +08:00
// create DataSet.
2004-03-12 00:14:25 +08:00
osg : : ref_ptr < osgTerrain : : DataSet > dataset = new osgTerrain : : DataSet ;
2003-10-28 00:07:21 +08:00
2003-11-25 19:40:10 +08:00
float x , y , w , h ;
while ( arguments . read ( " -e " , x , y , w , h ) )
2003-10-28 00:07:21 +08:00
{
2003-11-25 19:40:10 +08:00
dataset - > setDestinationExtents ( osg : : BoundingBox ( x , y , 0.0f , x + w , y + h , 0.0f ) ) ;
2003-10-28 00:07:21 +08:00
}
2004-01-29 23:47:06 +08:00
2004-03-29 18:45:58 +08:00
while ( arguments . read ( " --HEIGHT_FIELD " ) )
{
dataset - > setGeometryType ( osgTerrain : : DataSet : : HEIGHT_FIELD ) ;
}
while ( arguments . read ( " --POLYGONAL " ) )
{
dataset - > setGeometryType ( osgTerrain : : DataSet : : POLYGONAL ) ;
}
2004-03-15 23:47:22 +08:00
while ( arguments . read ( " --LOD " ) )
{
dataset - > setDatabaseType ( osgTerrain : : DataSet : : LOD_DATABASE ) ;
}
2004-01-29 23:47:06 +08:00
2004-03-15 23:47:22 +08:00
while ( arguments . read ( " --PagedLOD " ) )
{
dataset - > setDatabaseType ( osgTerrain : : DataSet : : PagedLOD_DATABASE ) ;
}
2003-10-28 00:07:21 +08:00
2004-06-06 22:28:29 +08:00
while ( arguments . read ( " --compressed " ) ) { dataset - > setTextureType ( osgTerrain : : DataSet : : COMPRESSED_TEXTURE ) ; }
while ( arguments . read ( " --RGB_16 " ) ) { dataset - > setTextureType ( osgTerrain : : DataSet : : RGB_16_BIT ) ; }
while ( arguments . read ( " --RGB_24 " ) ) { dataset - > setTextureType ( osgTerrain : : DataSet : : RGB_24_BIT ) ; }
2004-06-09 18:03:01 +08:00
while ( arguments . read ( " --no_mip_mapping " ) ) { dataset - > setMipMappingMode ( osgTerrain : : DataSet : : NO_MIP_MAPPING ) ; }
while ( arguments . read ( " --mip_mapping_hardware " ) ) { dataset - > setMipMappingMode ( osgTerrain : : DataSet : : MIP_MAPPING_HARDWARE ) ; }
while ( arguments . read ( " --mip_mapping_imagery " ) ) { dataset - > setMipMappingMode ( osgTerrain : : DataSet : : MIP_MAPPING_IMAGERY ) ; }
2004-06-08 21:58:36 +08:00
float maxAnisotropy ;
2004-06-09 18:03:01 +08:00
while ( arguments . read ( " --max_anisotropy " , maxAnisotropy ) )
2004-06-08 21:58:36 +08:00
{
dataset - > setMaxAnisotropy ( maxAnisotropy ) ;
}
2003-11-25 19:40:10 +08:00
dataset - > setDestinationTileBaseName ( " output " ) ;
dataset - > setDestinationTileExtension ( " .ive " ) ;
2003-10-28 00:07:21 +08:00
2004-06-02 22:16:45 +08:00
unsigned int numLevels = 6 ;
2003-10-28 00:07:21 +08:00
while ( arguments . read ( " -l " , numLevels ) ) { }
2003-11-25 19:40:10 +08:00
float verticalScale ;
2004-03-12 00:14:25 +08:00
while ( arguments . read ( " -v " , verticalScale ) )
{
dataset - > setVerticalScale ( verticalScale ) ;
}
2003-10-28 00:07:21 +08:00
2004-06-02 22:16:45 +08:00
float skirtRatio ;
while ( arguments . read ( " --skirt-ratio " , skirtRatio ) )
{
dataset - > setSkirtRatio ( skirtRatio ) ;
}
2003-10-29 19:11:17 +08:00
2004-06-08 21:58:36 +08:00
float maxVisibleDistanceOfTopLevel ;
2004-06-09 18:03:01 +08:00
while ( arguments . read ( " --max_visible_distance_of_top_level " , maxVisibleDistanceOfTopLevel ) )
2004-06-08 21:58:36 +08:00
{
dataset - > setMaximumVisibleDistanceOfTopLevel ( maxVisibleDistanceOfTopLevel ) ;
}
float radiusToMaxVisibleDistanceRatio ;
2004-06-09 18:03:01 +08:00
while ( arguments . read ( " --radius_to_max_visible_distance_ratio " , radiusToMaxVisibleDistanceRatio ) )
2004-06-08 21:58:36 +08:00
{
dataset - > setRadiusToMaxVisibleDistanceRatio ( radiusToMaxVisibleDistanceRatio ) ;
}
2004-06-09 18:03:01 +08:00
{
// handle any specification of output coordinate system.
std : : string outputCS ;
std : : string def ;
if ( arguments . read ( " --o_cs " , def ) )
{
outputCS = ! def . empty ( ) ? SanitizeSRS ( def . c_str ( ) ) : " " ;
std : : cout < < " --o_cs " < < outputCS < < std : : endl ;
}
else if ( arguments . read ( " --o_wkt " , def ) )
{
outputCS = def ;
std : : cout < < " --o_wkt " < < outputCS < < std : : endl ;
}
else if ( arguments . read ( " --o_wkt-file " , def ) )
{
std : : ifstream in ( def . c_str ( ) ) ;
if ( in )
{
outputCS = " " ;
while ( ! in . eof ( ) )
{
std : : string line ;
in > > line ;
outputCS + = line ;
}
std : : cout < < " --o_wkt-file " < < outputCS < < std : : endl ;
}
}
if ( ! outputCS . empty ( ) ) dataset - > setDestinationCoordinateSystem ( outputCS ) ;
}
2003-10-28 00:07:21 +08:00
// if user request help write it out to cout.
if ( arguments . read ( " -h " ) | | arguments . read ( " --help " ) )
{
arguments . getApplicationUsage ( ) - > write ( std : : cout ) ;
return 1 ;
}
2004-03-20 06:03:32 +08:00
2004-06-09 18:03:01 +08:00
2004-03-20 06:03:32 +08:00
// read the input data
std : : string filename ;
std : : string currentCS ;
osg : : Matrixd geoTransform ;
bool geoTransformSet = false ;
2004-04-23 05:51:06 +08:00
bool geoTransformScale = false ;
double xMin , xMax , yMin , yMax ;
2004-03-20 06:03:32 +08:00
int pos = 1 ;
while ( pos < arguments . argc ( ) )
2004-01-29 23:47:06 +08:00
{
2004-03-20 06:03:32 +08:00
std : : string def ;
2004-03-21 02:32:49 +08:00
2004-03-20 06:03:32 +08:00
if ( arguments . read ( pos , " --cs " , def ) )
{
currentCS = ! def . empty ( ) ? SanitizeSRS ( def . c_str ( ) ) : " " ;
std : : cout < < " --cs " < < currentCS < < std : : endl ;
2004-03-20 06:20:35 +08:00
}
2004-04-01 19:03:39 +08:00
else if ( arguments . read ( pos , " --wkt " , def ) )
2004-03-30 06:26:51 +08:00
{
currentCS = def ;
2004-04-01 19:03:39 +08:00
std : : cout < < " --wkt " < < currentCS < < std : : endl ;
}
2004-06-02 22:16:45 +08:00
else if ( arguments . read ( pos , " --wkt-file " , def ) )
2004-04-06 05:27:57 +08:00
{
std : : ifstream in ( def . c_str ( ) ) ;
if ( in )
{
currentCS = " " ;
while ( ! in . eof ( ) )
{
std : : string line ;
in > > line ;
currentCS + = line ;
}
2004-06-02 22:16:45 +08:00
std : : cout < < " --wkt-file " < < currentCS < < std : : endl ;
2004-04-06 05:27:57 +08:00
}
}
2004-04-01 19:03:39 +08:00
else if ( arguments . read ( pos , " --geocentric " ) )
{
dataset - > setConvertFromGeographicToGeocentric ( true ) ;
std : : cout < < " --geocentric " < < currentCS < < std : : endl ;
2004-03-30 06:26:51 +08:00
}
2004-04-23 05:51:06 +08:00
else if ( arguments . read ( pos , " --bluemarble-east " ) )
{
currentCS = SanitizeSRS ( " WGS84 " ) ;
geoTransformSet = true ;
geoTransformScale = true ;
geoTransform = computeGeoTransForRange ( 0.0 , 180.0 , - 90.0 , 90.0 ) ;
dataset - > setConvertFromGeographicToGeocentric ( true ) ;
std : : cout < < " --bluemarble-west " < < currentCS < < " matrix= " < < geoTransform < < std : : endl ;
}
else if ( arguments . read ( pos , " --bluemarble-west " ) )
{
currentCS = SanitizeSRS ( " WGS84 " ) ;
geoTransformSet = true ;
geoTransformScale = true ;
geoTransform = computeGeoTransForRange ( - 180.0 , 0.0 , - 90.0 , 90.0 ) ;
dataset - > setConvertFromGeographicToGeocentric ( true ) ;
std : : cout < < " --bluemarble-west " < < currentCS < < " matrix= " < < geoTransform < < std : : endl ;
}
else if ( arguments . read ( pos , " --whole-globe " ) )
{
currentCS = SanitizeSRS ( " WGS84 " ) ;
geoTransformSet = true ;
geoTransformScale = true ;
geoTransform = computeGeoTransForRange ( - 180.0 , 180.0 , - 90.0 , 90.0 ) ;
dataset - > setConvertFromGeographicToGeocentric ( true ) ;
std : : cout < < " --whole-globe " < < currentCS < < " matrix= " < < geoTransform < < std : : endl ;
}
else if ( arguments . read ( pos , " --range " , xMin , xMax , yMin , yMax ) )
{
geoTransformSet = true ;
geoTransformScale = true ;
geoTransform = computeGeoTransForRange ( xMin , xMax , yMin , yMax ) ;
std : : cout < < " --range, matrix= " < < geoTransform < < std : : endl ;
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --identity " ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = false ;
geoTransform . makeIdentity ( ) ;
2004-03-20 06:03:32 +08:00
}
2004-03-21 20:17:44 +08:00
// x vector
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --xx " , geoTransform ( 0 , 0 ) ) )
2004-03-20 06:20:35 +08:00
{
2004-04-23 05:51:06 +08:00
geoTransformSet = true ;
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --xx " < < geoTransform ( 0 , 0 ) < < std : : endl ;
}
else if ( arguments . read ( pos , " --xy " , geoTransform ( 1 , 0 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --xy " < < geoTransform ( 1 , 0 ) < < std : : endl ;
}
else if ( arguments . read ( pos , " --xz " , geoTransform ( 2 , 0 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --xz " < < geoTransform ( 2 , 0 ) < < std : : endl ;
2004-03-20 06:20:35 +08:00
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --xt " , geoTransform ( 3 , 0 ) ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-20 06:20:35 +08:00
std : : cout < < " --xo " < < geoTransform ( 3 , 0 ) < < std : : endl ;
}
2004-03-21 20:17:44 +08:00
// y vector
else if ( arguments . read ( pos , " --yx " , geoTransform ( 0 , 1 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --yx " < < geoTransform ( 0 , 1 ) < < std : : endl ;
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --yy " , geoTransform ( 1 , 1 ) ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-20 06:20:35 +08:00
std : : cout < < " --yy " < < geoTransform ( 1 , 1 ) < < std : : endl ;
}
2004-03-21 20:17:44 +08:00
else if ( arguments . read ( pos , " --yz " , geoTransform ( 2 , 1 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --yz " < < geoTransform ( 2 , 1 ) < < std : : endl ;
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --yt " , geoTransform ( 3 , 1 ) ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-20 06:20:35 +08:00
std : : cout < < " --yt " < < geoTransform ( 3 , 1 ) < < std : : endl ;
}
2004-03-21 20:17:44 +08:00
// z vector
else if ( arguments . read ( pos , " --zx " , geoTransform ( 0 , 2 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --zx " < < geoTransform ( 0 , 2 ) < < std : : endl ;
}
else if ( arguments . read ( pos , " --zy " , geoTransform ( 1 , 2 ) ) )
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-21 20:17:44 +08:00
std : : cout < < " --zy " < < geoTransform ( 1 , 2 ) < < std : : endl ;
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --zz " , geoTransform ( 2 , 2 ) ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-20 06:20:35 +08:00
std : : cout < < " --zz " < < geoTransform ( 2 , 2 ) < < std : : endl ;
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " --zt " , geoTransform ( 3 , 2 ) ) )
2004-03-20 06:20:35 +08:00
{
geoTransformSet = true ;
2004-04-23 05:51:06 +08:00
geoTransformScale = false ;
2004-03-20 06:20:35 +08:00
std : : cout < < " --zt " < < geoTransform ( 3 , 2 ) < < std : : endl ;
}
2004-03-21 20:17:44 +08:00
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " -d " , filename ) )
2004-03-20 06:03:32 +08:00
{
2004-05-08 14:35:32 +08:00
std : : cout < < " -d " < < filename < < std : : endl ;
processFile ( filename , osgTerrain : : DataSet : : Source : : HEIGHT_FIELD , currentCS , geoTransform , geoTransformSet , geoTransformScale , dataset ) ;
2004-06-06 22:28:29 +08:00
geoTransformSet = false ;
geoTransformScale = false ;
geoTransform . makeIdentity ( ) ;
2004-03-20 06:03:32 +08:00
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " -t " , filename ) )
2004-03-20 06:03:32 +08:00
{
2004-05-08 14:35:32 +08:00
std : : cout < < " -t " < < filename < < std : : endl ;
processFile ( filename , osgTerrain : : DataSet : : Source : : IMAGE , currentCS , geoTransform , geoTransformSet , geoTransformScale , dataset ) ;
2004-06-06 22:28:29 +08:00
geoTransformSet = false ;
geoTransformScale = false ;
geoTransform . makeIdentity ( ) ;
2004-03-20 06:03:32 +08:00
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " -m " , filename ) )
2004-03-20 06:03:32 +08:00
{
2004-05-08 14:35:32 +08:00
std : : cout < < " -m " < < filename < < std : : endl ;
processFile ( filename , osgTerrain : : DataSet : : Source : : MODEL , currentCS , geoTransform , geoTransformSet , geoTransformScale , dataset ) ;
2004-06-06 22:28:29 +08:00
geoTransformSet = false ;
geoTransformScale = false ;
geoTransform . makeIdentity ( ) ;
2004-03-20 06:03:32 +08:00
}
2004-03-21 02:32:49 +08:00
else if ( arguments . read ( pos , " -o " , filename ) )
{
std : : cout < < " -o " < < filename < < std : : endl ;
std : : string path = osgDB : : getFilePath ( filename ) ;
std : : string base = path . empty ( ) ? osgDB : : getStrippedName ( filename ) :
path + ' / ' + osgDB : : getStrippedName ( filename ) ;
std : : string extension = ' . ' + osgDB : : getLowerCaseFileExtension ( filename ) ;
dataset - > setDestinationTileBaseName ( base ) ;
dataset - > setDestinationTileExtension ( extension ) ;
if ( ! currentCS . empty ( ) ) dataset - > setDestinationCoordinateSystem ( currentCS ) ;
}
else
{
// if no argument read advance to next argument.
+ + pos ;
}
2004-03-20 06:03:32 +08:00
}
2004-01-29 23:47:06 +08:00
2003-10-28 00:07:21 +08:00
// any option left unread are converted into errors to write out later.
arguments . reportRemainingOptionsAsUnrecognized ( ) ;
// report any errors if they have occured when parsing the program aguments.
if ( arguments . errors ( ) )
{
arguments . writeErrorMessages ( std : : cout ) ;
return 1 ;
}
2004-03-29 18:45:58 +08:00
// generate the database
{
GraphicsContext context ;
2003-10-28 00:07:21 +08:00
2004-03-29 18:45:58 +08:00
dataset - > loadSources ( ) ;
dataset - > createDestination ( ( unsigned int ) numLevels ) ;
dataset - > writeDestination ( ) ;
}
2003-10-28 00:07:21 +08:00
return 0 ;
}