本文整理汇总了C++中osg::ArgumentParser::read方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser::read方法的具体用法?C++ ArgumentParser::read怎么用?C++ ArgumentParser::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ArgumentParser
的用法示例。
在下文中一共展示了ArgumentParser::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RealizeOperation
RealizeOperation(osg::ArgumentParser& arguments, osg::StateSet* stateset) :
osg::GraphicsOperation("RealizeOperation",false)
{
_stateset = stateset;
_useModelViewAndProjectionUniforms = arguments.read("--mv");
_useVertexAttributeAliasing = arguments.read("--va");
}
示例2: readArguments
void System::readArguments(osg::ArgumentParser &arguments)
{
while (arguments.read("--machines", _machineFileName))
{
}
while (arguments.read("--cache", _cacheFileName))
{
}
while (arguments.read("--xodr", _xodrName))
{
}
}
示例3: readShaderArguments
bool readShaderArguments(osg::ArgumentParser& arguments, const std::string& option, osg::Program* program, const std::string& fallbackShaderFilename)
{
bool shaderAssigned = false;
std::string shaderFilename;
while(arguments.read(option, shaderFilename))
{
osg::ref_ptr<osg::Shader> shader = osgDB::readRefShaderFile(shaderFilename);
if (shader)
{
shaderAssigned = true;
program->addShader(shader);
}
else
{
OSG_NOTICE<<"Unable to load shader file : "<<shaderFilename<<std::endl;
}
}
if (shaderAssigned) return true;
osg::ref_ptr<osg::Shader> shader = osgDB::readRefShaderFile(fallbackShaderFilename);
if (shader)
{
shaderAssigned = true;
program->addShader(shader);
return true;
}
else
{
OSG_NOTICE<<"Unable to load shader file : "<<fallbackShaderFilename<<std::endl;
return false;
}
}
示例4: setUpStateSet
bool setUpStateSet(osg::ArgumentParser& arguments, osg::StateSet* stateset)
{
osg::ref_ptr<osg::Program> program = new osg::Program;
if (!readShaderArguments(arguments, "--vert", program.get(), "shaders/shaderpipeline.vert"))
{
return false;
}
if (!readShaderArguments(arguments, "--frag", program.get(), "shaders/shaderpipeline.frag"))
{
return false;
}
unsigned int maxTextureUnits = 1;
while(arguments.read("--units", maxTextureUnits)) {}
stateset->setAttribute(program);
std::stringstream sstream;
sstream<<maxTextureUnits;
stateset->setDefine("GL_MAX_TEXTURE_UNITS", sstream.str());
#define ADD_DEFINE(DEF) \
sstream.str(""); \
sstream<<DEF; \
stateset->setDefine(#DEF, sstream.str());
if (maxTextureUnits>0)
{
osg::ref_ptr<osg::Texture2D> fallbackTexture = new osg::Texture2D(createFallbackImage());
fallbackTexture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP_TO_EDGE);
fallbackTexture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP_TO_EDGE);
fallbackTexture->setWrap(osg::Texture2D::WRAP_R, osg::Texture2D::CLAMP_TO_EDGE);
fallbackTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
fallbackTexture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
for(unsigned int i=0; i<maxTextureUnits;++i)
{
stateset->setTextureAttribute(i, fallbackTexture.get());
}
ADD_DEFINE(GL_ALPHA);
ADD_DEFINE(GL_INTENSITY);
ADD_DEFINE(GL_LUMINANCE);
ADD_DEFINE(GL_RED);
ADD_DEFINE(GL_RG);
ADD_DEFINE(GL_RGB);
ADD_DEFINE(GL_RGBA);
}
osgDB::writeObjectFile(*stateset, "stateset.osgt");
return true;
}
示例5: constructorInit
CompositeViewer::CompositeViewer(osg::ArgumentParser& arguments)
{
constructorInit();
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);
}
示例6: usage
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 );
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);
}
seeder.seed( mapNode->getMap() );
return 0;
}
示例7: 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 permissable 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);
}
示例8: mainAdapterWidget
int mainAdapterWidget(QApplication& a, osg::ArgumentParser& arguments) {
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) {
std::cerr << arguments[0] << ": No data loaded." << std::endl;
std::cout << "usage: " << arguments[0] << " [--mdi] nodefile" << 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("--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();
}
示例9: 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();
}
示例10: usage
/** 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 )
//.........这里部分代码省略.........
示例11: 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 permissible 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")) 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_WARN<<"Invalid clear color \""<<colorStr<<"\""<<std::endl;
}
}
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); }
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"))
{
osg::ref_ptr<WoWVxDisplay> wow = new WoWVxDisplay;
if (screenNum>=0) wow->setScreenNum(screenNum);
if (wowvx20) wow->WoWVx20();
if (wowvx42) wow->WoWVx42();
unsigned int c;
float v;
while (arguments.read("--wow-content",c)) { wow->setContent(c); }
while (arguments.read("--wow-factor",c)) { wow->setFactor(c); }
while (arguments.read("--wow-offset",c)) { wow->setOffset(c); }
//.........这里部分代码省略.........
示例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.2f;
args.read("--ambientBrightness", ambientBrightness);
std::string kmlFile;
args.read( "--kml", kmlFile );
std::string imageFolder;
args.read( "--images", imageFolder );
std::string imageExtensions;
args.read("--image-extensions", imageExtensions);
// install a canvas for any UI controls we plan to create:
ControlCanvas* canvas = ControlCanvas::get(view, false);
Container* mainContainer = canvas->addControl( new VBox() );
mainContainer->setAbsorbEvents( true );
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");
// some terrain effects.
const Config& normalMapConf = externals.child("normal_map");
const Config& detailTexConf = externals.child("detail_texture");
const Config& lodBlendingConf = externals.child("lod_blending");
const Config& vertScaleConf = externals.child("vertical_scale");
const Config& contourMapConf = externals.child("contour_map");
// 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( DateTime(2011, 3, 6, hours) );
sky->attach( view );
//.........这里部分代码省略.........
示例13: createOptions
osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const osgDB::ReaderWriter::Options* options)
{
osg::ref_ptr<osgDB::Options> local_options = createOptions(options);
local_options->setOptionString("main");
typedef std::vector< osg::ref_ptr<osg::Node> > NodeList;
NodeList nodeList;
std::string filename;
while (arguments.read("--image",filename))
{
osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get());
if (image.valid()) nodeList.push_back(osg::createGeodeForImage(image.get()));
}
while (arguments.read("--movie",filename))
{
osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get());
osg::ref_ptr<osg::ImageStream> imageStream = dynamic_cast<osg::ImageStream*>(image.get());
if (image.valid())
{
imageStream->play();
nodeList.push_back(osg::createGeodeForImage(imageStream.get()));
}
}
while (arguments.read("--dem",filename))
{
osg::HeightField* hf = readHeightFieldFile(filename.c_str(), local_options.get());
if (hf)
{
osg::Geode* geode = new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(hf));
nodeList.push_back(geode);
}
}
// note currently doesn't delete the loaded file entries from the command line yet...
for(int pos=1;pos<arguments.argc();++pos)
{
if (!arguments.isOption(pos))
{
// not an option so assume string is a filename.
osg::Node *node = osgDB::readNodeFile( arguments[pos], local_options.get());
if(node)
{
if (node->getName().empty()) node->setName( arguments[pos] );
nodeList.push_back(node);
}
}
}
if (nodeList.empty())
{
return NULL;
}
osg::ref_ptr<osg::Node> root;
if (nodeList.size()==1)
{
root = nodeList.front().get();
}
else // size >1
{
osg::Switch* sw = new osg::Switch;
for(NodeList::iterator itr=nodeList.begin();
itr!=nodeList.end();
++itr)
{
sw->addChild((*itr).get());
}
sw->setSingleChildOn(0);
sw->setEventCallback(new p3d::ShowEventHandler());
root = sw;
}
if (root.valid())
{
osg::notify(osg::INFO)<<"Got node now adding callback"<<std::endl;
AddVolumeEditingCallbackVisitor avecv;
root->accept(avecv);
}
return root;
}
示例14: 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 animateSky = args.read("--animate-sky");
bool showActivity = args.read("--activity");
bool useLogDepth = args.read("--logdepth");
bool useLogDepth2 = args.read("--logdepth2");
bool kmlUI = args.read("--kmlui");
if (args.read("--verbose"))
osgEarth::setNotifyLevel(osg::INFO);
if (args.read("--quiet"))
osgEarth::setNotifyLevel(osg::FATAL);
float ambientBrightness = 0.2f;
args.read("--ambientBrightness", ambientBrightness);
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) );
// look for external data in the map node:
const Config& externals = mapNode->externalConfig();
//const Config& screenSpaceLayoutConf =
// externals.hasChild("screen_space_layout") ? externals.child("screen_space_layout") :
// externals.child("decluttering"); // backwards-compatibility
// some terrain effects.
// TODO: Most of these are likely to move into extensions.
const Config& lodBlendingConf = externals.child("lod_blending");
const Config& vertScaleConf = externals.child("vertical_scale");
// Shadowing.
if (args.read("--shadows"))
{
int unit;
if ( mapNode->getTerrainEngine()->getResources()->reserveTextureImageUnit(unit, "ShadowCaster") )
{
ShadowCaster* caster = new ShadowCaster();
caster->setTextureImageUnit( unit );
caster->setLight( view->getLight() );
caster->getShadowCastingGroup()->addChild( mapNode );
if ( mapNode->getNumParents() > 0 )
{
//.........这里部分代码省略.........
示例15: 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 );
//.........这里部分代码省略.........