osgEarth 2.1.1
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes

osgEarth::DrapeableNode Class Reference

Inheritance diagram for osgEarth::DrapeableNode:

List of all members.

Public Member Functions

 DrapeableNode (MapNode *mapNode=0L, bool draped=true)
void setNode (osg::Node *node)
osg::Node * getNode () const
void setDraped (bool value)
bool getDraped () const
virtual void traverse (osg::NodeVisitor &nv)

Protected Attributes

osg::observer_ptr< MapNode_mapNode

Private Member Functions

void applyChanges ()
void setNodeImpl (osg::Node *)
void setDrapedImpl (bool)

Private Attributes

bool _draped
osg::ref_ptr< osg::Node > _node
osg::ref_ptr< osg::Group > _nodeContainer
int _dirty
bool _newDraped
osg::ref_ptr< osg::Node > _newNode

Detailed Description

Base class for a node that can be "draped" on the MapNode terrain using the overlay decorator.

Definition at line 32 of file DrapeableNode.


Constructor & Destructor Documentation

DrapeableNode::DrapeableNode ( MapNode mapNode = 0L,
bool  draped = true 
)

Definition at line 26 of file DrapeableNode.cpp.

                                                            :
_mapNode  ( mapNode ),
_newDraped( draped ),
_draped   ( false ),
_dirty    ( false )
{
    // create a container group that will house the culler. This culler
    // allows a draped node, which sits under the MapNode's OverlayDecorator,
    // to "track" the traversal state of the DrapeableNode itself.
    _nodeContainer = new osg::Group();
    _nodeContainer->setCullCallback( new CullNodeByFrameNumber() );
    _nodeContainer->setStateSet( this->getOrCreateStateSet() ); // share the stateset
}

Member Function Documentation

void DrapeableNode::applyChanges ( ) [private]

Definition at line 41 of file DrapeableNode.cpp.

{    
    if ( _newDraped != _draped )
    {
        setDrapedImpl( _newDraped );
    }

    if ( _newNode.valid() )
    {
        setNodeImpl( _newNode.get() );
        _newNode = 0L;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool osgEarth::DrapeableNode::getDraped ( ) const [inline]

Definition at line 47 of file DrapeableNode.

{ return _draped; }
osg::Node* osgEarth::DrapeableNode::getNode ( ) const [inline]

Definition at line 41 of file DrapeableNode.

{ return _node.get(); }
void DrapeableNode::setDraped ( bool  value)

Whether to drape the node content on the mapnode terrain.

Definition at line 67 of file DrapeableNode.cpp.

{
    _newDraped = draped;
    if ( !_dirty )
    {
        _dirty = true;
        ADJUST_UPDATE_TRAV_COUNT( this, 1 );
    }
}
void DrapeableNode::setDrapedImpl ( bool  value) [private]

Definition at line 112 of file DrapeableNode.cpp.

{
    if ( _draped != value )
    {
        osg::ref_ptr<osg::Node> save = _node.get();
        if ( save.valid() )
            setNode( 0L );

        _draped = value;

        if ( save.valid() )
            setNode( save.get() );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void DrapeableNode::setNode ( osg::Node *  node)

The node to drape (or not) on the MapNode terrain.

Definition at line 56 of file DrapeableNode.cpp.

{
    _newNode = node;
    if ( !_dirty )
    {
        _dirty = true;
        ADJUST_UPDATE_TRAV_COUNT( this, 1 );
    }
}

Here is the caller graph for this function:

void DrapeableNode::setNodeImpl ( osg::Node *  node) [private]

Definition at line 78 of file DrapeableNode.cpp.

{
    if ( _node.valid() )
    {
        if ( _draped && _mapNode.valid() )
        {
            _mapNode->getOverlayGroup()->removeChild( _nodeContainer.get() );
            _mapNode->updateOverlayGraph();
        }
        else
        {
            this->removeChild( _node.get() );
        }
    }

    _node = node;
    _nodeContainer->removeChildren( 0, _nodeContainer->getNumChildren() );

    if ( _node.valid() )
    {
        if ( _draped && _mapNode.valid() )
        {
            _nodeContainer->addChild( _node.get() );
            _mapNode->getOverlayGroup()->addChild( _nodeContainer.get() );
            _mapNode->updateOverlayGraph();
        }
        else
        {
            this->addChild( _node.get() );
        }
    }
}

Here is the caller graph for this function:

void DrapeableNode::traverse ( osg::NodeVisitor &  nv) [virtual]

Reimplemented in osgEarth::Util::ImageOverlay.

Definition at line 129 of file DrapeableNode.cpp.

{
    if ( _draped && nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR && _node.valid() && _mapNode.valid() )
    {
        CullNodeByFrameNumber* cb = static_cast<CullNodeByFrameNumber*>(_nodeContainer->getCullCallback());
        cb->_frame = nv.getFrameStamp()->getFrameNumber();
    }

    if ( nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR )
    {
        if ( _dirty )
        {
            applyChanges();

            _dirty = false;
            ADJUST_UPDATE_TRAV_COUNT( this, -1 );
        }

        // traverse the subgraph
        if ( _nodeContainer.valid() && this->getNumChildrenRequiringUpdateTraversal() > 0 )
        {
            _nodeContainer->accept( nv );
        }
    }

    osg::Group::traverse( nv );
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented in osgEarth::Util::ImageOverlay.

Definition at line 60 of file DrapeableNode.

Definition at line 56 of file DrapeableNode.

osg::observer_ptr<MapNode> osgEarth::DrapeableNode::_mapNode [protected]

Definition at line 53 of file DrapeableNode.

Definition at line 61 of file DrapeableNode.

osg::ref_ptr<osg::Node> osgEarth::DrapeableNode::_newNode [private]

Definition at line 62 of file DrapeableNode.

osg::ref_ptr<osg::Node> osgEarth::DrapeableNode::_node [private]

Definition at line 57 of file DrapeableNode.

osg::ref_ptr<osg::Group> osgEarth::DrapeableNode::_nodeContainer [private]

Definition at line 58 of file DrapeableNode.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines