Hi Robert,
I followed your advice added the code into the traverse function of my root
node.
Much of the code could now be removed, and I got rid of the "0..1 loop"-hack
that I had to do earlier.
I think the new code looks very good. Do you see anything you would do
differently?
The new code looks like this:
void MyRootNodeClass::traverse( osg::NodeVisitor& nv )
{
osg::Group::traverse( nv );
// Clone render-bin 10 if this is a cull visitor
if( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
if( cv )
{
// Act if we have a RenderStage pointer
if( osgUtil::RenderStage* renderStage = cv->getRenderStage() )
{
// Get the render-bin list
osgUtil::RenderBin::RenderBinList& binList =
renderStage->getRenderBinList();
if( binList.find(10) != binList.end() )
{
// Clone bin 10
osgUtil::RenderBin* clonedBin = new osgUtil::RenderBin(
*(binList[10].get()) );
// Clone the state-set
osg::StateSet* originalStateSet = clonedBin->getStateSet();
osg::StateSet* stateSet = (originalStateSet) ? new
osg::StateSet( *(originalStateSet) ) : new osg::StateSet();
// Ensure the cloned state-set is used in the cloned bin
clonedBin->setStateSet( stateSet );
// Cloned bin shall not write to the depth-buffer
stateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON
| osg::StateAttribute::OVERRIDE );
stateSet->setAttributeAndModes( new
osg::Depth(osg::Depth::LESS, 0.0, 1.0, false), osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE );
// Ensure cloned bin is rendered before bin 10.
binList[9] = clonedBin;
}
}
}
}
}
Regards,
Viggo> Date: Thu, 24 Jul 2008 11:19:21 +0100> From: [EMAIL PROTECTED]> To:
osg-users@lists.openscenegraph.org> Subject: Re: [osg-users] Robert: I figured
it out :-) (was: Is it possible to know when the node-graph is 'dirty'?)> > Hi
Viggo,> > I'd do this trick using a CullCallback on the topmost node of sub>
graph that you won't to repeat rather than a pre draw callback. The>
CullVisitor keeps track of the current RenderStage.> > Robert.>
_________________________________________________________________
Hold kontakten med Windows Live Messenger.
http://clk.atdmt.com/GBL/go/msnnkdre0010000003gbl/direct/01/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org