I use osgSim::OverlayNode extensively in my application; however, I require 
that MIN_FILTER and MAG_FILTER are set to NEAREST instead of LINEAR.

With OSG 1.2, I accomplished this by creating a new class "FalseColorOverlay" 
that subclasses osgSim::OverlayNode.  In the constructor, I could simply call 
the following (since the _texture member was protected):

_texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST);
_texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST);

The new OverlayNode capability in OSG 2.0 is wonderful; however, it also put a 
stop to my workaround.  Now, the texture is wrapped in an OverlayData struct 
that can only be accessed through a private method "getOverlayData".  If 
getOverlayData were a protected method, I would be able to accomplish my 
porting to OSG 2.0 with the following code snippet:

// Not pretty but functional
void FalseColorOverlay::traverse (osg::NodeVisitor& nv)
{
    osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
    if (cv)
    {
        // Force the filters to NEAREST
        OverlayData& overlayData = getOverlayData(cv);
        overlayData._texture->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::NEAREST);
        overlayData._texture->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::NEAREST);
    }

    // Traverse as normal now ...
    osgSim::OverlayNode::traverse(nv);
}

My solution would require a small patch to the API.  Additionally, it does not 
look eloquent.  Are there any suggestions for alternative solutions?

Thank you for your time.

Respectfully,
Justin
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to