[osg-users] Problem changing Stateset

60 views
Skip to first unread message

Enrico Villani

unread,
Nov 16, 2007, 5:37:50 AM11/16/07
to osg-...@lists.openscenegraph.org
Hello, I have a osg::Node* that has applied a osg::StateSet*  with many Attribute, in particular an osg::Material*.  When I try to switch the stateset to another, no changes are visible.

I tried with

node->setStateSet(TheOtherStateSet);

and

osg::stateSet* tmp = node.getOrCreateStateSet();
tmp = TheOtherStateSet;


but it doesn't work correctly.

Thank you Davide

Thrall, Bryan

unread,
Nov 16, 2007, 9:59:43 AM11/16/07
to OpenSceneGraph Users

Are you using display lists? Your first try should work to change the
state, but you won't see the effects unless you dirty the display list;
simply find all the Drawables under the node and call
dirtyDisplayList(), which will recompile the display list with the new
state.

If you are changing state more than once-in-a-while, you may want to
disable display lists instead (see Drawable::setUseDisplayList());
recompiling them all the time will slow things down (and is wasteful
anyway).

--
Bryan Thrall
FlightSafety International
Bryan....@flightsafety.com
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Brian

unread,
Nov 17, 2007, 12:17:14 AM11/17/07
to OpenSceneGraph Users
Hi,

I'm having a similar problem and was wondering how to "simply find all the Drawables?" I thought I knew, but after looking at the header files for a while, I'm not so sure.

Thanks,
Brian

Robert Osfield

unread,
Nov 17, 2007, 6:22:14 AM11/17/07
to bpd...@knology.net, OpenSceneGraph Users
On Nov 17, 2007 5:17 AM, Brian <bpd...@knology.net> wrote:
> Hi,
>
> I'm having a similar problem and was wondering how to "simply find all the Drawables?" I thought I knew, but after looking at the header files for a while, I'm not so sure.

NodeVisitor is your friend, there are plenty of examples of subclasses
from NodeVisitor in the OSG distribution itself, many of which go in
seach for Drawables. src/osgUtil/Optimizer.cpp in particular has
plenty of example to choose from.

Robert.

Reply all
Reply to author
Forward
0 new messages