I want to turn a cutting plane on and off at various levels in the graph and
update it under user control.  The osgclip example was enough to show me how
to add the clipping plane.  Getting it turned on and off is something that
somehow eludes me.  I'm having trouble understanding the "OSG way" of doing
this.

Code looks like this:

   // load geometry, etc ...
   // add clip node
   decorate_with_clip_node(scene);

   // set attributes on stateset ...

   MyVisitor myVisitor(stateset);

   while (!viewer.done()) {
         viewer.advance();
         viewer.eventTraversal();
         viewer.updateTraversal();
         viewer.renderingTraversals();
   }

When the user presses a key to toggle the clipping plane I do:

   clipped_subgraph->accept(myVisitor);

which in turn does:

     if (node.getStateSet()) {
         node.setStateSet(NULL);
     } else {
         node.setStateSet( _stateset );
     }


The first time the NodeVisitor runs it claims to turn off the StateSet on the
graphNode.  Yet the clipping still occurs.  On the second pass through, the
stateset pointer is no longer valid, as if it had been freed.  I've checked
the reference count on the stateset after the call to node.setStateSet(NULL)
and the it is still 2, so I wouldn't have anticipated it getting destroyed.

Clearly I'm lost in newbie-land.  I've tried searching the archives, but I
haven't found the right posting and the website doesn't seem to be very stable
this month.

Help?

Lee
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to