root/OpenSceneGraph/trunk/examples/osgdem/osgdem.cpp @ 3242

Revision 3242, 23.8 kB (checked in by robert, 10 years ago)

From Bruce Clay, Build fixes for Win32 VS6.0

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
2 *
3 * This application is open source and may be redistributed and/or modified   
4 * freely and without restriction, both in commericial and non commericial applications,
5 * as long as this copyright notice is maintained.
6 *
7 * This application is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10*/
11
12#ifdef WIN32
13
14/////////////////////////////////////////////////////////////////////////////
15// Disable unavoidable warning messages:
16
17//  4114: same type qualifier used more than once
18//  4201: nonstandard extension used : nameless struct/union
19//  4237: "keyword" reserved for future use
20//  4251: class needs to have dll-interface to export class
21//  4275: non DLL-interface class used as base for DLL-interface class
22//  4290: C++ Exception Specification ignored
23//  4503: ecorated name length exceeded, name was truncated
24//  4786: string too long - truncated to 255 characters
25
26//#pragma warning(disable : 4103 4114 4201 4237 4251 4275 4290 4335 4786)
27#pragma warning(disable : 4503)
28
29#endif // WIN32
30
31#include <osg/Texture2D>
32#include <osg/Geometry>
33#include <osg/State>
34#include <osg/ShapeDrawable>
35
36#include <osgDB/ReadFile>
37#include <osgDB/WriteFile>
38#include <osgDB/ImageOptions>
39#include <osgDB/FileNameUtils>
40#include <osgDB/FileUtils>
41
42#include <osgUtil/Optimizer>
43#include <osgUtil/TriStripVisitor>
44#include <osgUtil/SmoothingVisitor>
45#include <osgUtil/TangentSpaceGenerator>
46
47#include <osgFX/BumpMapping>
48
49#include <osgProducer/Viewer>
50#include <osg/Switch>
51
52#include <osgTerrain/DataSet>
53
54#include <ogr_spatialref.h>
55
56class GraphicsContext {
57    public:
58        GraphicsContext()
59        {
60            rs = new Producer::RenderSurface;
61            rs->setWindowRectangle(0,0,1,1);
62            rs->useBorder(false);
63            rs->useConfigEventThread(false);
64            rs->realize();
65            std::cout<<"Realized window"<<std::endl;
66        }
67
68        virtual ~GraphicsContext()
69        {
70        }
71       
72    private:
73        Producer::ref_ptr<Producer::RenderSurface> rs;
74};
75
76char *SanitizeSRS( const char *pszUserInput )
77
78{
79    OGRSpatialReferenceH hSRS;
80    char *pszResult = NULL;
81
82    CPLErrorReset();
83   
84    hSRS = OSRNewSpatialReference( NULL );
85    if( OSRSetFromUserInput( hSRS, pszUserInput ) == OGRERR_NONE )
86        OSRExportToWkt( hSRS, &pszResult );
87    else
88    {
89        CPLError( CE_Failure, CPLE_AppDefined,
90                  "Translating source or target SRS failed:\n%s",
91                  pszUserInput );
92        exit( 1 );
93    }
94   
95    OSRDestroySpatialReference( hSRS );
96
97    return pszResult;
98}
99
100osg::Matrixd computeGeoTransForRange(double xMin, double xMax, double yMin, double yMax)
101{
102    osg::Matrixd matrix;
103    matrix(0,0) = xMax-xMin;
104    matrix(3,0) = xMin;
105
106    matrix(1,1) = yMax-yMin;
107    matrix(3,1) = yMin;
108   
109    return matrix;
110}
111
112
113void ellipsodeTransformTest(double latitude, double longitude, double height)
114{
115    osg::ref_ptr<osg::EllipsoidModel> transform = new osg::EllipsoidModel;
116   
117    double X,Y,Z;
118    double newLat, newLong, newHeight;
119   
120    transform->convertLatLongHeightToXYZ(latitude,longitude,height,
121                                        X,Y,Z);
122   
123    transform->convertXYZToLatLongHeight(X,Y,Z,
124                                        newLat,newLong,newHeight);
125                                       
126    std::cout<<"lat = "<<osg::RadiansToDegrees(latitude)<<"\tlong="<<osg::RadiansToDegrees(longitude)<<"\t"<<height<<std::endl; 
127    std::cout<<"X = "<<X<<"\tY="<<Y<<"\tZ="<<Z<<std::endl; 
128    std::cout<<"lat = "<<osg::RadiansToDegrees(newLat)<<"\tlong="<<osg::RadiansToDegrees(newLong)<<"\t"<<newHeight<<std::endl; 
129}
130
131void processFile(std::string filename,
132                   osgTerrain::DataSet::Source::Type type,
133                   std::string currentCS,
134                   osg::Matrixd &geoTransform,
135                   bool geoTransformSet,
136                   bool geoTransformScale,
137                   bool minmaxLevelSet, unsigned int min_level, unsigned int max_level,
138                   osg::ref_ptr<osgTerrain::DataSet> dataset) {
139
140    if(filename.empty()) return;
141
142    if(osgDB::fileType(filename) == osgDB::REGULAR_FILE) {
143       
144        osgTerrain::DataSet::Source* source = new osgTerrain::DataSet::Source(type, filename);               
145        if (source)
146        {
147            if (!currentCS.empty())
148            {
149                std::cout<<"source->setCoordySystem "<<currentCS<<std::endl;
150                source->setCoordinateSystemPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS);
151                source->setCoordinateSystem(currentCS);
152            }
153           
154            if (geoTransformSet)
155            {
156                std::cout<<"source->setGeoTransform "<<geoTransform<<std::endl;
157                source->setGeoTransformPolicy(geoTransformScale ?
158                                              osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION :
159                                              osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS);
160                source->setGeoTransform(geoTransform);
161            }
162            if (minmaxLevelSet)
163            {
164                source->setMinMaxLevel(min_level, max_level);
165            }
166           
167            dataset->addSource(source);
168        }
169    } else if (osgDB::fileType(filename) == osgDB::DIRECTORY) {
170
171        osgDB::DirectoryContents dirContents= osgDB::getDirectoryContents(filename);
172       
173        // loop through directory contents and call processFile
174        std::vector<std::string>::iterator i;
175        std::string fullfilename;
176        for(i = dirContents.begin(); i != dirContents.end(); ++i) {
177            if((*i != ".") && (*i != "..")) {
178                fullfilename = filename + '/' + *i;
179                processFile(fullfilename, type, currentCS,
180                            geoTransform, geoTransformSet, geoTransformScale,
181                            minmaxLevelSet, min_level, max_level,
182                            dataset);
183            }
184        }
185    }
186}
187
188
189int main( int argc, char **argv )
190{
191
192    // use an ArgumentParser object to manage the program arguments.
193    osg::ArgumentParser arguments(&argc,argv);
194   
195    // set up the usage document, in case we need to print out how to use this program.
196    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
197    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
198    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
199    arguments.getApplicationUsage()->addCommandLineOption("-d <filename>","Specify the digital elevation map input file to process");
200    arguments.getApplicationUsage()->addCommandLineOption("-t <filename>","Specify the texture map input file to process");
201    arguments.getApplicationUsage()->addCommandLineOption("-m <filename>","Specify the 3D database model input file to process");
202    arguments.getApplicationUsage()->addCommandLineOption("-o <outputfile>","Specify the output master file to generate");
203    arguments.getApplicationUsage()->addCommandLineOption("-l <numOfLevels>","Specify the number of PagedLOD levels to generate");
204    arguments.getApplicationUsage()->addCommandLineOption("-e <x> <y> <w> <h>","Extents of the model to generate");
205    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
206    arguments.getApplicationUsage()->addCommandLineOption("--cs <coordinates system string>","Set the coordinates system of source imagery, DEM or destination database. The string may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPS");     
207    arguments.getApplicationUsage()->addCommandLineOption("--wkt <WKT string>","Set the coordinates system of source imagery, DEM or destination database in WellKownText form.");     
208    arguments.getApplicationUsage()->addCommandLineOption("--wkt-file <WKT file>","Set the coordinates system of source imagery, DEM or destination database by as file containing WellKownText definition.");     
209    arguments.getApplicationUsage()->addCommandLineOption("--skirt-ratio <float>","Set the ratio of skirt height to tile size");     
210    arguments.getApplicationUsage()->addCommandLineOption("--HEIGHT_FIELD","Create a height field database");     
211    arguments.getApplicationUsage()->addCommandLineOption("--POLYGONAL","Create a height field database");     
212    arguments.getApplicationUsage()->addCommandLineOption("--LOD","Create a LOD'd database");     
213    arguments.getApplicationUsage()->addCommandLineOption("--PagedLOD","Create a PagedLOD'd database");     
214    arguments.getApplicationUsage()->addCommandLineOption("-v","Set the vertical multiplier");     
215    arguments.getApplicationUsage()->addCommandLineOption("--compressed","Use OpenGL compression on destination imagery");     
216    arguments.getApplicationUsage()->addCommandLineOption("--RGB-16","Use 16bit RGB destination imagery");     
217    arguments.getApplicationUsage()->addCommandLineOption("--RGB-24","Use 24bit RGB destination imagery");     
218    arguments.getApplicationUsage()->addCommandLineOption("--max-visible-distance-of-top-level","Set the maximum visible distance that the top most tile can be viewed at");     
219    arguments.getApplicationUsage()->addCommandLineOption("--radius-to-max-visible-distance-ratio","Set the maximum visible distance ratio for all tiles apart from the top most tile. The maximum visuble distance is computed from the ratio * tile radius.");     
220    arguments.getApplicationUsage()->addCommandLineOption("--no-mip-mapping","Disable mip mapping of textures");     
221    arguments.getApplicationUsage()->addCommandLineOption("--mip-mapping-hardware","Use mip mapped textures, and generate the mipmaps in hardware when available.");     
222    arguments.getApplicationUsage()->addCommandLineOption("--mip-mapping-imagery","Use mip mapped textures, and generate the mipmaps in imagery.");     
223    arguments.getApplicationUsage()->addCommandLineOption("--max-anisotropy","Max anisotropy level to use when texturing, defaults to 1.0.");
224    arguments.getApplicationUsage()->addCommandLineOption("--bluemarble-east","");     
225    arguments.getApplicationUsage()->addCommandLineOption("--bluemarble-west","");     
226    arguments.getApplicationUsage()->addCommandLineOption("--whole-globe","");
227    arguments.getApplicationUsage()->addCommandLineOption("--geocentric","");
228    arguments.getApplicationUsage()->addCommandLineOption("--range","");     
229    arguments.getApplicationUsage()->addCommandLineOption("--xx","");     
230    arguments.getApplicationUsage()->addCommandLineOption("--xt","");     
231    arguments.getApplicationUsage()->addCommandLineOption("--yy","");     
232    arguments.getApplicationUsage()->addCommandLineOption("--yt","");     
233    arguments.getApplicationUsage()->addCommandLineOption("--zz","");     
234    arguments.getApplicationUsage()->addCommandLineOption("--zt","");     
235    arguments.getApplicationUsage()->addCommandLineOption("--tile-image-size","Set the tile maximum image size");
236    arguments.getApplicationUsage()->addCommandLineOption("--tile-terrain-size","Set the tile maximum terrain size");
237    arguments.getApplicationUsage()->addCommandLineOption("--comment","Added a comment/description string to the top most node in the dataset");     
238       
239    // create DataSet.
240    osg::ref_ptr<osgTerrain::DataSet> dataset = new osgTerrain::DataSet;
241
242
243    float x,y,w,h;
244    while (arguments.read("-e",x,y,w,h))
245    {
246        dataset->setDestinationExtents(osg::BoundingBox(x,y,0.0f,x+w,y+h,0.0f));
247    }
248   
249    while (arguments.read("--HEIGHT_FIELD"))
250    {
251        dataset->setGeometryType(osgTerrain::DataSet::HEIGHT_FIELD);
252    }
253
254    while (arguments.read("--POLYGONAL"))
255    {
256        dataset->setGeometryType(osgTerrain::DataSet::POLYGONAL);
257    }
258
259    while (arguments.read("--LOD"))
260    {
261        dataset->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE);
262    }
263   
264    while (arguments.read("--PagedLOD"))
265    {
266        dataset->setDatabaseType(osgTerrain::DataSet::PagedLOD_DATABASE);
267    }
268
269    while (arguments.read("--compressed")) { dataset->setTextureType(osgTerrain::DataSet::COMPRESSED_TEXTURE); }
270    while (arguments.read("--RGB_16") || arguments.read("--RGB-16") ) { dataset->setTextureType(osgTerrain::DataSet::RGB_16_BIT); }
271    while (arguments.read("--RGB_24") || arguments.read("--RGB-24") ) { dataset->setTextureType(osgTerrain::DataSet::RGB_24_BIT); }
272
273    while (arguments.read("--no_mip_mapping") || arguments.read("--no-mip-mapping")) { dataset->setMipMappingMode(osgTerrain::DataSet::NO_MIP_MAPPING); }
274    while (arguments.read("--mip_mapping_hardware") || arguments.read("--mip-mapping-hardware")) { dataset->setMipMappingMode(osgTerrain::DataSet::MIP_MAPPING_HARDWARE); }
275    while (arguments.read("--mip_mapping_imagery") || arguments.read("--mip-mapping-imagery")) { dataset->setMipMappingMode(osgTerrain::DataSet::MIP_MAPPING_IMAGERY); }
276
277    float maxAnisotropy;
278    while (arguments.read("--max_anisotropy",maxAnisotropy) || arguments.read("--max-anisotropy",maxAnisotropy))
279    {
280        dataset->setMaxAnisotropy(maxAnisotropy);
281    }
282
283    unsigned int image_size;
284    while (arguments.read("--tile-image-size",image_size)) { dataset->setMaximumTileImageSize(image_size); }
285
286    unsigned int terrain_size;
287    while (arguments.read("--tile-terrain-size",terrain_size)) { dataset->setMaximumTileTerrainSize(terrain_size); }
288
289    std::string comment;
290    while (arguments.read("--comment",comment)) { dataset->setCommentString(comment); }
291
292
293    dataset->setDestinationTileBaseName("output");
294    dataset->setDestinationTileExtension(".ive");
295
296
297    unsigned int numLevels = 10;
298    while (arguments.read("-l",numLevels)) {}
299
300    float verticalScale;
301    while (arguments.read("-v",verticalScale))
302    {
303        dataset->setVerticalScale(verticalScale);
304    }
305
306    float skirtRatio;
307    while (arguments.read("--skirt-ratio",skirtRatio))
308    {
309        dataset->setSkirtRatio(skirtRatio);
310    }
311
312    float maxVisibleDistanceOfTopLevel;
313    while (arguments.read("--max_visible_distance_of_top_level",maxVisibleDistanceOfTopLevel) ||
314          arguments.read("--max-visible-distance-of-top-level",maxVisibleDistanceOfTopLevel) )
315    {
316        dataset->setMaximumVisibleDistanceOfTopLevel(maxVisibleDistanceOfTopLevel);
317    }
318
319    float radiusToMaxVisibleDistanceRatio;
320    while (arguments.read("--radius_to_max_visible_distance_ratio",radiusToMaxVisibleDistanceRatio) ||
321           arguments.read("--radius-to-max-visible-distance-ratio",radiusToMaxVisibleDistanceRatio))
322    {
323        dataset->setRadiusToMaxVisibleDistanceRatio(radiusToMaxVisibleDistanceRatio);
324    }
325
326
327    // if user request help write it out to cout.
328    if (arguments.read("-h") || arguments.read("--help"))
329    {
330        arguments.getApplicationUsage()->write(std::cout);
331        return 1;
332    }
333
334    unsigned int maximumPossibleLevel = 30;
335
336
337    // read the input data
338
339    std::string filename;
340    std::string currentCS;
341    osg::Matrixd geoTransform;
342    bool geoTransformSet = false;
343    bool geoTransformScale = false;
344    double xMin, xMax, yMin, yMax;
345    bool minmaxLevelSet = false;
346    unsigned int min_level=0, max_level=maximumPossibleLevel;
347         
348    int pos = 1;
349    while(pos<arguments.argc())
350    {
351        std::string def;
352
353        if (arguments.read(pos, "--cs",def))
354        {
355            currentCS = !def.empty() ? SanitizeSRS(def.c_str()) : "";
356            std::cout<<"--cs "<<currentCS<<std::endl;
357        }
358        else if (arguments.read(pos, "--wkt",def))
359        {
360            currentCS = def;
361            std::cout<<"--wkt "<<currentCS<<std::endl;
362        }
363        else if (arguments.read(pos, "--wkt-file",def))
364        {
365            std::ifstream in(def.c_str());
366            if (in)
367            {   
368                currentCS = "";
369                while (!in.eof())
370                {
371                    std::string line;
372                    in >> line;
373                    currentCS += line;
374                }
375                std::cout<<"--wkt-file "<<currentCS<<std::endl;
376            }
377        }
378        else if (arguments.read(pos, "--geocentric"))
379        {
380            dataset->setConvertFromGeographicToGeocentric(true);
381            std::cout<<"--geocentric "<<currentCS<<std::endl;
382        }
383
384        else if (arguments.read(pos, "--bluemarble-east"))
385        {
386            currentCS = SanitizeSRS("WGS84");
387            geoTransformSet = true;
388            geoTransformScale = true;
389            geoTransform = computeGeoTransForRange(0.0, 180.0, -90.0, 90.0);
390           
391            dataset->setConvertFromGeographicToGeocentric(true);
392            std::cout<<"--bluemarble-west"<<currentCS<<" matrix="<<geoTransform<<std::endl;
393        }
394
395        else if (arguments.read(pos, "--bluemarble-west"))
396        {
397            currentCS = SanitizeSRS("WGS84");
398            geoTransformSet = true;
399            geoTransformScale = true;
400            geoTransform = computeGeoTransForRange(-180.0, 0.0, -90.0, 90.0);
401           
402            dataset->setConvertFromGeographicToGeocentric(true);
403            std::cout<<"--bluemarble-west "<<currentCS<<" matrix="<<geoTransform<<std::endl;
404        }
405
406        else if (arguments.read(pos, "--whole-globe"))
407        {
408            currentCS = SanitizeSRS("WGS84");
409            geoTransformSet = true;
410            geoTransformScale = true;
411            geoTransform = computeGeoTransForRange(-180.0, 180.0, -90.0, 90.0);
412           
413            dataset->setConvertFromGeographicToGeocentric(true);
414            std::cout<<"--whole-globe "<<currentCS<<" matrix="<<geoTransform<<std::endl;
415        }
416
417        else if (arguments.read(pos, "--range", xMin, xMax, yMin, yMax))
418        {
419            geoTransformSet = true;
420            geoTransformScale = true;
421            geoTransform = computeGeoTransForRange( xMin, xMax, yMin, yMax);
422           
423            std::cout<<"--range, matrix="<<geoTransform<<std::endl;
424        }
425
426        else if (arguments.read(pos, "--identity"))
427        {
428            geoTransformSet = false;
429            geoTransform.makeIdentity();           
430        }
431
432        // x vector
433        else if (arguments.read(pos, "--xx",geoTransform(0,0)))
434        {
435           geoTransformSet = true;
436           geoTransformScale = false;
437            std::cout<<"--xx "<<geoTransform(0,0)<<std::endl;
438        }
439        else if (arguments.read(pos, "--xy",geoTransform(1,0)))
440        {
441            geoTransformSet = true;
442            geoTransformScale = false;
443            std::cout<<"--xy "<<geoTransform(1,0)<<std::endl;
444        }
445        else if (arguments.read(pos, "--xz",geoTransform(2,0)))
446        {
447            geoTransformSet = true;
448            geoTransformScale = false;
449            std::cout<<"--xz "<<geoTransform(2,0)<<std::endl;
450        }
451        else if (arguments.read(pos, "--xt",geoTransform(3,0)))
452        {
453            geoTransformSet = true;
454            geoTransformScale = false;
455            std::cout<<"--xo "<<geoTransform(3,0)<<std::endl;
456        }
457
458        // y vector
459        else if (arguments.read(pos, "--yx",geoTransform(0,1)))
460        {
461            geoTransformSet = true;
462            geoTransformScale = false;
463            std::cout<<"--yx "<<geoTransform(0,1)<<std::endl;
464        }
465        else if (arguments.read(pos, "--yy",geoTransform(1,1)))
466        {
467            geoTransformSet = true;
468            geoTransformScale = false;
469            std::cout<<"--yy "<<geoTransform(1,1)<<std::endl;
470        }
471        else if (arguments.read(pos, "--yz",geoTransform(2,1)))
472        {
473            geoTransformSet = true;
474            geoTransformScale = false;
475            std::cout<<"--yz "<<geoTransform(2,1)<<std::endl;
476        }
477        else if (arguments.read(pos, "--yt",geoTransform(3,1)))
478        {
479            geoTransformSet = true;
480            geoTransformScale = false;
481            std::cout<<"--yt "<<geoTransform(3,1)<<std::endl;
482        }
483
484        // z vector
485        else if (arguments.read(pos, "--zx",geoTransform(0,2)))
486        {
487            geoTransformSet = true;
488            geoTransformScale = false;
489            std::cout<<"--zx "<<geoTransform(0,2)<<std::endl;
490        }
491        else if (arguments.read(pos, "--zy",geoTransform(1,2)))
492        {
493            geoTransformSet = true;
494            geoTransformScale = false;
495            std::cout<<"--zy "<<geoTransform(1,2)<<std::endl;
496        }
497        else if (arguments.read(pos, "--zz",geoTransform(2,2)))
498        {
499            geoTransformSet = true;
500            geoTransformScale = false;
501            std::cout<<"--zz "<<geoTransform(2,2)<<std::endl;
502        }
503        else if (arguments.read(pos, "--zt",geoTransform(3,2)))
504        {
505            geoTransformSet = true;
506            geoTransformScale = false;
507            std::cout<<"--zt "<<geoTransform(3,2)<<std::endl;
508        }
509
510        else if (arguments.read(pos, "--levels", min_level, max_level))
511        {
512            minmaxLevelSet = true;
513            std::cout<<"--levels, min_level="<<min_level<<"  max_level="<<max_level<<std::endl;
514        }
515
516        else if (arguments.read(pos, "-d",filename))
517        {
518            std::cout<<"-d "<<filename<<std::endl;
519            processFile(filename, osgTerrain::DataSet::Source::HEIGHT_FIELD, currentCS,
520                        geoTransform, geoTransformSet, geoTransformScale,
521                        minmaxLevelSet, min_level, max_level,
522                        dataset);
523
524            minmaxLevelSet = false;
525            min_level=0; max_level=maximumPossibleLevel;
526           
527            currentCS = "";
528            geoTransformSet = false;
529            geoTransformScale = false;
530            geoTransform.makeIdentity();           
531        }
532        else if (arguments.read(pos, "-t",filename))
533        {
534            std::cout<<"-t "<<filename<<std::endl;
535            processFile(filename, osgTerrain::DataSet::Source::IMAGE, currentCS,
536                        geoTransform, geoTransformSet, geoTransformScale,
537                        minmaxLevelSet, min_level, max_level,
538                        dataset);
539
540            minmaxLevelSet = false;
541            min_level=0; max_level=maximumPossibleLevel;
542           
543            currentCS = "";
544            geoTransformSet = false;
545            geoTransformScale = false;
546            geoTransform.makeIdentity();           
547        }
548        else if (arguments.read(pos, "-m",filename))
549        {
550            std::cout<<"-m "<<filename<<std::endl;
551            processFile(filename, osgTerrain::DataSet::Source::MODEL, currentCS, geoTransform, geoTransformSet, geoTransformScale, minmaxLevelSet, min_level, max_level, dataset);
552
553            minmaxLevelSet = false;
554            min_level=0; max_level=maximumPossibleLevel;
555           
556            currentCS = "";
557            geoTransformSet = false;
558            geoTransformScale = false;
559            geoTransform.makeIdentity();           
560        }
561        else if (arguments.read(pos, "-o",filename))
562        {
563            std::cout<<"-o "<<filename<<std::endl;
564
565            std::string path = osgDB::getFilePath(filename);
566            std::string base = path.empty()?osgDB::getStrippedName(filename):
567                                            path +'/'+ osgDB::getStrippedName(filename);
568            std::string extension = '.'+osgDB::getLowerCaseFileExtension(filename);
569
570            dataset->setDestinationTileBaseName(base);
571            dataset->setDestinationTileExtension(extension);
572           
573            if (!currentCS.empty()) dataset->setDestinationCoordinateSystem(currentCS);
574
575            minmaxLevelSet = false;
576            min_level=0; max_level=maximumPossibleLevel;
577           
578            currentCS = "";
579            geoTransformSet = false;
580            geoTransformScale = false;
581            geoTransform.makeIdentity();           
582
583        }
584        else
585        {
586            // if no argument read advance to next argument.
587            ++pos;
588        }
589    }
590   
591    // any option left unread are converted into errors to write out later.
592    arguments.reportRemainingOptionsAsUnrecognized();
593
594    // report any errors if they have occured when parsing the program aguments.
595    if (arguments.errors())
596    {
597        arguments.writeErrorMessages(std::cout);
598        return 1;
599    }
600   
601    // generate the database
602    {
603        GraphicsContext context;
604
605        dataset->loadSources();
606
607        dataset->createDestination((unsigned int)numLevels);
608
609        dataset->writeDestination();       
610    }
611
612    return 0;
613}
Note: See TracBrowser for help on using the browser.