Hi Robert,

I am now able to set an overall color for otherwise uncolored
geometries with your suggested fix.  I still don't understand why this
is correct.  I thought that the setStateSet would set a current color
from it's material which is now OSG seemed to behave until 2.9.3.


    osg::Group *primary   = gg.getPrimarySurface();
    // This used to specify an overall color for otherwise uncolored geometries.
    primary->setStateSet( _state.get() );

    // Now required to set the overall color directly in the Geode.
    // Uses the material associated with the state.
    osg::Geode *gg = dynamic_cast<osg::Geode*>(primary->getChild(0));
    if ( gg )
        _applyColor( gg, _material->getDiffuse(osg::Material::FRONT_AND_BACK));

...

void Material::_applyColor( osg::Geode *gg, osg::Vec4 color )
{
    osg::ref_ptr<osg::Geode> geode = gg;
    osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array( 1 );
    (*colors)[ 0 ] = color;
    for ( unsigned int ii=0; ii<geode->getNumDrawables(); ii++ )
    {
osg::Geometry *geom = dynamic_cast<osg::Geometry*>(geode->getDrawable( ii ));
        geom->setColorArray( colors.get() );
        geom->setColorBinding( osg::Geometry::BIND_OVERALL );
    }
}


-Don


Robert Osfield wrote:
Hi Don,

On Tue, Sep 21, 2010 at 12:13 AM, Don Leich <[email protected]> wrote:

I confirmed that the bug persists in today's SVN trunk.  In the example
already supplied the overall color is not applied when normals are
given as BIND_PER_PRIMITIVE.


I've just tested svn/trunk and 2.9.3 and can confirm that there is
different behaviour.

I've also isolated the two geometries that use BIND_PER_PRIMITIVE and
they just use this binding for normals, but have no colour array
assigned at all.  So... they will be inheriting their colour from
other geometries in a completely undefined way.

This to me doesn't look like a bug at all, but an issue with a
under-defined scene graph, and just by luck it's worked before.
Please assign colours to all the geometries that need it and then
re-test.

Robert.


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to