本文整理汇总了C++中osg::ArgumentParser类的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser类的具体用法?C++ ArgumentParser怎么用?C++ ArgumentParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArgumentParser类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: makeTMS
/** Packages an image layer as a TMS folder. */
int
makeTMS( osg::ArgumentParser& args )
{
osgDB::Registry::instance()->getReaderWriterForExtension("png");
osgDB::Registry::instance()->getReaderWriterForExtension("jpg");
osgDB::Registry::instance()->getReaderWriterForExtension("tiff");
//Read the min level
unsigned int minLevel = 0;
while (args.read("--min-level", minLevel));
//Read the max level
unsigned int maxLevel = 5;
while (args.read("--max-level", maxLevel));
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
std::string tileList;
while (args.read( "--tiles", tileList ) );
bool verbose = args.read("--verbose");
unsigned int batchSize = 0;
args.read("--batchsize", batchSize);
// Read the concurrency level
unsigned int concurrency = 0;
args.read("-c", concurrency);
args.read("--concurrency", concurrency);
bool writeXML = true;
// load up the map
osg::ref_ptr<MapNode> mapNode = MapNode::load( args );
if( !mapNode.valid() )
return usage( "Failed to load a valid .earth file" );
// Read in an index shapefile
std::string index;
while (args.read("--index", index))
{
//Open the feature source
OGRFeatureOptions featureOpt;
featureOpt.url() = index;
osg::ref_ptr< FeatureSource > features = FeatureSourceFactory::create( featureOpt );
features->initialize();
features->getFeatureProfile();
osg::ref_ptr< FeatureCursor > cursor = features->createFeatureCursor();
while (cursor.valid() && cursor->hasMore())
{
osg::ref_ptr< Feature > feature = cursor->nextFeature();
osgEarth::Bounds featureBounds = feature->getGeometry()->getBounds();
GeoExtent ext( feature->getSRS(), featureBounds );
ext = ext.transform( mapNode->getMapSRS() );
bounds.push_back( ext.bounds() );
}
}
// see if the user wants to override the type extension (imagery only)
std::string extension;
args.read( "--ext", extension );
// find a .earth file on the command line
std::string earthFile = findArgumentWithExtension( args, ".earth" );
// folder to which to write the TMS archive.
std::string rootFolder;
if( !args.read( "--out", rootFolder ) )
rootFolder = Stringify() << earthFile << ".tms_repo";
// whether to overwrite existing tile files
//TODO: Support
bool overwrite = false;
if( args.read( "--overwrite" ) )
overwrite = true;
// write out an earth file
std::string outEarth;
args.read( "--out-earth", outEarth );
std::string dbOptions;
args.read( "--db-options", dbOptions );
std::string::size_type n = 0;
while( (n = dbOptions.find( '"', n )) != dbOptions.npos )
{
dbOptions.erase( n, 1 );
}
//.........这里部分代码省略.........
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:101,代码来源:osgearth_package.cpp
示例2: seed
int
seed( osg::ArgumentParser& args )
{
osgDB::Registry::instance()->getReaderWriterForExtension("png");
osgDB::Registry::instance()->getReaderWriterForExtension("jpg");
osgDB::Registry::instance()->getReaderWriterForExtension("tiff");
//Read the min level
int minLevel = -1;
while (args.read("--min-level", minLevel));
//Read the max level
int maxLevel = -1;
while (args.read("--max-level", maxLevel));
bool estimate = args.read("--estimate");
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
std::string tileList;
while (args.read( "--tiles", tileList ) );
bool verbose = args.read("--verbose");
unsigned int batchSize = 0;
args.read("--batchsize", batchSize);
// Read the concurrency level
unsigned int concurrency = 0;
args.read("-c", concurrency);
args.read("--concurrency", concurrency);
int imageLayerIndex = -1;
args.read("--image", imageLayerIndex);
int elevationLayerIndex = -1;
args.read("--elevation", elevationLayerIndex);
//Read in the earth file.
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
// Read in an index shapefile
std::string index;
while (args.read("--index", index))
{
//Open the feature source
OGRFeatureOptions featureOpt;
featureOpt.url() = index;
osg::ref_ptr< FeatureSource > features = FeatureSourceFactory::create( featureOpt );
Status status = features->open();
if (status.isOK())
{
osg::ref_ptr< FeatureCursor > cursor = features->createFeatureCursor(0L);
while (cursor.valid() && cursor->hasMore())
{
osg::ref_ptr< Feature > feature = cursor->nextFeature();
osgEarth::Bounds featureBounds = feature->getGeometry()->getBounds();
GeoExtent ext( feature->getSRS(), featureBounds );
ext = ext.transform( mapNode->getMapSRS() );
bounds.push_back( ext.bounds() );
}
}
else
{
OE_WARN << status.message() << "\n";
}
}
// If they requested to do an estimate then don't do the seed, just print out the estimated values.
if (estimate)
{
CacheEstimator est;
if ( minLevel >= 0 )
est.setMinLevel( minLevel );
if ( maxLevel >= 0 )
est.setMaxLevel( maxLevel );
est.setProfile( mapNode->getMap()->getProfile() );
for (unsigned int i = 0; i < bounds.size(); i++)
{
GeoExtent extent(mapNode->getMapSRS(), bounds[i]);
OE_DEBUG << "Adding extent " << extent.toString() << std::endl;
//.........这里部分代码省略.........
开发者ID:aroth-fastprotect,项目名称:osgearth,代码行数:101,代码来源:osgearth_seed.cpp
示例3: mainAdapterWidget
int mainAdapterWidget(QApplication& a, osg::ArgumentParser& arguments)
{
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
std::cout << arguments[0] <<": No data loaded." << std::endl;
return 1;
}
std::cout<<"Using AdapterWidget - QGLWidget subclassed to integrate with osgViewer using its embedded graphics window support."<<std::endl;
if (arguments.read("--CompositeViewer"))
{
CompositeViewerQT* viewerWindow = new CompositeViewerQT;
unsigned int width = viewerWindow->width();
unsigned int height = viewerWindow->height();
{
osgViewer::View* view1 = new osgViewer::View;
view1->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
view1->getCamera()->setViewport(new osg::Viewport(0,0,width,height/2));
view1->setCameraManipulator(new osgGA::TrackballManipulator);
view1->setSceneData(loadedModel.get());
viewerWindow->addView(view1);
}
{
osgViewer::View* view2 = new osgViewer::View;
view2->getCamera()->setGraphicsContext(viewerWindow->getGraphicsWindow());
view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height/2), 1.0, 1000.0);
view2->getCamera()->setViewport(new osg::Viewport(0,height/2,width,height/2));
view2->setCameraManipulator(new osgGA::TrackballManipulator);
view2->setSceneData(loadedModel.get());
viewerWindow->addView(view2);
}
viewerWindow->show();
}
else if (arguments.read("--mdi")) {
std::cout<<"Using ViewetQT MDI version"<<std::endl;
/*
Following problems are found here:
- miminize causes loaded model to disappear (some problem with Camera matrix? - clampProjectionMatrix is invalid)
*/
ViewerQT* viewerWindow = new ViewerQT;
viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator);
viewerWindow->setSceneData(loadedModel.get());
QMainWindow* mw = new QMainWindow();
QMdiArea* mdiArea = new QMdiArea(mw);
mw->setCentralWidget(mdiArea);
QMdiSubWindow *subWindow = mdiArea->addSubWindow(viewerWindow);
subWindow->showMaximized();
subWindow->setWindowTitle("New Window");
mw->show();
} else {
ViewerQT* viewerWindow = new ViewerQT;
viewerWindow->setCameraManipulator(new osgGA::TrackballManipulator);
viewerWindow->setSceneData(loadedModel.get());
viewerWindow->show();
}
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
return a.exec();
}
开发者ID:hywei,项目名称:PatchEditor,代码行数:75,代码来源:AdapterWidget.cpp
示例4: VBox
void
MapNodeHelper::parse(MapNode* mapNode,
osg::ArgumentParser& args,
osgViewer::View* view,
osg::Group* root,
Control* userControl ) const
{
if ( !root )
root = mapNode;
// parse out custom example arguments first:
bool useSky = args.read("--sky");
bool useOcean = args.read("--ocean");
bool useMGRS = args.read("--mgrs");
bool useDMS = args.read("--dms");
bool useDD = args.read("--dd");
bool useCoords = args.read("--coords") || useMGRS || useDMS || useDD;
std::string kmlFile;
args.read( "--kml", kmlFile );
// install a canvas for any UI controls we plan to create:
ControlCanvas* canvas = ControlCanvas::get(view, false);
Container* mainContainer = canvas->addControl( new VBox() );
mainContainer->setBackColor( Color(Color::Black, 0.8) );
mainContainer->setHorizAlign( Control::ALIGN_LEFT );
mainContainer->setVertAlign( Control::ALIGN_BOTTOM );
// install the user control:
if ( userControl )
mainContainer->addControl( userControl );
// look for external data in the map node:
const Config& externals = mapNode->externalConfig();
const Config& skyConf = externals.child("sky");
const Config& oceanConf = externals.child("ocean");
const Config& annoConf = externals.child("annotations");
const Config& declutterConf = externals.child("decluttering");
Config viewpointsConf = externals.child("viewpoints");
// backwards-compatibility: read viewpoints at the top level:
const ConfigSet& old_viewpoints = externals.children("viewpoint");
for( ConfigSet::const_iterator i = old_viewpoints.begin(); i != old_viewpoints.end(); ++i )
viewpointsConf.add( *i );
// Loading a viewpoint list from the earth file:
if ( !viewpointsConf.empty() )
{
std::vector<Viewpoint> viewpoints;
const ConfigSet& children = viewpointsConf.children();
if ( children.size() > 0 )
{
for( ConfigSet::const_iterator i = children.begin(); i != children.end(); ++i )
{
viewpoints.push_back( Viewpoint(*i) );
}
}
if ( viewpoints.size() > 0 )
{
Control* c = ViewpointControlFactory().create(viewpoints, view);
if ( c )
mainContainer->addControl( c );
}
}
// Adding a sky model:
if ( useSky || !skyConf.empty() )
{
double hours = skyConf.value( "hours", 12.0 );
SkyNode* sky = new SkyNode( mapNode->getMap() );
sky->setDateTime( 2011, 3, 6, hours );
sky->attach( view );
root->addChild( sky );
Control* c = SkyControlFactory().create(sky, view);
if ( c )
mainContainer->addControl( c );
}
// Adding an ocean model:
if ( useOcean || !oceanConf.empty() )
{
OceanSurfaceNode* ocean = new OceanSurfaceNode( mapNode, oceanConf );
if ( ocean )
{
root->addChild( ocean );
Control* c = OceanControlFactory().create(ocean, view);
if ( c )
mainContainer->addControl(c);
}
}
// Loading KML from the command line:
if ( !kmlFile.empty() )
{
//.........这里部分代码省略.........
开发者ID:airwzz999,项目名称:osgearth-for-android,代码行数:101,代码来源:ExampleResources.cpp
示例5: constructorInit
CompositeViewer::CompositeViewer(osg::ArgumentParser& arguments)
{
constructorInit();
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--run-on-demand","Set the run methods frame rate management to only rendering frames when required.");
arguments.getApplicationUsage()->addCommandLineOption("--run-continuous","Set the run methods frame rate management to rendering frames continuously.");
arguments.getApplicationUsage()->addCommandLineOption("--run-max-frame-rate","Set the run methods maximum permissible frame rate, 0.0 is default and switching off frame rate capping.");
std::string filename;
bool readConfig = false;
while (arguments.read("-c",filename))
{
readConfig = readConfiguration(filename) || readConfig;
}
while (arguments.read("--SingleThreaded")) setThreadingModel(SingleThreaded);
while (arguments.read("--CullDrawThreadPerContext")) setThreadingModel(CullDrawThreadPerContext);
while (arguments.read("--DrawThreadPerContext")) setThreadingModel(DrawThreadPerContext);
while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) setThreadingModel(CullThreadPerCameraDrawThreadPerContext);
while(arguments.read("--run-on-demand")) { setRunFrameScheme(ON_DEMAND); }
while(arguments.read("--run-continuous")) { setRunFrameScheme(CONTINUOUS); }
double runMaxFrameRate;
while(arguments.read("--run-max-frame-rate", runMaxFrameRate)) { setRunMaxFrameRate(runMaxFrameRate); }
osg::DisplaySettings::instance()->readCommandLine(arguments);
osgDB::readCommandLine(arguments);
}
开发者ID:cjslep,项目名称:osg,代码行数:37,代码来源:CompositeViewer.cpp
示例6: seed
int
seed( osg::ArgumentParser& args )
{
//Read the min level
unsigned int minLevel = 0;
while (args.read("--min-level", minLevel));
//Read the max level
unsigned int maxLevel = 5;
while (args.read("--max-level", maxLevel));
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
//Read the cache override directory
std::string cachePath;
while (args.read("--cache-path", cachePath));
//Read the cache type
std::string cacheType;
while (args.read("--cache-type", cacheType));
bool verbose = args.read("--verbose");
//Read in the earth file.
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
CacheSeed seeder;
seeder.setMinLevel( minLevel );
seeder.setMaxLevel( maxLevel );
// Read in an index shapefile
std::string index;
while (args.read("--index", index))
{
//Open the feature source
OGRFeatureOptions featureOpt;
featureOpt.url() = index;
osg::ref_ptr< FeatureSource > features = FeatureSourceFactory::create( featureOpt );
features->initialize();
features->getFeatureProfile();
osg::ref_ptr< FeatureCursor > cursor = features->createFeatureCursor();
while (cursor.valid() && cursor->hasMore())
{
osg::ref_ptr< Feature > feature = cursor->nextFeature();
osgEarth::Bounds featureBounds = feature->getGeometry()->getBounds();
GeoExtent ext( feature->getSRS(), featureBounds );
ext = ext.transform( mapNode->getMapSRS() );
bounds.push_back( ext.bounds() );
}
}
for (unsigned int i = 0; i < bounds.size(); i++)
{
GeoExtent extent(mapNode->getMapSRS(), bounds[i]);
OE_DEBUG << "Adding extent " << extent.toString() << std::endl;
seeder.addExtent( extent );
}
if (verbose)
{
seeder.setProgressCallback(new ConsoleProgressCallback);
}
osg::Timer_t start = osg::Timer::instance()->tick();
seeder.seed( mapNode->getMap() );
osg::Timer_t end = osg::Timer::instance()->tick();
OE_NOTICE << "Completed seeding in " << prettyPrintTime( osg::Timer::instance()->delta_s( start, end ) ) << std::endl;
return 0;
}
开发者ID:progame127,项目名称:osgearth,代码行数:91,代码来源:osgearth_seed.cpp
示例7: build
int
build(osg::ArgumentParser& arguments)
{
// the input resource catalog XML file:
std::string inCatalogPath;
if ( !arguments.read("--build", inCatalogPath) )
return usage("Missing required argument catalog file");
// the output texture atlas image path:
std::string inCatalogFile = osgDB::getSimpleFileName(inCatalogPath);
std::string outImageFile = osgDB::getNameLessExtension(inCatalogFile) + "_atlas.osgb";
// the output catalog file describing the texture atlas contents:
std::string outCatalogFile;
outCatalogFile = outImageFile + ".xml";
// check that the input file exists:
if ( !osgDB::fileExists(inCatalogPath) )
return usage("Input file not found");
// open the resource library.
osg::ref_ptr<osgEarth::Symbology::ResourceLibrary> lib =
new osgEarth::Symbology::ResourceLibrary("unnamed", inCatalogPath);
if ( !lib->initialize(0L) )
return usage("Error loading input catalog file");
// build the atlas.
osgEarth::Util::AtlasBuilder builder;
osgEarth::Util::AtlasBuilder::Atlas atlas;
// max x/y dimensions:
unsigned size;
if ( arguments.read("--size", size) )
builder.setSize( size, size );
// auxiliary atlas patterns:
std::string pattern;
while(arguments.read("--aux", pattern))
builder.addAuxFilePattern(pattern);
if ( !builder.build(lib.get(), outImageFile, atlas) )
return usage("Failed to build atlas");
// write the atlas images.
osgDB::writeImageFile(*atlas._images.begin()->get(), outImageFile);
OE_INFO << LC << "Wrote output image to \"" << outImageFile << "\"" << std::endl;
// write any aux images.
const std::vector<std::string>& auxPatterns = builder.auxFilePatterns();
for(unsigned i=0; i<auxPatterns.size(); ++i)
{
std::string auxAtlasFile =
osgDB::getNameLessExtension(outImageFile) +
"_" + auxPatterns[i] + "." +
osgDB::getFileExtension(outImageFile);
osgDB::writeImageFile(*atlas._images[i+1].get(), auxAtlasFile);
OE_INFO << LC << "Wrote auxiliary image to \"" << auxAtlasFile << "\"" << std::endl;
}
// write the new catalog:
osgEarth::XmlDocument catXML( atlas._lib->getConfig() );
std::ofstream catOut(outCatalogFile.c_str());
if ( !catOut.is_open() )
return usage("Failed to open output catalog file for writing");
catXML.store(catOut);
catOut.close();
OE_INFO << LC << "Wrote output catalog to \"" << outCatalogFile<< "\"" << std::endl;
}
开发者ID:energonQuest,项目名称:dtEarth,代码行数:74,代码来源:osgearth_atlas.cpp
示例8: makeTMS
/** Packages an image layer as a TMS folder. */
int
makeTMS( osg::ArgumentParser& args )
{
// see if the user wants to override the type extension (imagery only)
std::string extension;
args.read( "--ext", extension );
// verbosity?
bool verbose = !args.read( "--quiet" );
// find a .earth file on the command line
std::string earthFile = findArgumentWithExtension(args, ".earth");
/* if ( earthFile.empty() )
return usage( "Missing required .earth file" );
*/
// folder to which to write the TMS archive.
std::string rootFolder;
if ( !args.read( "--out", rootFolder ) )
rootFolder = Stringify() << earthFile << ".tms_repo";
// whether to overwrite existing tile files
bool overwrite = false;
if ( args.read("--overwrite") )
overwrite = true;
// write out an earth file
std::string outEarth;
args.read("--out-earth", outEarth);
std::string dbOptions;
args.read("--db-options", dbOptions);
std::string::size_type n = 0;
while ((n=dbOptions.find('"', n))!=dbOptions.npos)
{
dbOptions.erase(n,1);
}
osg::ref_ptr<osgDB::Options> options = new osgDB::Options(dbOptions);
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
// max level to which to generate
unsigned maxLevel = ~0;
args.read( "--max-level", maxLevel );
// whether to keep 'empty' tiles
bool keepEmpties = args.read("--keep-empties");
bool continueSingleColor = args.read("--continue-single-color");
// load up the map
osg::ref_ptr<MapNode> mapNode = MapNode::load( args );
if ( !mapNode.valid() )
return usage( "Failed to load a valid .earth file" );
// create a folder for the output
osgDB::makeDirectory(rootFolder);
if ( !osgDB::fileExists(rootFolder) )
return usage("Failed to create root output folder" );
Map* map = mapNode->getMap();
// fire up a packager:
TMSPackager packager( map->getProfile(), options);
packager.setVerbose( verbose );
packager.setOverwrite( overwrite );
packager.setKeepEmptyImageTiles( keepEmpties );
packager.setSubdivideSingleColorImageTiles( continueSingleColor );
if ( maxLevel != ~0 )
packager.setMaxLevel( maxLevel );
if (bounds.size() > 0)
{
for (unsigned int i = 0; i < bounds.size(); ++i)
{
Bounds b = bounds[i];
if ( b.isValid() )
packager.addExtent( GeoExtent(map->getProfile()->getSRS(), b) );
}
}
// new map for an output earth file if necessary.
osg::ref_ptr<Map> outMap = 0L;
if ( !outEarth.empty() )
{
// copy the options from the source map first
outMap = new Map(map->getInitialMapOptions());
//.........这里部分代码省略.........
开发者ID:APerennec,项目名称:osgearth,代码行数:101,代码来源:osgearth_package.cpp
示例9: notify
Viewer::Viewer(osg::ArgumentParser& arguments)
{
_viewerBase = this;
constructorInit();
// Add help for command-line options read here
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--clear-color <color>","Set the background color of the viewer in the form \"r,g,b[,a]\".");
arguments.getApplicationUsage()->addCommandLineOption("--screen <num>","Set the screen to use when multiple screens are present.");
arguments.getApplicationUsage()->addCommandLineOption("--window <x y w h>","Set the position (x,y) and size (w,h) of the viewer window.");
// FIXME: Uncomment these lines when the options have been documented properly
//arguments.getApplicationUsage()->addCommandLineOption("--3d-sd","");
//arguments.getApplicationUsage()->addCommandLineOption("--panoramic-sd","");
//arguments.getApplicationUsage()->addCommandLineOption("--radius","");
//arguments.getApplicationUsage()->addCommandLineOption("--collar","");
//arguments.getApplicationUsage()->addCommandLineOption("--im","");
std::string filename;
bool readConfig = false;
while (arguments.read("-c",filename))
{
readConfig = readConfiguration(filename) || readConfig;
}
while (arguments.read("--SingleThreaded")) setThreadingModel(SingleThreaded);
while (arguments.read("--CullDrawThreadPerContext")) setThreadingModel(CullDrawThreadPerContext);
while (arguments.read("--DrawThreadPerContext")) setThreadingModel(DrawThreadPerContext);
while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) setThreadingModel(CullThreadPerCameraDrawThreadPerContext);
osg::DisplaySettings::instance()->readCommandLine(arguments);
osgDB::readCommandLine(arguments);
std::string colorStr;
while (arguments.read("--clear-color",colorStr))
{
float r, g, b;
float a = 1.0f;
int cnt = sscanf( colorStr.c_str(), "%f,%f,%f,%f", &r, &g, &b, &a );
if( cnt==3 || cnt==4 ) getCamera()->setClearColor( osg::Vec4(r,g,b,a) );
else osg::notify(osg::WARN)<<"Invalid clear color \""<<colorStr<<"\""<<std::endl;
}
int screenNum = -1;
while (arguments.read("--screen",screenNum)) {}
int x = -1, y = -1, width = -1, height = -1;
while (arguments.read("--window",x,y,width,height)) {}
bool ss3d = false;
bool wowvx20 = false;
bool wowvx42 = false;
if ((wowvx20=arguments.read("--wowvx-20")) || (wowvx42=arguments.read("--wowvx-42")) || arguments.read("--wowvx"))
{
int wow_content=0x02, wow_factor=0x40, wow_offset=0x80;
float wow_Zd, wow_vz, wow_M, wow_C;
if (wowvx20){
wow_Zd = 0.459813f;
wow_vz = 6.180772f;
wow_M = -1586.34f;
wow_C = 127.5f;
}
else if (wowvx42){
wow_Zd = 0.467481f;
wow_vz = 7.655192f;
wow_M = -1960.37f;
wow_C = 127.5f;
}
while (arguments.read("--wow-content",wow_content)) {}
while (arguments.read("--wow-factor",wow_factor)) {}
while (arguments.read("--wow-offset",wow_offset)) {}
while (arguments.read("--wow-zd",wow_Zd)) {}
while (arguments.read("--wow-vz",wow_vz)) {}
while (arguments.read("--wow-M",wow_M)) {}
while (arguments.read("--wow-C",wow_C)) {}
if (screenNum<0) screenNum = 0;
setUpViewForWoWVxDisplay( screenNum, wow_content, wow_factor, wow_offset, wow_Zd, wow_vz, wow_M, wow_C );
}
else if ((ss3d=arguments.read("--3d-sd")) || arguments.read("--panoramic-sd"))
{
double radius = 1.0;
while (arguments.read("--radius",radius)) {}
double collar = 0.45;
while (arguments.read("--collar",collar)) {}
std::string intensityMapFilename;
while (arguments.read("--im",intensityMapFilename)) {}
osg::ref_ptr<osg::Image> intensityMap = intensityMapFilename.empty() ? 0 : osgDB::readImageFile(intensityMapFilename);
if (screenNum<0) screenNum = 0;
if (ss3d)
//.........这里部分代码省略.........
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:101,代码来源:Viewer.cpp
示例10: makeTMS
/** Packages an image layer as a TMS folder. */
int
makeTMS( osg::ArgumentParser& args )
{
// see if the user wants to override the type extension (imagery only)
std::string extension = "png";
args.read( "--ext", extension );
// verbosity?
bool verbose = !args.read( "--quiet" );
// find a .earth file on the command line
std::string earthFile = findArgumentWithExtension(args, ".earth");
if ( earthFile.empty() )
return usage( "Missing required .earth file" );
// folder to which to write the TMS archive.
std::string rootFolder;
if ( !args.read( "--out", rootFolder ) )
rootFolder = Stringify() << earthFile << ".tms_repo";
// max level to which to generate
unsigned maxLevel = ~0;
args.read( "--max-level", maxLevel );
// load up the map
osg::ref_ptr<MapNode> mapNode = MapNode::load( args );
if ( !mapNode.valid() )
return usage( "Failed to load a valid .earth file" );
// create a folder for the output
osgDB::makeDirectory(rootFolder);
if ( !osgDB::fileExists(rootFolder) )
return usage("Failed to create root output folder" );
Map* map = mapNode->getMap();
// fire up a packager:
TMSPackager packager( map->getProfile() );
packager.setVerbose( verbose );
if ( maxLevel != ~0 )
packager.setMaxLevel( maxLevel );
// package any image layers that are enabled:
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
unsigned counter = 0;
for( ImageLayerVector::iterator i = imageLayers.begin(); i != imageLayers.end(); ++i, ++counter )
{
ImageLayer* layer = i->get();
if ( layer->getImageLayerOptions().enabled() == true )
{
std::string layerFolder = toLegalFileName( layer->getName() );
if ( layerFolder.empty() )
layerFolder = Stringify() << "image_layer_" << counter;
if ( verbose )
{
OE_NOTICE << LC << "Packaging image layer \"" << layerFolder << "\"" << std::endl;
}
std::string layerRoot = osgDB::concatPaths( rootFolder, layerFolder );
TMSPackager::Result r = packager.package( layer, layerRoot, extension );
if ( !r.ok )
{
OE_WARN << LC << r.message << std::endl;
}
}
else if ( verbose )
{
OE_NOTICE << LC << "Skipping disabled layer \"" << layer->getName() << "\"" << std::endl;
}
}
// package any elevation layers that are enabled:
counter = 0;
ElevationLayerVector elevationLayers;
map->getElevationLayers( elevationLayers );
for( ElevationLayerVector::iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i, ++counter )
{
ElevationLayer* layer = i->get();
if ( layer->getElevationLayerOptions().enabled() == true )
{
std::string layerFolder = toLegalFileName( layer->getName() );
if ( layerFolder.empty() )
layerFolder = Stringify() << "elevation_layer_" << counter;
if ( verbose )
{
OE_NOTICE << LC << "Packaging elevation layer \"" << layerFolder << "\"" << std::endl;
}
std::string layerRoot = osgDB::concatPaths( rootFolder, layerFolder );
packager.package( layer, layerRoot );
}
else if ( verbose )
//.........这里部分代码省略.........
开发者ID:mysticbob,项目名称:osgearth,代码行数:101,代码来源:osgearth_package.cpp
示例11: if
void
MapNodeHelper::parse(MapNode* mapNode,
osg::ArgumentParser& args,
osgViewer::View* view,
osg::Group* root,
Container* userContainer ) const
{
if ( !root )
root = mapNode;
// options to use for the load
osg::ref_ptr<osgDB::Options> dbOptions = Registry::instance()->cloneOrCreateOptions();
// parse out custom example arguments first:
bool useMGRS = args.read("--mgrs");
bool useDMS = args.read("--dms");
bool useDD = args.read("--dd");
bool useCoords = args.read("--coords") || useMGRS || useDMS || useDD;
bool useAutoClip = args.read("--autoclip");
bool showActivity = args.read("--activity");
bool useLogDepth = args.read("--logdepth");
bool useLogDepth2 = args.read("--logdepth2");
bool kmlUI = args.read("--kmlui");
std::string kmlFile;
args.read( "--kml", kmlFile );
std::string imageFolder;
args.read( "--images", imageFolder );
std::string imageExtensions;
args.read("--image-extensions", imageExtensions);
// animation path:
std::string animpath;
if ( args.read("--path", animpath) )
{
view->setCameraManipulator( new osgGA::AnimationPathManipulator(animpath) );
}
// Install a new Canvas for our UI controls, or use one that already exists.
ControlCanvas* canvas = ControlCanvas::getOrCreate( view );
Container* mainContainer;
if ( userContainer )
{
mainContainer = userContainer;
}
else
{
mainContainer = new VBox();
mainContainer->setAbsorbEvents( true );
mainContainer->setBackColor( Color(Color::Black, 0.8) );
mainContainer->setHorizAlign( Control::ALIGN_LEFT );
mainContainer->setVertAlign( Control::ALIGN_BOTTOM );
}
canvas->addControl( mainContainer );
// Add an event handler to toggle the canvas with a key press;
view->addEventHandler(new ToggleCanvasEventHandler(canvas, 'y'));
// look for external data in the map node:
const Config& externals = mapNode->externalConfig();
// some terrain effects.
// TODO: Most of these are likely to move into extensions.
const Config& vertScaleConf = externals.child("vertical_scale");
// Loading KML from the command line:
if ( !kmlFile.empty() )
{
KMLOptions kml_options;
kml_options.declutter() = true;
// set up a default icon for point placemarks:
IconSymbol* defaultIcon = new IconSymbol();
defaultIcon->url()->setLiteral(KML_PUSHPIN_URL);
kml_options.defaultIconSymbol() = defaultIcon;
TextSymbol* defaultText = new TextSymbol();
defaultText->halo() = Stroke(0.3,0.3,0.3,1.0);
kml_options.defaultTextSymbol() = defaultText;
osg::Node* kml = KML::load( URI(kmlFile), mapNode, kml_options );
if ( kml )
{
if (kmlUI)
{
Control* c = AnnotationGraphControlFactory().create(kml, view);
if ( c )
{
c->setVertAlign( Control::ALIGN_TOP );
canvas->addControl( c );
}
}
root->addChild( kml );
}
else
{
//.........这里部分代码省略.........
开发者ID:ldelgass,项目名称:osgearth,代码行数:101,代码来源:ExampleResources.cpp
示例12: VBox
void
MapNodeHelper::parse(MapNode* mapNode,
osg::ArgumentParser& args,
osgViewer::View* view,
osg::Group* root,
Control* userControl ) const
{
// this is a dubious move.
if ( !root )
root = mapNode;
// options to use for the load
osg::ref_ptr<osgDB::Options> dbOptions = Registry::instance()->cloneOrCreateOptions();
// parse out custom example arguments first:
bool useSky = args.read("--sky");
bool useOcean = args.read("--ocean");
bool useMGRS = args.read("--mgrs");
bool useDMS = args.read("--dms");
bool useDD = args.read("--dd");
bool useCoords = args.read("--coords") || useMGRS || useDMS || useDD;
bool useOrtho = args.read("--ortho");
bool useAutoClip = args.read("--autoclip");
float ambientBrightness = 0.4f;
args.read("--ambientBrightness", ambientBrightness);
std::string kmlFile;
args.read( "--kml", kmlFile );
// install a canvas for any UI controls we plan to create:
ControlCanvas* canvas = ControlCanvas::get(view, false);
Container* mainContainer = canvas->addControl( new VBox() );
mainContainer->setBackColor( Color(Color::Black, 0.8) );
mainContainer->setHorizAlign( Control::ALIGN_LEFT );
mainContainer->setVertAlign( Control::ALIGN_BOTTOM );
// install the user control:
if ( userControl )
mainContainer->addControl( userControl );
// look for external data in the map node:
const Config& externals = mapNode->externalConfig();
const Config& skyConf = externals.child("sky");
const Config& oceanConf = externals.child("ocean");
const Config& annoConf = externals.child("annotations");
const Config& declutterConf = externals.child("decluttering");
Config viewpointsConf = externals.child("viewpoints");
// backwards-compatibility: read viewpoints at the top level:
const ConfigSet& old_viewpoints = externals.children("viewpoint");
for( ConfigSet::const_iterator i = old_viewpoints.begin(); i != old_viewpoints.end(); ++i )
viewpointsConf.add( *i );
// Loading a viewpoint list from the earth file:
if ( !viewpointsConf.empty() )
{
std::vector<Viewpoint> viewpoints;
const ConfigSet& children = viewpointsConf.children();
if ( children.size() > 0 )
{
for( ConfigSet::const_iterator i = children.begin(); i != children.end(); ++i )
{
viewpoints.push_back( Viewpoint(*i) );
}
}
if ( viewpoints.size() > 0 )
{
Control* c = ViewpointControlFactory().create(viewpoints, view);
if ( c )
mainContainer->addControl( c );
}
}
// Adding a sky model:
if ( useSky || !skyConf.empty() )
{
double hours = skyConf.value( "hours", 12.0 );
SkyNode* sky = new SkyNode( mapNode->getMap() );
sky->setAmbientBrightness( ambientBrightness );
sky->setDateTime( 2011, 3, 6, hours );
sky->attach( view );
root->addChild( sky );
Control* c = SkyControlFactory().create(sky, view);
if ( c )
mainContainer->addControl( c );
}
// Adding an ocean model:
if ( useOcean || !oceanConf.empty() )
{
OceanSurfaceNode* ocean = new OceanSurfaceNode( mapNode, oceanConf );
if ( ocean )
{
root->addChild( ocean );
//.........这里部分代码省略.........
开发者ID:JohnDr,项目名称:osgearth,代码行数:101,代码来源:ExampleResources.cpp
示例13: if
Viewer::Viewer(osg::ArgumentParser& arguments)
{
_viewerBase = this;
constructorInit();
// Add help for command-line options read here
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--clear-color <color>","Set the background color of the viewer in the form \"r,g,b[,a]\".");
arguments.getApplicationUsage()->addCommandLineOption("--screen <num>","Set the screen to use when multiple screens are present.");
arguments.getApplicationUsage()->addCommandLineOption("--window <x y w h>","Set the position (x,y) and size (w,h) of the viewer window.");
arguments.getApplicationUsage()->addCommandLineOption("--run-on-demand","Set the run methods frame rate management to only rendering frames when required.");
arguments.getApplicationUsage()->addCommandLineOption("--run-continuous","Set the run methods frame rate management to rendering frames continuously.");
arguments.getApplicationUsage()->addCommandLineOption("--run-max-frame-rate","Set the run methods maximum permissable frame rate, 0.0 is default and switching off frame rate capping.");
arguments.getApplicationUsage()->addCommandLineOption("--enable-object-cache","Enable caching of objects, images, etc.");
// FIXME: Uncomment these lines when the options have been documented properly
//arguments.getApplicationUsage()->addCommandLineOption("--3d-sd","");
//arguments.getApplicationUsage()->addCommandLineOption("--panoramic-sd","");
//arguments.getApplicationUsage()->addCommandLineOption("--radius","");
//arguments.getApplicationUsage()->addCommandLineOption("--collar","");
//arguments.getApplicationUsage()->addCommandLineOption("--im","");
if (arguments.read("--ico"))
{
setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation());
}
std::string filename;
bool readConfig = false;
while (arguments.read("-c",filename))
{
readConfig = readConfiguration(filename) || readConfig;
}
// Enable caching?
while (arguments.read("--enable-object-cache"))
{
if (osgDB::Registry::instance()->getOptions()==0) osgDB::Registry::instance()->setOptions(new osgDB::Options());
osgDB::Registry::instance()->getOptions()->setObjectCacheHint(osgDB::Options::CACHE_ALL);
}
while (arguments.read("--SingleThreaded"
|
请发表评论