2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
3
* Copyright 2008-2010 Pelican Mapping
6
* osgEarth is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>
19
#include <osgEarth/MaskLayer>
20
#include <osgEarth/Map>
22
using namespace osgEarth;
24
#define MASK_MODEL_DRIVER "feature_stencil"
26
MaskLayer::MaskLayer( const ConfigOptions& options )
28
// just in case the caller did not ref the parameter:
29
//osg::ref_ptr<const DriverOptions> tempHold = options;
31
// copy the input options and set some special settings:
32
Config conf = options.getConfig();
33
conf.update( "mask", "true" );
34
conf.update( "inverted", "true" );
35
conf.update( "extrusion_distance", "100000" );
36
_driverOptions = DriverConfigOptions( conf );
37
_driverOptions.setDriver( MASK_MODEL_DRIVER );
41
MaskLayer::initialize( const std::string& referenceURI, const Map* map )
43
_referenceURI = referenceURI;
45
if ( !_modelSource.valid() )
47
_modelSource = ModelSourceFactory::create( _driverOptions );
50
if ( _modelSource.valid() )
52
_modelSource->initialize( _referenceURI, map );
57
MaskLayer::getOrCreateNode( ProgressCallback* progress )
59
osg::Node* result = 0L;
61
if ( _modelSource.valid() )
63
result = _modelSource->createNode( progress );
65
// a hack to immediately update-traverse this node so it can generate its
66
// MaskNodes. Otherwise MapNode will not be able to apply it.
69
osg::NodeVisitor nv( osg::NodeVisitor::UPDATE_VISITOR, osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );
78
MaskLayer::getConfig() const
80
Config conf = _driverOptions.getConfig();
82
conf.remove( "driver" );