Hi Hagen,

I think you need to enable blending as well, with
stateset->setMode(GL_BLEND, osg::StateAttribute::ON)

Regards
Raymond


Kaiser, Hagen (CT) wrote:

Hello everyone,

Im dont come any further, trying to change transparency of on object at runtime.

I have something like this:

The stateset in a method:

this->material = new osg::Material();
this->material->setDataVariance(osg::Object::DYNAMIC);
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet();
                stateset->setDataVariance(osg::Object::DYNAMIC);
                // set up the texture.
                osg::Texture2D* texture = new osg::Texture2D;
                texture->setImage(image);
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
                stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setAttributeAndModes(this->material.get(),osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);

stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

The stateset is then applied to a geode once.

And in another mehtod after viewer is running and object is shown:

this->material->setTransparency(osg::Material::Face::FRONT_AND_BACK,value);


This method is called continuesly with different float values between 0 and 1 depending an GUI Slider.

But I cant see any changes.

Do you have some hints maybe?

Greetings Hagen

------------------------------------------------------------------------

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

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

Reply via email to