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

Fuesz, Matthew matthew.fuesz at lmco.com
Tue Jul 1 11:27:01 PDT 2008


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.

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.

Matthew W. Fuesz
Software Engineer Asc.
Lockheed Martin STS
1210 Massillon Road
Akron, OH 44315
matthew.fuesz at lmco.com

-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Judie
Sent: Tuesday, July 01, 2008 1:57 PM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] StateSet issues with parent\child node


I must be doing something wrong. I have a function that adds a sphere
map and material to a node. When I apply this function to a parent, it
also affects the child. How can I make it just affect the parent and
not the child? Also, if I call the same function with different
settings for the child, it still gets the parent's settings even if I
call the function on the child last. In the algorithm I do the

find the node by name that I want to apply the state to - currNode.

make a new group node (gnode) and insert that between the currNode and
it's parent. I use this "gnode" to get or create the state. Then I add
my settings to this state. I also give it a unique name.

I have also tried just applying the state to the currNode directly and
I get the same behavior no matter what.

osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list