本文整理汇总了C++中MapNodeOptions::setTerrainOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ MapNodeOptions::setTerrainOptions方法的具体用法?C++ MapNodeOptions::setTerrainOptions怎么用?C++ MapNodeOptions::setTerrainOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapNodeOptions
的用法示例。
在下文中一共展示了MapNodeOptions::setTerrainOptions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: epo
void
OceanSurfaceContainer::rebuild()
{
this->removeChildren( 0, this->getNumChildren() );
if ( _parentMapNode.valid() )
{
const MapOptions& parentMapOptions = _parentMapNode->getMap()->getMapOptions();
const MapNodeOptions& parentMapNodeOptions = _parentMapNode->getMapNodeOptions();
// set up the map to "match" the parent map:
MapOptions mo;
mo.coordSysType() = parentMapOptions.coordSysType();
mo.profile() = _parentMapNode->getMap()->getProfile()->toProfileOptions();
// new data model for the ocean:
Map* oceanMap = new Map( mo );
// ditto with the map node options:
MapNodeOptions mno;
if ( mno.enableLighting().isSet() )
mno.enableLighting() = *mno.enableLighting();
QuadTreeTerrainEngineOptions to;
to.heightFieldSkirtRatio() = 0.0; // don't want to see skirts
to.clusterCulling() = false; // want to see underwater
to.enableBlending() = true; // gotsta blend with the main node
mno.setTerrainOptions( to );
// make the ocean's map node:
MapNode* oceanMapNode = new MapNode( oceanMap, mno );
// install a custom compositor. Must do this before adding any image layers.
oceanMapNode->setCompositorTechnique( new OceanCompositor() );
// install an "elevation proxy" layer that reads elevation tiles from the
// parent map and turns them into encoded images for our shader to use.
ImageLayerOptions epo( "ocean-proxy" );
epo.cachePolicy() = CachePolicy::NO_CACHE;
epo.maxLevel() = *_options.maxLOD();
oceanMap->addImageLayer( new ElevationProxyImageLayer(_parentMapNode->getMap(), epo) );
this->addChild( oceanMapNode );
// set up the options uniforms.
osg::StateSet* ss = this->getOrCreateStateSet();
_seaLevel = new osg::Uniform(osg::Uniform::FLOAT, "ocean_seaLevel");
ss->addUniform( _seaLevel.get() );
_lowFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_lowFeather");
ss->addUniform( _lowFeather.get() );
_highFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_highFeather");
ss->addUniform( _highFeather.get() );
_baseColor = new osg::Uniform(osg::Uniform::FLOAT_VEC4, "ocean_baseColor");
ss->addUniform( _baseColor.get() );
// trick to prevent z-fighting..
ss->setAttributeAndModes( new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0, false) );
ss->setRenderBinDetails( 15, "RenderBin" );
// load up a surface texture
ss->getOrCreateUniform( "ocean_has_tex1", osg::Uniform::BOOL )->set( false );
if ( _options.textureURI().isSet() )
{
//TODO: enable cache support here:
osg::Image* image = _options.textureURI()->getImage();
if ( image )
{
osg::Texture2D* tex = new osg::Texture2D( image );
tex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
tex->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR );
tex->setWrap ( osg::Texture::WRAP_S, osg::Texture::REPEAT );
tex->setWrap ( osg::Texture::WRAP_T, osg::Texture::REPEAT );
ss->setTextureAttributeAndModes( 1, tex, 1 );
ss->getOrCreateUniform( "ocean_tex1", osg::Uniform::SAMPLER_2D )->set( 1 );
ss->getOrCreateUniform( "ocean_has_tex1", osg::Uniform::BOOL )->set( true );
}
}
// remove backface culling so we can see underwater
// (use OVERRIDE since the terrain engine sets back face culling.)
ss->setAttributeAndModes( new osg::CullFace(), osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE );
apply( _options );
}
}
示例2: epo
void
SimpleOceanNode::rebuild()
{
this->removeChildren( 0, this->getNumChildren() );
osg::ref_ptr<MapNode> mapNode;
if (_parentMapNode.lock(mapNode))
{
const MapOptions& parentMapOptions = mapNode->getMap()->getMapOptions();
const MapNodeOptions& parentMapNodeOptions = mapNode->getMapNodeOptions();
// set up the map to "match" the parent map:
MapOptions mo;
mo.coordSysType() = parentMapOptions.coordSysType();
mo.profile() = mapNode->getMap()->getProfile()->toProfileOptions();
// new data model for the ocean:
Map* oceanMap = new Map( mo );
// ditto with the map node options:
MapNodeOptions mno;
if ( mno.enableLighting().isSet() )
mno.enableLighting() = *mno.enableLighting();
RexTerrainEngineOptions terrainoptions;
terrainoptions.enableBlending() = true; // gotsta blend with the main node
terrainoptions.color() = baseColor().get();
terrainoptions.tileSize() = 5;
mno.setTerrainOptions( terrainoptions );
// make the ocean's map node:
MapNode* oceanMapNode = new MapNode( oceanMap, mno );
// set up the shaders.
osg::StateSet* ss = this->getOrCreateStateSet();
// if the caller requested a mask layer, install that now.
if ( maskLayer().isSet() )
{
if ( !maskLayer()->maxLevel().isSet() )
{
// set the max subdivision level if it's not already specified in the
// mask layer options:
maskLayer()->maxLevel() = maxLOD().get();
}
// make sure the mask is shared (so we can access it from our shader)
// and invisible (so we can't see it)
maskLayer()->shared() = true;
maskLayer()->visible() = false;
ImageLayer* layer = new ImageLayer("ocean-mask", maskLayer().get());
oceanMap->addLayer( layer );
ss->setDefine("OE_SIMPLE_OCEAN_USE_MASK");
OE_INFO << LC << "Using mask layer \"" << layer->getName() << "\"\n";
}
// otherwise, install a "proxy layer" that will use the elevation data in the map
// to determine where the ocean is. This approach is limited in that it cannot
// detect the difference between ocean and inland areas that are below sea level.
else
{
// install an "elevation proxy" layer that reads elevation tiles from the
// parent map and turns them into encoded images for our shader to use.
ImageLayerOptions epo( "ocean-proxy" );
epo.cachePolicy() = CachePolicy::NO_CACHE;
epo.shared() = true;
epo.visible() = false;
epo.shareTexUniformName() = "oe_ocean_proxyTex";
epo.shareTexMatUniformName() = "oe_ocean_proxyMat";
oceanMap->addLayer( new ElevationProxyImageLayer(mapNode->getMap(), epo) );
OE_INFO << LC << "Using elevation proxy layer\n";
}
this->addChild( oceanMapNode );
// install the shaders on the ocean map node.
VirtualProgram* vp = VirtualProgram::getOrCreate( ss );
vp->setName( "osgEarth SimpleOcean" );
Shaders shaders;
shaders.loadAll(vp, 0L);
// set up the options uniforms.
_seaLevel = new osg::Uniform(osg::Uniform::FLOAT, "ocean_seaLevel");
ss->addUniform( _seaLevel.get() );
_lowFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_lowFeather");
ss->addUniform( _lowFeather.get() );
_highFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_highFeather");
ss->addUniform( _highFeather.get() );
_baseColor = new osg::Uniform(osg::Uniform::FLOAT_VEC4, "ocean_baseColor");
ss->addUniform( _baseColor.get() );
//.........这里部分代码省略.........
示例3: to
osg::Group*
MapNodeHelper::load(osg::ArgumentParser& args,
osgViewer::View* view,
Container* userContainer,
const osgDB::Options* readOptions) const
{
// do this first before scanning for an earth file
std::string outEarth;
args.read( "--out-earth", outEarth );
osg::ref_ptr<osgDB::Options> myReadOptions = Registry::cloneOrCreateOptions(readOptions);
Config c;
c.add("elevation_smoothing", false);
TerrainOptions to(c);
MapNodeOptions defMNO;
defMNO.setTerrainOptions( to );
myReadOptions->setPluginStringData("osgEarth.defaultOptions", defMNO.getConfig().toJSON());
// read in the Earth file:
osg::Node* node = osgDB::readNodeFiles(args, myReadOptions.get());
osg::ref_ptr<MapNode> mapNode;
if ( !node )
{
if ( args.find("--images") < 0 )
{
OE_WARN << LC << "No earth file." << std::endl;
return 0L;
}
else
{
mapNode = new MapNode();
}
}
else
{
mapNode = MapNode::get(node);
if ( !mapNode.valid() )
{
OE_WARN << LC << "Loaded scene graph does not contain a MapNode - aborting" << std::endl;
return 0L;
}
}
// warn about not having an earth manip
if ( view )
{
EarthManipulator* manip = dynamic_cast<EarthManipulator*>(view->getCameraManipulator());
if ( manip == 0L )
{
OE_WARN << LC << "Helper used before installing an EarthManipulator" << std::endl;
}
}
// a root node to hold everything:
osg::Group* root = new osg::Group();
root->addChild( node );
// parses common cmdline arguments.
if ( view )
{
parse( mapNode.get(), args, view, root, userContainer );
}
// Dump out an earth file if so directed.
if ( !outEarth.empty() )
{
OE_NOTICE << LC << "Writing earth file: " << outEarth << std::endl;
osgDB::writeNodeFile( *mapNode, outEarth );
}
// configures the viewer with some stock goodies
if ( view )
{
configureView( view );
}
return root;
}
示例4: epo
void
SimpleOceanNode::rebuild()
{
this->removeChildren( 0, this->getNumChildren() );
if ( _parentMapNode.valid() )
{
const MapOptions& parentMapOptions = _parentMapNode->getMap()->getMapOptions();
const MapNodeOptions& parentMapNodeOptions = _parentMapNode->getMapNodeOptions();
// set up the map to "match" the parent map:
MapOptions mo;
mo.coordSysType() = parentMapOptions.coordSysType();
mo.profile() = _parentMapNode->getMap()->getProfile()->toProfileOptions();
// new data model for the ocean:
Map* oceanMap = new Map( mo );
// ditto with the map node options:
MapNodeOptions mno;
if ( mno.enableLighting().isSet() )
mno.enableLighting() = *mno.enableLighting();
MPTerrainEngineOptions mpoptions;
mpoptions.heightFieldSkirtRatio() = 0.0; // don't want to see skirts
mpoptions.minLOD() = _options.maxLOD().get(); // weird, I know
// so we can the surface from underwater:
mpoptions.clusterCulling() = false; // want to see underwater
mpoptions.enableBlending() = true; // gotsta blend with the main node
mpoptions.color() = _options.baseColor().get();
mno.setTerrainOptions( mpoptions );
// make the ocean's map node:
MapNode* oceanMapNode = new MapNode( oceanMap, mno );
// if the caller requested a mask layer, install that now.
if ( _options.maskLayer().isSet() )
{
if ( !_options.maskLayer()->maxLevel().isSet() )
{
// set the max subdivision level if it's not already specified in the
// mask layer options:
_options.maskLayer()->maxLevel() = *_options.maxLOD();
}
// make sure the mask is shared (so we can access it from our shader)
// and invisible (so we can't see it)
_options.maskLayer()->shared() = true;
_options.maskLayer()->visible() = false;
ImageLayer* maskLayer = new ImageLayer( "ocean-mask", *_options.maskLayer() );
oceanMap->addImageLayer( maskLayer );
}
// otherwise, install a "proxy layer" that will use the elevation data in the map
// to determine where the ocean is. This approach is limited in that it cannot
// detect the difference between ocean and inland areas that are below sea level.
else
{
// install an "elevation proxy" layer that reads elevation tiles from the
// parent map and turns them into encoded images for our shader to use.
ImageLayerOptions epo( "ocean-proxy" );
epo.cachePolicy() = CachePolicy::NO_CACHE;
//epo.maxLevel() = *_options.maxLOD();
oceanMap->addImageLayer( new ElevationProxyImageLayer(_parentMapNode->getMap(), epo) );
}
this->addChild( oceanMapNode );
// set up the shaders.
osg::StateSet* ss = this->getOrCreateStateSet();
// install the shaders on the ocean map node.
VirtualProgram* vp = VirtualProgram::getOrCreate( ss );
vp->setName( "osgEarth SimpleOcean" );
// use the appropriate shader for the active technique:
std::string vertSource = _options.maskLayer().isSet() ? source_vertMask : source_vertProxy;
std::string fragSource = _options.maskLayer().isSet() ? source_fragMask : source_fragProxy;
vp->setFunction( "oe_ocean_vertex", vertSource, ShaderComp::LOCATION_VERTEX_VIEW );
vp->setFunction( "oe_ocean_fragment", fragSource, ShaderComp::LOCATION_FRAGMENT_COLORING, 0.6f );
// install the slot attribute(s)
ss->getOrCreateUniform( "ocean_data", osg::Uniform::SAMPLER_2D )->set( 0 );
// set up the options uniforms.
_seaLevel = new osg::Uniform(osg::Uniform::FLOAT, "ocean_seaLevel");
ss->addUniform( _seaLevel.get() );
_lowFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_lowFeather");
ss->addUniform( _lowFeather.get() );
_highFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_highFeather");
ss->addUniform( _highFeather.get() );
//.........这里部分代码省略.........
示例5: setupMap
void GlobePlugin::setupMap()
{
QSettings settings;
/*
QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
TMSCacheOptions cacheOptions;
cacheOptions.setPath( cacheDirectory.toStdString() );
*/
MapOptions mapOptions;
//mapOptions.cache() = cacheOptions;
osgEarth::Map *map = new osgEarth::Map( mapOptions );
//Default image layer
/*
GDALOptions driverOptions;
driverOptions.url() = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/world.tif" ).toStdString();
ImageLayerOptions layerOptions( "world", driverOptions );
map->addImageLayer( new osgEarth::ImageLayer( layerOptions ) );
*/
TMSOptions imagery;
imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/";
map->addImageLayer( new ImageLayer( "Imagery", imagery ) );
MapNodeOptions nodeOptions;
//nodeOptions.proxySettings() =
//nodeOptions.enableLighting() = false;
//LoadingPolicy loadingPolicy( LoadingPolicy::MODE_SEQUENTIAL );
TerrainOptions terrainOptions;
//terrainOptions.loadingPolicy() = loadingPolicy;
terrainOptions.compositingTechnique() = TerrainOptions::COMPOSITING_MULTITEXTURE_FFP;
//terrainOptions.lodFallOff() = 6.0;
nodeOptions.setTerrainOptions( terrainOptions );
// The MapNode will render the Map object in the scene graph.
mMapNode = new osgEarth::MapNode( map, nodeOptions );
mRootNode = new osg::Group();
mRootNode->addChild( mMapNode );
// Add layers to the map
imageLayersChanged();
elevationLayersChanged();
// model placement utils
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#else
mElevationManager = new osgEarth::Util::ElevationManager( mMapNode->getMap() );
mElevationManager->setTechnique( osgEarth::Util::ElevationManager::TECHNIQUE_GEOMETRIC );
mElevationManager->setMaxTilesToCache( 50 );
mObjectPlacer = new osgEarth::Util::ObjectPlacer( mMapNode );
// place 3D model on point layer
if ( mSettingsDialog->modelLayer() && !mSettingsDialog->modelPath().isEmpty() )
{
osg::Node* model = osgDB::readNodeFile( mSettingsDialog->modelPath().toStdString() );
if ( model )
{
QgsVectorLayer* layer = mSettingsDialog->modelLayer();
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) ); //TODO: select only visible features
QgsFeature feature;
while ( fit.nextFeature( feature ) )
{
QgsPoint point = feature.geometry()->asPoint();
placeNode( model, point.y(), point.x() );
}
}
}
#endif
}
示例6: to
osg::Group*
MapNodeHelper::load(osg::ArgumentParser& args,
osgViewer::ViewerBase* viewer,
Container* userContainer,
const osgDB::Options* readOptions) const
{
// do this first before scanning for an earth file
std::string outEarth;
args.read( "--out-earth", outEarth );
osg::ref_ptr<osgDB::Options> myReadOptions = Registry::cloneOrCreateOptions(readOptions);
Config c;
c.add("elevation_smoothing", false);
TerrainOptions to(c);
MapNodeOptions defMNO;
defMNO.setTerrainOptions( to );
myReadOptions->setPluginStringData("osgEarth.defaultOptions", defMNO.getConfig().toJSON());
// read in the Earth file:
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(args, myReadOptions.get());
osg::ref_ptr<MapNode> mapNode;
if ( !node )
{
if ( args.find("--images") < 0 )
{
OE_WARN << LC << "No earth file." << std::endl;
return 0L;
}
else
{
mapNode = new MapNode();
}
}
else
{
mapNode = MapNode::get(node.get());
if ( !mapNode.valid() )
{
OE_WARN << LC << "Loaded scene graph does not contain a MapNode - aborting" << std::endl;
return 0L;
}
}
// collect the views
osgViewer::Viewer::Views views;
if (viewer)
{
viewer->getViews(views);
}
// warn about not having an earth manip
for (osgViewer::Viewer::Views::iterator view = views.begin(); view != views.end(); ++view)
{
EarthManipulator* manip = dynamic_cast<EarthManipulator*>((*view)->getCameraManipulator());
if ( manip == 0L )
{
OE_WARN << LC << "Helper used before installing an EarthManipulator" << std::endl;
}
}
// a root node to hold everything:
osg::Group* root = new osg::Group();
root->addChild( node );
// parses common cmdline arguments and apply to the first view:
if ( !views.empty() )
{
parse( mapNode.get(), args, views.front(), root, userContainer );
}
// Dump out an earth file if so directed.
if ( !outEarth.empty() )
{
OE_NOTICE << LC << "Writing earth file: " << outEarth << std::endl;
osgDB::writeNodeFile( *mapNode, outEarth );
}
// configures each view with some stock goodies
for (osgViewer::Viewer::Views::iterator view = views.begin(); view != views.end(); ++view)
{
configureView( *view );
}
#ifdef OSG_GL3_AVAILABLE
if (viewer)
{
viewer->realize();
for (osgViewer::Viewer::Views::iterator view = views.begin(); view != views.end(); ++view)
{
osg::State* state = (*view)->getCamera()->getGraphicsContext()->getState();
state->setUseModelViewAndProjectionUniforms(true);
state->setUseVertexAttributeAliasing(true);
}
}
#endif
//.........这里部分代码省略.........