Hi,

ok. I registered a osgDB::Registry::ReadFileCallback and I overidden the 
readNode() function. As Robert suggested, I added a node visitor to scan for 
all statesets (in nodes and drawables) for textures.  


Code:

void CGeTrilinearVisitor::apply( osg::Node& rNode )
{
    osg::StateSet* pStateSet = rNode.getStateSet( );
    if( pStateSet )
    {
        osg::StateSet::TextureAttributeList& rList = 
pStateSet->getTextureAttributeList( );
        osg::Texture2D* pTex = dynamic_cast<osg::Texture2D*>( 
pStateSet->getTextureAttribute( 0, osg::StateAttribute::TEXTURE ) );
        if( pTex )
        {
            pTex->setFilter( osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR );
        }
    }

    Inherited::apply( rNode );
}

void CGeTrilinearVisitor::apply( osg::Geode& rGNode )
{
    const osg::Geode::DrawableList& rDrawables = rGNode.getDrawableList( );

    for( int i = 0; i < rDrawables.size( ); ++i )
    {
        osg::ref_ptr<osg::Drawable> pDrawable = rDrawables[i];
        osg::StateSet* pStateSet = pDrawable->getStateSet( );
        if( pStateSet )
        {
            osg::StateSet::TextureAttributeList& rList = 
pStateSet->getTextureAttributeList( );
            osg::Texture2D* pTex = dynamic_cast<osg::Texture2D*>( 
pStateSet->getTextureAttribute( 0, osg::StateAttribute::TEXTURE ) );
            if( pTex )
            {
                pTex->setFilter( osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR );
            }
        }
    }

    Inherited::apply( rGNode );
}




What I discovered is that the nodes and drawables don't have any stateset 
allocated when loading an openflight file. Maybe the statesets get added later??

I am looking at the openflight plugin, but any suggestion would be appreciated.

Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12985#12985





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to