Thanks to all. I've got this working now. Lee
On Mon, 2009-05-11 at 20:17 +0100, Robert Osfield wrote: > Hi Lee, > > Clip planes are position state, so have to be positioned in space by > the osg::ClipNode, but the actually enabling of clip planes is > decoupled from this and control through > osg::StateSet::setMode(GL_CLIP_PLANE0+i, osg::StateAttribute::ON). > You typically wouldn't decorate your scene with the ClipNode, rather > you would usually place the ClipNode in your scene and positioned > appropriately, then enable the individual clip planes for the > subgraphs you want them to be on by just setting the modes (as above) > via a StateSet that is attached to root of subgraph that you want to > enable it for. > > Robert. > > On Mon, May 11, 2009 at 8:02 PM, Butler, Lee Mr CIV USA USAMC > <[email protected]> wrote: > > 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 > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

