osgEarth 2.1.1
|
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 |
Base class for a node that can be "draped" on the MapNode terrain using the overlay decorator.
Definition at line 32 of file DrapeableNode.
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 }
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; } }
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() ); } }
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 ); } }
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() ); } } }
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 ); }
int osgEarth::DrapeableNode::_dirty [private] |
Reimplemented in osgEarth::Util::ImageOverlay.
Definition at line 60 of file DrapeableNode.
bool osgEarth::DrapeableNode::_draped [private] |
Definition at line 56 of file DrapeableNode.
osg::observer_ptr<MapNode> osgEarth::DrapeableNode::_mapNode [protected] |
Definition at line 53 of file DrapeableNode.
bool osgEarth::DrapeableNode::_newDraped [private] |
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.