Example #1
0
void 
ShaderGenerator::apply( osg::Node& node )
{
    if ( !_active ) return;

    osg::ref_ptr<osg::StateSet> ss = node.getStateSet();
    if ( ss.valid() )
    {
        _state->pushStateSet( ss.get() );

        osg::ref_ptr<osg::StateSet> replacement;
        if ( processGeometry(ss.get(), replacement) )
        {
            // optimize state set sharing
            if ( _stateSetCache.valid() )
                _stateSetCache->share(replacement, replacement);

            _state->popStateSet();
            node.setStateSet( replacement.get() );
            _state->pushStateSet( replacement.get() );
        }
    }

    traverse(node);

    if ( ss.get() )
    {
        _state->popStateSet();
    }
}
Example #2
0
File: osgconv.cpp Project: 3dcl/osg
 virtual void apply(osg::Node& node)
 {
     if (node.getStateSet())
     {
         node.setStateSet(0);
         ++_numStateSetRemoved;
     }
     traverse(node);
 }
void
CountStateSets::apply( osg::Node& node )
{
    if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets )
    {
        node.setStateSet( NULL );
        _removedStateSets++;
    }
    traverse( node );
}
Example #4
0
void 
ShaderGenerator::apply( osg::Node& node )
{
    osg::ref_ptr<osg::StateSet> ss = node.getStateSet();
    if ( ss.valid() )
    {
        _state->pushStateSet( ss.get() );

        osg::ref_ptr<osg::StateSet> replacement;
        if ( processGeometry(ss.get(), replacement) )
        {
            _state->popStateSet();
            node.setStateSet( replacement.get() );
            _state->pushStateSet( replacement.get() );
        }
    }

    traverse(node);

    if ( ss.get() )
    {
        _state->popStateSet();
    }
}