Hi Viggo, You could possible experiment with reuse the bin rather than cloning it. Inserting a two bins for bin 9 and 10, then have the original transparent bin nested within them. I can't recall the exact details but I think I've tried a trick like this in the past. This would also allow you to reuse a fixed StateSet on every frame rather than creating one.
Robert. On Thu, Jul 24, 2008 at 12:41 PM, Viggo Løvli <[EMAIL PROTECTED]> wrote: > 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. >> > > > ________________________________ > Få Hotmail du også. Windows Live Hotmail nå med 5000 MB gratis > lagringsplass. > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org