예제 #1
0
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);
        }
    }
}
예제 #2
0
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() );
            }
        }
    }
}
예제 #3
0
파일: Node.cpp 프로젝트: bouffa/osg
  virtual void apply(osg::Node& node)
  {
      if (node.getNumParents()==0 || &node==_haltTraversalAtNode)
      {
          _nodePaths.push_back(getNodePath());
      }
      else
      {
          traverse(node);
      }
 }
예제 #4
0
 virtual void apply( osg::Node& node )
 {
     if( ( node.getNumParents() == 0 ) ||
             ( &node == m_stopNode.get() ) )
     {
         _finalNodePath = getNodePath();
     }
     else
     {
         osg::NodeVisitor::traverse( node );
     }
 }
예제 #5
0
void GetWorldCoorOfNode::apply(osg::Node & node)
{
	if (!done)
	{
		if ( 0 == node.getNumParents() ) // no parents
		{
			wcMatrix->set( osg::computeLocalToWorld(this->getNodePath()) );
			done = true;
		}
		traverse(node);
	}
}
예제 #6
0
 virtual void apply(osg::Node &node)
 {
     if ( 0 == node.getNumParents() ) // no parents
         wcMatrix.set( osg::computeLocalToWorld(this->getNodePath()) );
     traverse(node);
 }