Exemplo n.º 1
0
void
MapNode::onModelLayerAdded( ModelLayer* layer, unsigned int index )
{
    if ( !layer->getEnabled() )
        return;
    
    // install a noe operation that will associate this mapnode with
    // any MapNodeObservers loaded by the model layer:
    ModelSource* modelSource = layer->getModelSource();
    if ( modelSource )
    {
        // install a post-processing callback on the ModelLayer's source 
        // so we can update the MapNode on new data that comes in:
        modelSource->addPostMergeOperation( new MapNodeObserverInstaller(this) );
    }

    // create the scene graph:
    //osg::Node* node = layer->getOrCreateSceneGraph( _map.get(), _map->getDBOptions(), 0L );
    osg::Node* node = layer->getOrCreateSceneGraph( _map.get(), 0L );

    if ( node )
    {
        if ( _modelLayerNodes.find( layer ) != _modelLayerNodes.end() )
        {
            OE_WARN
                << "Illegal: tried to add the name model layer more than once: " 
                << layer->getName()
                << std::endl;
        }
        else
        {
            if ( dynamic_cast<TerrainDecorator*>(node) )
            {
                OE_INFO << LC << "Installing overlay node" << std::endl;
                addTerrainDecorator( node->asGroup() );
            }
            else
            {
                _models->insertChild( index, node );
            }

            ModelSource* ms = layer->getModelSource();

            if ( ms )
            {
                // enfore a rendering bin if necessary:
                if ( ms->getOptions().renderOrder().isSet() )
                {
                    node->getOrCreateStateSet()->setRenderBinDetails(
                        ms->getOptions().renderOrder().value(), "RenderBin" );
                }
            }

            _modelLayerNodes[ layer ] = node;
        }

        dirtyBound();
    }
}
Exemplo n.º 2
0
void
MapNode::onModelLayerAdded( ModelLayer* layer, unsigned int index )
{
    if ( !layer->getEnabled() )
        return;

    osg::Node* node = layer->getOrCreateNode();

    layer->addCallback(_modelLayerCallback.get() );

    if ( node )
    {
        if ( _modelLayerNodes.find( layer ) != _modelLayerNodes.end() )
        {
            OE_WARN
                << "Illegal: tried to add the name model layer more than once: " 
                << layer->getName()
                << std::endl;
        }
        else
        {
            if ( dynamic_cast<TerrainDecorator*>(node) || dynamic_cast<osgSim::OverlayNode*>(node) )
            {
                OE_INFO << LC << "Installing overlay node" << std::endl;
                addTerrainDecorator( node->asGroup() );
            }
            else
            {
                if ( layer->getOverlay() )
                {
#if 0
                    _overlayModels->addChild( node );
                    updateOverlayGraph();
#else
                    DrapeableNode* draper = new DrapeableNode( this );
                    draper->addChild( node );
                    _models->insertChild( index, draper );
#endif
                }
                else
                {
                    _models->insertChild( index, node );
                }
            }

            ModelSource* ms = layer->getModelSource();
            if ( ms && ms->getOptions().renderOrder().isSet() )
            {
                node->getOrCreateStateSet()->setRenderBinDetails(
                    ms->getOptions().renderOrder().value(), "RenderBin" );
            }

            _modelLayerNodes[ layer ] = node;
        }

        dirtyBound();
    }
}