I thouth the keywords OVERRIDE should be use when you want to override
the Attribute. So i would do something like that:
Switcher:
StateSet - tex0
- tex1
Geode
geom1
stateset - tex0 override
stateset - tex1 override
geom2
stateset - tex0 override
stateset - tex1 override
In this sceme geom 1 et 2 will use for tex0 and tex1 from the switcher
you can read the code here in include/osg/State in the function
State::pushAttributeList
It does not anwser directly to you questions but i hope it will help.
Cedric
Riccardo Corsi wrote:
> Hi all,
>
> I'm after overriding some texture attributes in a hierarchy, following
> the osgmultitexture example, from within a "MyTextureSwitcher" node
> derived from osg::Group.
> I basically want to load a new texture on layer 1 and try to mix/blend
> it with the other existing texture on the underlying geometries.
> The hierarchy I have is the following:
>
> MyTextureSwitcher
> |
> MatrixTransform
> |
> MatrixTransform
> |
> Geode
> |-- geom1
> |-- geom2
>
> Now if I try to set the values on the MyTextureSwitcher StateSet,
> nothing happen (the new texture file is not even loaded).
>
> If I change the same attributes on the MatrixTrasform instead,
> everything works nicely. The attributes I'm adding to override the
> other are as well highlighted in the attached image (thanks orhialcon).
> Of course, I'd like to do everything in the MyTextureSwitcher
> stateset, as this is a node that I can add or remove to obtain
> different effects.
>
> My code is:
>
> MyTextureSwitcher::Setup()
> {
> [...]
> osg::StateSet* pSS = getChild(0)->getOrCreateStateSet(); //
> working case
> //osg::StateSet* pSS = getOrCreateStateSet(); // NOT working
>
> pSS->setTextureAttributeAndModes(1, mSwitchTex.get(),
> osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
>
> osg::TexEnv* texenv = new osg::TexEnv;
> texenv->setMode(osg::TexEnv::BLEND);
> texenv->setColor(osg::Vec4(0.3f,0.3f,0.3f,0.3f));
>
> pSS->setTextureAttributeAndModes(1,texenv, osg::StateAttribute::ON
> | osg::StateAttribute::OVERRIDE);
> }
>
> Any clue why the second case is not working?
>
> Thank you,
> Ricky
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
--
+33 (0) 6 63 20 03 56 Cedric Pinson mailto:[EMAIL PROTECTED]
http://www.plopbyte.net
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org