[osg-users] StateSet issues with parent\child node

Judie judie.m.stanley at gmail.com
Tue Jul 1 15:51:52 PDT 2008

On Jul 1, 11:27 am, "Fuesz, Matthew" <matthew.fu... at lmco.com> wrote:
> Judie,
> The default behavior is for States/StateSets to be inherited down the
> scene graph, from parent to child. However, in the default
> configuration, setting the StateSet of the child directly should cause
> that child (and any children that it itself has) to use the new StateSet
> parameters. This inheritance method is controlled by the OverrideValue
> flag, which can be set when attributes and modes are enabled or disabled
> on a StateSet.
> It sounds like what you're doing should work (set the state on the
> parent, then reset the state on the child), but I don't understand why
> you're creating and adding another group node in between the parent and
> child, as this is completely unnecessary to manipulate state changes.

OK, I thought someone had told me this needed to be done but that was
a while ago. It works as you say.

> All you need to do is to query the StateSet from the parent (using
> getOrCreateStateSet() ) and make any appropriate changes. Then get the
> StateSet from the child, and remove/reverse any changes (e.g., disable
> materials, or apply 'empty' Programs in the case of shaders).
> Alternatively, you could set the child's OverrideValue to PROTECTED in
> order to prevent the parent's state values from being inherited.

This did the trick!



More information about the osg-users mailing list