osgEarth 2.1.1
|
Public Member Functions | |
ModelLayer (const ModelLayerOptions &options) | |
ModelLayer (const std::string &name, const ModelSourceOptions &options) | |
ModelLayer (const ModelLayerOptions &options, ModelSource *source) | |
ModelLayer (const std::string &name, osg::Node *node) | |
const std::string & | getName () const |
const ModelLayerOptions & | getModelLayerOptions () const |
const std::string & | getReferenceURI () const |
ModelSource * | getModelSource () const |
osg::Node * | getOrCreateNode (ProgressCallback *progress=0L) |
bool | getEnabled () const |
void | setEnabled (bool enabled) |
bool | getOverlay () const |
void | setOverlay (bool overlay) |
void | setLightingEnabled (bool value) |
bool | isLightingEnabled () const |
void | addCallback (ModelLayerCallback *cb) |
void | removeCallback (ModelLayerCallback *cb) |
void | initialize (const std::string &referenceURI, const Map *map) |
Private Member Functions | |
virtual void | fireCallback (ModelLayerCallbackMethodPtr method) |
void | copyOptions () |
Private Attributes | |
std::string | _referenceURI |
osg::ref_ptr< ModelSource > | _modelSource |
const ModelLayerOptions | _initOptions |
ModelLayerOptions | _runtimeOptions |
osg::ref_ptr< osg::Node > | _node |
Revision | _modelSourceRev |
ModelLayerCallbackList | _callbacks |
Definition at line 103 of file ModelLayer.
ModelLayer::ModelLayer | ( | const ModelLayerOptions & | options | ) |
Constructs a new model layer.
Definition at line 83 of file ModelLayer.cpp.
: _initOptions( options ) { copyOptions(); }
ModelLayer::ModelLayer | ( | const std::string & | name, |
const ModelSourceOptions & | options | ||
) |
Constructs a new model layer with a user-provided driver options.
Definition at line 89 of file ModelLayer.cpp.
: _initOptions( ModelLayerOptions( name, options ) ) { copyOptions(); }
ModelLayer::ModelLayer | ( | const ModelLayerOptions & | options, |
ModelSource * | source | ||
) |
Constructs a new model layer with a user-provided model source.
Definition at line 95 of file ModelLayer.cpp.
: _modelSource( source ), _initOptions( options ) { copyOptions(); }
ModelLayer::ModelLayer | ( | const std::string & | name, |
osg::Node * | node | ||
) |
Constructs a new model layer with a user provided name and an existing node
Definition at line 102 of file ModelLayer.cpp.
: _initOptions(ModelLayerOptions( name )), _node(node) { copyOptions(); }
void ModelLayer::addCallback | ( | ModelLayerCallback * | cb | ) |
Adds a property notification callback to this layer
Definition at line 219 of file ModelLayer.cpp.
{ _callbacks.push_back( cb ); }
void ModelLayer::copyOptions | ( | ) | [private] |
Definition at line 110 of file ModelLayer.cpp.
{ _runtimeOptions = _initOptions; }
void ModelLayer::fireCallback | ( | ModelLayerCallbackMethodPtr | method | ) | [private, virtual] |
Definition at line 234 of file ModelLayer.cpp.
{ for( ModelLayerCallbackList::const_iterator i = _callbacks.begin(); i != _callbacks.end(); ++i ) { ModelLayerCallback* cb = i->get(); (cb->*method)( this ); } }
bool ModelLayer::getEnabled | ( | ) | const |
Whether this layer is rendered.
Definition at line 170 of file ModelLayer.cpp.
{ return *_runtimeOptions.enabled(); }
const ModelLayerOptions& osgEarth::ModelLayer::getModelLayerOptions | ( | ) | const [inline] |
Gets the initialization options for this layer.
Definition at line 135 of file ModelLayer.
{ return _initOptions; }
ModelSource* osgEarth::ModelLayer::getModelSource | ( | ) | const [inline] |
Access the underlying model source.
Definition at line 145 of file ModelLayer.
{ return _modelSource.get(); }
const std::string& osgEarth::ModelLayer::getName | ( | ) | const [inline] |
Gets the name of this model layer
Definition at line 130 of file ModelLayer.
{ return *_runtimeOptions.name(); }
osg::Node * ModelLayer::getOrCreateNode | ( | ProgressCallback * | progress = 0L | ) |
Definition at line 132 of file ModelLayer.cpp.
{ if ( _modelSource.valid() ) { // if the model source has changed, regenerate the node. if ( _node.valid() && !_modelSource->inSyncWith(_modelSourceRev) ) { _node = 0L; } if ( !_node.valid() ) { _node = _modelSource->createNode( progress ); if ( _runtimeOptions.enabled().isSet() ) setEnabled( *_runtimeOptions.enabled() ); if ( _runtimeOptions.lightingEnabled().isSet() ) setLightingEnabled( *_runtimeOptions.lightingEnabled() ); if ( _modelSource->getOptions().depthTestEnabled() == false ) { if ( _node ) { osg::StateSet* ss = _node->getOrCreateStateSet(); ss->setAttributeAndModes( new osg::Depth( osg::Depth::ALWAYS ) ); ss->setRenderBinDetails( 99999, "RenderBin" ); //TODO: configure this bin ... } } _modelSource->sync( _modelSourceRev ); } } return _node.get(); }
bool ModelLayer::getOverlay | ( | ) | const |
Whether this layer is drawn as normal geometry or as a draped overlay.
Definition at line 203 of file ModelLayer.cpp.
{ return *_runtimeOptions.overlay(); }
const std::string& osgEarth::ModelLayer::getReferenceURI | ( | ) | const [inline] |
Gets the reference URI (for resolving relative paths)
Definition at line 140 of file ModelLayer.
{ return _referenceURI; }
void ModelLayer::initialize | ( | const std::string & | referenceURI, |
const Map * | map | ||
) |
Definition at line 116 of file ModelLayer.cpp.
{ _referenceURI = referenceURI; if ( !_modelSource.valid() && _initOptions.driver().isSet() ) { _modelSource = ModelSourceFactory::create( *_initOptions.driver() ); } if ( _modelSource.valid() ) { _modelSource->initialize( _referenceURI, map ); } }
bool ModelLayer::isLightingEnabled | ( | ) | const |
Definition at line 197 of file ModelLayer.cpp.
{ return *_runtimeOptions.lightingEnabled(); }
void ModelLayer::removeCallback | ( | ModelLayerCallback * | cb | ) |
Removes a property notification callback from this layer
Definition at line 225 of file ModelLayer.cpp.
{ ModelLayerCallbackList::iterator i = std::find( _callbacks.begin(), _callbacks.end(), cb ); if ( i != _callbacks.end() ) _callbacks.erase( i ); }
void ModelLayer::setEnabled | ( | bool | enabled | ) |
Definition at line 176 of file ModelLayer.cpp.
{ _runtimeOptions.enabled() = enabled; if ( _node.valid() ) _node->setNodeMask( enabled ? ~0 : 0 ); }
void ModelLayer::setLightingEnabled | ( | bool | value | ) |
whether to apply lighting to the model layer's root node
Definition at line 184 of file ModelLayer.cpp.
{ _runtimeOptions.lightingEnabled() = value; if ( _node.valid() ) { _node->getOrCreateStateSet()->setMode( GL_LIGHTING, value ? osg::StateAttribute::ON : (osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED) ); } }
void ModelLayer::setOverlay | ( | bool | overlay | ) |
Definition at line 209 of file ModelLayer.cpp.
{ if ( _runtimeOptions.overlay() != overlay ) { _runtimeOptions.overlay() = overlay; fireCallback( &ModelLayerCallback::onOverlayChanged ); } }
Definition at line 193 of file ModelLayer.
const ModelLayerOptions osgEarth::ModelLayer::_initOptions [private] |
Definition at line 182 of file ModelLayer.
osg::ref_ptr<ModelSource> osgEarth::ModelLayer::_modelSource [private] |
Definition at line 180 of file ModelLayer.
Definition at line 191 of file ModelLayer.
osg::ref_ptr< osg::Node > osgEarth::ModelLayer::_node [private] |
Definition at line 185 of file ModelLayer.
std::string osgEarth::ModelLayer::_referenceURI [private] |
Definition at line 179 of file ModelLayer.
Definition at line 183 of file ModelLayer.