本文整理汇总了C++中ImageLayer::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer::getName方法的具体用法?C++ ImageLayer::getName怎么用?C++ ImageLayer::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLayer
的用法示例。
在下文中一共展示了ImageLayer::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapConf
Config
EarthFileSerializer2::serialize( MapNode* input ) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "external";
mapConf.add( ext );
}
return mapConf;
}
示例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: usage
//.........这里部分代码省略.........
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() );
}
// establish the output path of the earth file, if applicable:
std::string outEarthFile = osgDB::concatPaths( rootFolder, osgDB::getSimpleFileName( outEarth ) );
// 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;
}
osg::ref_ptr< ConsoleProgressCallback > progress = new ConsoleProgressCallback();
std::string layerRoot = osgDB::concatPaths( rootFolder, layerFolder );
TMSPackager::Result r = packager.package( layer, layerRoot, progress, extension );
if( r.ok )
{
// save to the output map if requested:
if( outMap.valid() )
{
// new TMS driver info:
TMSOptions tms;
tms.url() = URI(
osgDB::concatPaths( layerFolder, "tms.xml" ),
outEarthFile );
ImageLayerOptions layerOptions( layer->getName(), tms );
layerOptions.mergeConfig( layer->getInitialOptions().getConfig( true ) );
layerOptions.cachePolicy() = CachePolicy::NO_CACHE;
outMap->addImageLayer( new ImageLayer( layerOptions ) );
}
}
else
{
OE_WARN << LC << r.message << std::endl;
示例4: seed
void CacheSeed::seed( Map* map )
{
// We must do this to avoid an error message in OpenSceneGraph b/c the findWrapper method doesn't appear to be threadsafe.
// This really isn't a big deal b/c this only effects data that is already cached.
osgDB::ObjectWrapper* wrapper = osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper( "osg::Image" );
osg::Timer_t startTime = osg::Timer::instance()->tick();
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
//.........这里部分代码省略.........
示例5: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例6: mapConf
Config
EarthFileSerializer2::serialize(const MapNode* input, const std::string& referrer) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
const Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "extensions";
mapConf.add( ext );
}
#if 1 // removed until it can be debugged.
// Re-write pathnames in the Config so they are relative to the new referrer.
if ( _rewritePaths && !referrer.empty() )
{
RewritePaths rewritePaths( referrer );
rewritePaths.setRewriteAbsolutePaths( _rewriteAbsolutePaths );
rewritePaths.apply( mapConf );
}
#endif
return mapConf;
}
示例7: usage
//.........这里部分代码省略.........
packager.writeXML(layer, map);
}
}
else
{
std::cout << "Failed to find an image layer at index " << imageLayerIndex << std::endl;
return 1;
}
}
// Package an individual elevation layer
else if (elevationLayerIndex >= 0)
{
ElevationLayer* layer = map->getElevationLayerAt(elevationLayerIndex);
if (layer)
{
packager.run(layer, map);
if (writeXML)
{
packager.writeXML(layer, map );
}
}
else
{
std::cout << "Failed to find an elevation layer at index " << elevationLayerIndex << std::endl;
return 1;
}
}
else
{
// Package all the ImageLayer's
for (unsigned int i = 0; i < map->getNumImageLayers(); i++)
{
ImageLayer* layer = map->getImageLayerAt(i);
OE_NOTICE << "Packaging " << layer->getName() << std::endl;
osg::Timer_t start = osg::Timer::instance()->tick();
packager.run(layer, map);
osg::Timer_t end = osg::Timer::instance()->tick();
if (verbose)
{
OE_NOTICE << "Completed seeding layer " << layer->getName() << " in " << prettyPrintTime( osg::Timer::instance()->delta_s( start, end ) ) << std::endl;
}
if (writeXML)
{
packager.writeXML(layer, map);
}
// save to the output map if requested:
if( outMap.valid() )
{
std::string layerFolder = toLegalFileName( packager.getLayerName() );
// new TMS driver info:
TMSOptions tms;
tms.url() = URI(
osgDB::concatPaths( layerFolder, "tms.xml" ),
outEarthFile );
ImageLayerOptions layerOptions( packager.getLayerName(), tms );
layerOptions.mergeConfig( layer->getInitialOptions().getConfig( true ) );
layerOptions.cachePolicy() = CachePolicy::NO_CACHE;
outMap->addImageLayer( new ImageLayer( layerOptions ) );
}
}
示例8: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例9: while
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
// Install the image layer stateset on this layer.
// Later we will refactor this into an ImageLayerRenderer or something similar.
//osg::StateSet* stateSet = tileLayer->getOrCreateStateSet();
//stateSet->merge(*getSurfaceStateSet());
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
optional<int>& unit = imageLayer->shareImageUnit();
if ( !unit.isSet() )
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp) )
{
imageLayer->shareImageUnit() = temp;
OE_INFO << LC << "Image unit " << temp << " assigned to shared layer " << imageLayer->getName() << std::endl;
}
else
{
OE_WARN << LC << "Insufficient GPU image units to share layer " << imageLayer->getName() << std::endl;
}
}
// Build a sampler binding for the shared layer.
if ( unit.isSet() )
{
// Find the next empty SHARED slot:
unsigned newIndex = SamplerBinding::SHARED;
while (_renderBindings[newIndex].isActive())
++newIndex;
// Put the new binding there:
SamplerBinding& newBinding = _renderBindings[newIndex];
newBinding.usage() = SamplerBinding::SHARED;
newBinding.sourceUID() = imageLayer->getUID();
newBinding.unit() = unit.get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< " .. Sampler=\"" << newBinding.samplerName() << "\", "
<< "Matrix=\"" << newBinding.matrixName() << ", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
refresh();
}
}
示例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: updateModels
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
if (!imageLayer->shareImageUnit().isSet())
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp, imageLayer->getName().c_str()) )
{
imageLayer->shareImageUnit() = temp;
//OE_INFO << LC << "Image unit " << temp << " assigned to shared layer " << imageLayer->getName() << std::endl;
}
else
{
OE_WARN << LC << "Insufficient GPU image units to share layer " << imageLayer->getName() << std::endl;
}
}
// Build a sampler binding for the shared layer.
if ( imageLayer->shareImageUnit().isSet() )
{
// Find the next empty SHARED slot:
unsigned newIndex = SamplerBinding::SHARED;
while (_renderBindings[newIndex].isActive())
++newIndex;
// Put the new binding there:
SamplerBinding& newBinding = _renderBindings[newIndex];
newBinding.usage() = SamplerBinding::SHARED;
newBinding.sourceUID() = imageLayer->getUID();
newBinding.unit() = imageLayer->shareImageUnit().get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< "Shared Layer \"" << imageLayer->getName() << "\" : sampler=\"" << newBinding.samplerName() << "\", "
<< "matrix=\"" << newBinding.matrixName() << "\", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
if (_terrain)
{
// Update the existing render models, and trigger a data reload.
// Later we can limit the reload to an update of only the new data.
UpdateRenderModels updateModels(_mapFrame);
#if 0
// This uses the loaddata filter approach which will only request
// data for one layer. It mostly works but not 100%; see hires-insets
// as an example. Removing the world layer and re-adding it while
// zoomed in doesn't result in all tiles reloading. Possibly a
// synchronization issue.
ImageLayerVector imageLayers;
_mapFrame.getLayers(imageLayers);
if (imageLayers.size() == 1)
updateModels.setReloadData(true);
else
updateModels.layersToLoad().insert(tileLayer->getUID());
#else
updateModels.setReloadData(true);
#endif
_terrain->accept(updateModels);
}
}
}
示例12: exportTMS
/** Packages image and elevation layers as a TMS. */
int TMSExporter::exportTMS(MapNode* mapNode, const std::string& path, std::vector< osgEarth::Bounds >& bounds, const std::string& outEarth, bool overwrite, const std::string& extension)
{
if ( !mapNode )
{
_errorMessage = "Invalid MapNode";
if (_progress.valid()) _progress->onCompleted();
return 0;
}
// folder to which to write the TMS archive.
std::string rootFolder = path;
osg::ref_ptr<osgDB::Options> options = new osgDB::Options(_dbOptions);
// create a folder for the output
osgDB::makeDirectory(rootFolder);
if ( !osgDB::fileExists(rootFolder) )
{
_errorMessage = "Failed to create root output folder";
if (_progress.valid()) _progress->onCompleted();
return 0;
}
Map* map = mapNode->getMap();
// 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());
}
// establish the output path of the earth file, if applicable:
std::string outEarthName = osgDB::getSimpleFileName(outEarth);
if (outEarthName.length() > 0 && osgEarth::toLower(osgDB::getFileExtension(outEarthName)) != "earth")
outEarthName += ".earth";
std::string outEarthFile = osgDB::concatPaths(rootFolder, outEarthName);
// semaphore and tasks collection for multithreading
osgEarth::Threading::MultiEvent semaphore;
osgEarth::TaskRequestVector tasks;
int taskCount = 0;
// package any image layers that are enabled and visible
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
unsigned imageCount = 0;
for( ImageLayerVector::iterator i = imageLayers.begin(); i != imageLayers.end(); ++i, ++imageCount )
{
ImageLayer* layer = i->get();
if ( layer->getEnabled() && layer->getVisible() )
{
std::string layerFolder = toLegalFileName( layer->getName() );
if ( layerFolder.empty() )
layerFolder = Stringify() << "image_layer_" << imageCount;
ParallelTask<PackageLayer>* task = new ParallelTask<PackageLayer>( &semaphore );
task->init(map, layer, options, rootFolder, layerFolder, true, overwrite, _keepEmpties, _maxLevel, extension, bounds);
task->setProgressCallback(new PackageLayerProgressCallback(this));
tasks.push_back(task);
taskCount++;
}
}
// package any elevation layers that are enabled and visible
ElevationLayerVector elevationLayers;
map->getElevationLayers( elevationLayers );
int elevCount = 0;
for( ElevationLayerVector::iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i, ++elevCount )
{
ElevationLayer* layer = i->get();
if ( layer->getEnabled() && layer->getVisible() )
{
std::string layerFolder = toLegalFileName( layer->getName() );
if ( layerFolder.empty() )
layerFolder = Stringify() << "elevation_layer_" << elevCount;
ParallelTask<PackageLayer>* task = new ParallelTask<PackageLayer>( &semaphore );
task->init(map, layer, options, rootFolder, layerFolder, true, overwrite, _keepEmpties, _maxLevel, extension, bounds);
task->setProgressCallback(new PackageLayerProgressCallback(this));
tasks.push_back(task);
taskCount++;
}
}
// Run all the tasks in parallel
_totalTasks = taskCount;
_completedTasks = 0;
semaphore.reset( _totalTasks );
//.........这里部分代码省略.........