void ShaderGenerator::duplicateSharedNode(osg::Node& node) { if ( node.getNumParents() > 1 ) { for(int i=1; i<(int)node.getNumParents(); ++i) { osg::Group* parent = node.getParent(i); osg::Node* replicant = osg::clone( &node, osg::CopyOp::DEEP_COPY_NODES | osg::CopyOp::DEEP_COPY_DRAWABLES | osg::CopyOp::DEEP_COPY_ARRAYS); parent->replaceChild(&node, replicant); } } }
void OcclusionQueryVisitor::addOQN( osg::Node& node ) { VertexCounter vc( _occluderThreshold ); node.accept( vc ); if (vc.exceeded()) { // Insert OQN(s) above this node. unsigned int np = node.getNumParents(); while (np--) { osg::Group* parent = dynamic_cast<osg::Group*>( node.getParent( np ) ); if (parent != NULL) { osg::ref_ptr<osg::OcclusionQueryNode> oqn = new osg::OcclusionQueryNode(); oqn->addChild( &node ); parent->replaceChild( &node, oqn.get() ); oqn->setName( getNextOQNName() ); // Set all OQNs to use the same query StateSets (instead of multiple copies // of the same StateSet) for efficiency. oqn->setQueryStateSet( _state.get() ); oqn->setDebugStateSet( _debugState.get() ); } } } }
virtual void apply(osg::Node& node) { if (node.getNumParents()==0 || &node==_haltTraversalAtNode) { _nodePaths.push_back(getNodePath()); } else { traverse(node); } }
virtual void apply( osg::Node& node ) { if( ( node.getNumParents() == 0 ) || ( &node == m_stopNode.get() ) ) { _finalNodePath = getNodePath(); } else { osg::NodeVisitor::traverse( node ); } }
void GetWorldCoorOfNode::apply(osg::Node & node) { if (!done) { if ( 0 == node.getNumParents() ) // no parents { wcMatrix->set( osg::computeLocalToWorld(this->getNodePath()) ); done = true; } traverse(node); } }
virtual void apply(osg::Node &node) { if ( 0 == node.getNumParents() ) // no parents wcMatrix.set( osg::computeLocalToWorld(this->getNodePath()) ); traverse(node); }