Hi Bill,

The OSG fully supports StateSet inheritance top down through the
graph, so if you want to decoratate a subgraph with a StateSet then
just attach a StateSet to that subgraph.  Have a look at the osgscribe
example to see it in action.

Also if you want to retain reference to StateSet's that you
adding/removing from the scene graph simply hold a ref_ptr<StateSet>
in your app to these StateSet's and all memory will automatically be
managed safely.

Robert.

On 10/16/06, Bill Prendergast <[EMAIL PROTECTED]> wrote:
I see that the State object has a pushStateSet method, but that appears to
be used in drawing / culling, not where I'm headed.  If it is indeed the answer
to my question below, great!... but presently, it doesn't seem so.

I was wondering if anyone has come across the need to push/pop state sets
at the node level?

Specifically, I am thinking along these lines:

 - I have a node that I want to decorate (wire frame, highlight, etc.)

 - I can easily go to that Node and setStateSet() using (for example) a wire
   frame polygon mode and a material with emissivity set to the color I want

 - The node and children are now wire framed in the color I want

 - The problem lies in the fact that by calling setStateSet with the new 
settings, the
   _stateSet ref_ptr has unref'ed (and typically discarded) the original state 
set that
   may contain a texture or material or polygon mode that I want to revert back 
to
   when I'm done with the special mode.

What I'd like to do is "push" the old state set at the node level so that the
method that altered the states doesn't need to somehow remember the old
one and hold it (i.e., call highlightNode( ) at will and unHighlightNode( ) at 
will,
where the "un" methods just pop the original stateset, if any).

I could make a map< node, stack<stateset> > and hold the old ones in a well-
known place that routines like unHighlight( ) could get to, or potentially push 
them
into the user data area.  This leads to my questions:

1)  Has anyone ever saved/restored state sets like this in a clean & clever way
     that they'd like to share here?

2)  Is there a way to leverage State::pushStateSet at the node level that I'm 
just
     failing to see?

3)  Can we count on the User Data area of osg::Object to always be available at
     the user level?  For example, the FLT loader appears to use this area to 
hold
     the Lat/Long in some cases and without hunting, I am wondering if other 
"osg-level"
     code has hijacked the user area so we cannot count on it always being 
available.

Thanks in advance,

Bill

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to