Hi Robert :-D
 
Thanx a lot for pointing in the right direction!!!
 
I can now enforce render-bin 10 to be rendered twice each frame with the needed 
stateset changes. No node-mask stuff is needed. This is a completely 
stand-alone fix :-)
 
This is what I did:
Camera is set up with a callback: 
    camera.setPreDrawCallback( new MyCallback() );
 
The callback struct's operator () looks like this:
    virtual void operator () (osg::RenderInfo& renderInfo) const
    {
        osg::Camera* camera = renderInfo.getCurrentCamera();
        if( !camera )
        {
            return;
        }
 
        osgViewer::Renderer* renderer = dynamic_cast<osgViewer::Renderer*>( 
camera->getRenderer() );
        if( !renderer )
        {
            return;
        }
 
        // HACK: This loop should not be here...
        //       Need to figure out which scene-view that is used (0 or 1).
        //       Renderer::draw() does it this way: sceneView = 
_drawQueue.takeFront()
        //       _drawQueue is protected and not accessible through class 
methods.
        //       This hack means we do the job below twice each frame.
        //
        for( int i=0; i<2; i++ )
        {
            osgUtil::SceneView* sceneView = renderer->getSceneView( i );
            if( !sceneView )
            {
                return;
            }
 
            osgUtil::RenderStage* renderStage = sceneView->getRenderStage();
            if( !renderStage )
            {
                return;
            }
 
            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 stateset
                // TODO: Need to check that getStateSet does not return NULL.
                osg::StateSet* stateSet = new osg::StateSet( 
*(clonedBin->getStateSet()) );
 
                // Ensure the cloned stateset 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;
            }
        }
    }

 
I am not sure how to solve the 0..1 loop marked by "// HACK:" in the source. Do 
you know how I can know what SceneView that is used?
 
Do you see any other problems with this code?
 
Regards,
Viggo
 
 
> Date: Wed, 23 Jul 2008 15:01:50 +0100> From: [EMAIL PROTECTED]> To: 
> osg-users@lists.openscenegraph.org> Subject: Re: [osg-users] Is it possible 
> to know when the node-graph is 'dirty'?> > Hi Viggo,> > I think you are on 
> totally wrong take w.r.t trying to track changes in> the scene graph, for 
> what is effectively just a custom transparent> renderbin setup, and has 
> little to do with the scene itself.> > The way you should tackle it is to 
> customize the rendering backend so> that the bins you require are built for 
> you. One one for instance> would be to post process the RenderStage and its 
> contents after the> CullVisitor has filled it in.> > Robert.> 
_________________________________________________________________
Windows Live Messenger - også på mobilen.
http://windowslivemobile.msn.com/Homepage.aspx?lang=nb-no&ocid=30032
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to