[osg-users] fadeIn and Out with blendcolor

Dieter Pfeffer dieter.pfeffer at nl.thalesgroup.com
Wed Sep 10 01:51:30 PDT 2008


Hi
I am trying to fade one modell out and another one in; I am using blendfunc
and blendcolor.

However the first modell (when alpha is 0) cuts off the second  - see the
attached images:

a) first modell (dumptruck) cuts off the second
b) the transparency is corret

I suppose I use a wrong parameter, but I can't find it out - any idea?



float currentAlpha = 0.0;

void setAlphaBlendColor()
{
    if (blendFunc0 == 0)
    {
        blendFunc0 = new osg::BlendFunc(osg::BlendFunc::CONSTANT_ALPHA,
osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
        blendColor0 = new osg::BlendColor (osg::Vec4 (1.,1.,1.,0.));

    if (loadedModel0.valid())  //dumptruck
    {
        loadedModel0 ->getOrCreateStateSet()->setAttributeAndModes
(blendFunc0,osg::StateAttribute::ON);
        loadedModel0 ->getOrCreateStateSet()->setAttributeAndModes
(blendColor0,osg::StateAttribute::ON);
    }
}
    if (blendFunc1 == 0)
    {
        blendFunc1 = new osg::BlendFunc(osg::BlendFunc::CONSTANT_ALPHA,
osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
        blendColor1 = new osg::BlendColor (osg::Vec4 (1.,1.,1.,0.));
        if (loadedModel1.valid()) //plane
        {
            loadedModel1 ->getOrCreateStateSet()->setAttributeAndModes
(blendFunc1,osg::StateAttribute::ON);
            loadedModel1 ->getOrCreateStateSet()->setAttributeAndModes
(blendColor1,osg::StateAttribute::ON);
        }
    }
   if (loadedModel0.valid())
    {
        osg::Vec4 l_c;
        l_c.set(1.,1.,1.,currentAlpha);

        blendColor0->setConstantColor(l_c);
    }
    if (loadedModel1.valid())
    {
        osg::Vec4 l_c;
        l_c.set(1.,1.,1.,1-currentAlpha);

        blendColor1->setConstantColor(l_c);
    }
}



Thanks

Dieter
Unclassified Mail



------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080910/5aed9572/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScreenShotb.jpg
Type: image/jpeg
Size: 29377 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080910/5aed9572/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScreenShota.jpg
Type: image/jpeg
Size: 24992 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080910/5aed9572/attachment-0005.jpg>


More information about the osg-users mailing list