Thanks.  Now I see the problem in the model and it is not due to the DDS
texture.  I understand why this is being done, but the thing I don't get
is the text is drawing on layer 1 while the plane is drawing on layer 0.
When the plane unwinds its state from the render bins, should not the
state for layer 1 be setup exactly as the initial state of layer 0?
Should not the depth buffer write mask be reinitialized to true?

Ryan Kawicki
Software Engineer
The Boeing Company
Training Systems and Services

-----Original Message-----
From: Brede Johansen [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 19, 2006 1:27 PM
To: osg users
Subject: Re: [osg-users] New OpenFlight Plugin With DDS Textures

Hi Ryan,

2006/10/19, Kawicki, Ryan H <[EMAIL PROTECTED]>:
> ... the depth write mask seems to have been turned off.

The new loader disables writing to the depht buffer and sets the render
bin for subfaces.
You could try to remove this code (GeometryRecords.cpp) in the loader
and see if it helps.
Also try to disable optimizers with reader option "preserveFace" and see
if it makes a difference.

Brede


2006/10/19, Kawicki, Ryan H <[EMAIL PROTECTED]>:
> I have a situation where I am using the new OpenFlight plugin with DDS

> textures bound to the model.  Our application uses a layering approach

> to render symbols.  After a layer is rendered, the depth buffer is 
> cleared and the next layer is rendered.  What I am seeing is our 
> models seem to not follow this layering approach.  We keep a 
> collection of group nodes which represent our layers and set the 
> renderbin for this collection of nodes to the particular layer.  I 
> also tested with a model that had a RGB texture assigned to it and 
> using the old OpenFlight plugin, and this problem seems not to happen.
>
> What I have noticed is that the rendering order is correct, so I 
> cannot say that the render bins are being constructed in some 
> different manor than what is being specified, but what I have found is

> that the depth write mask seems to have been turned off.  I am still 
> looking into why this would be the case, but, again, this seems to 
> only effect DDS textures and the new OpenFlight plugin.  Is this the
intended behavior?
> I would not think it to be, but I am not sure.  Any ideas on where I 
> might start looking for this problem.  I have a couple of screen 
> captures of the problem and the code that produces the problem is
below.
>
> Thanks for the help.
>
>  <<TwoLayerNewOpenFlight.jpg>>  <<TwoLayerOldOpenFlight.jpg>> 
> <<TwoLayerNewOpenFlightDepthMaskTrue.jpg>>
>
> // osg includes
> #include <osgText\Text>
> #include <osgDB\ReadFile>
> #include <osgProducer\Viewer>
> #include <osg\MatrixTransform>
>
> // libraries to include
> #ifdef _DEBUG
>    #pragma comment( lib, "OSGd.lib" )
>    #pragma comment( lib, "OSGDBd.lib" )
>    #pragma comment( lib, "OSGUtild.lib" )
>    #pragma comment( lib, "OSGTextd.lib" )
>    #pragma comment( lib, "OSGProducerd.lib" ) #else
>    #pragma comment( lib, "OSG.lib" )
>    #pragma comment( lib, "OSGDB.lib" )
>    #pragma comment( lib, "OSGUtil.lib" )
>    #pragma comment( lib, "OSGText.lib" )
>    #pragma comment( lib, "OSGProducer.lib" ) #endif
>
> #pragma comment( lib, "OpenGL32.lib" )
>
> class ClearRenderBinDepthBuffer : public 
> osgUtil::RenderBin::DrawCallback {
> public:
>    // constructor
>    ClearRenderBinDepthBuffer( ) : m_nNested  ( 0 )
>    {
>    }
>
>    virtual void drawImplementation( osgUtil::RenderBin * pBin,
>                                     osg::State & rState,
>                                     osgUtil::RenderLeaf *& ppPrevious
)
>    {
>       if (m_nNested++)
>       {
>          pBin->drawImplementation(rState, ppPrevious);
>       }
>       else
>       {
>          if (pBin->getBinNum() > 0)
>          {
>             //glDepthMask(GL_TRUE);
>             GLboolean write_mask = GL_FALSE;
>             glGetBooleanv(GL_DEPTH_WRITEMASK, &write_mask);
>             glClear(GL_DEPTH_BUFFER_BIT);
>          }
>
>          pBin->drawImplementation(rState, ppPrevious);
>       }
>
>       --m_nNested;
>    }
>
> private:
>    int      m_nNested;
>
> };
>
> // main entry for the program
> int main( int argc, char ** argv )
> {
>    //putenv("OSG_OPEN_FLIGHT_PLUGIN=old");
>
>    // viewer class the visualize the scene
>    osgProducer::Viewer osgViewer;
>
>    // allow the viewer the pleasures of being standard
>    osgViewer.setUpViewer();
>
>    // create a root level group node
>    osg::Group * pRootGrp = new osg::Group;
>
>    // create the to layer nodes ( layers 0 and 1 )
>    osg::Group * pLayer0Grp = new osg::Group;
>    osg::Group * pLayer1Grp = new osg::Group;
>
>    // modify the state sets for each layer
>    pLayer0Grp->getOrCreateStateSet()->setRenderBinDetails(0,
> "RenderBin");
>    pLayer1Grp->getOrCreateStateSet()->setRenderBinDetails(1,
> "RenderBin");
>
>    // load the cessna
>    osg::Node * pHornet1 =
> osgDB::readNodeFile("fa18c-hornet_usmc-armed-xt_v2.0\\fa18c-hornet_usm
> c-
> armed-xt.flt");
>    osg::Node * pHornet2 = 
> osgDB::readNodeFile("f18c_hornet_usnavy.flt");
>
>    // create a text object
>    osgText::Text * pText = new osgText::Text;
>    // setup the text attributes
>    pText->setCharacterSize(24.0f);
>    pText->setAxisAlignment(osgText::Text::SCREEN);
>    pText->setAlignment(osgText::Text::CENTER_CENTER);
>    pText->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
>    pText->setText("This is a test of the\nnational broadcast 
> system!!!");
>    pText->setBackdropType(osgText::Text::BackdropType::OUTLINE);
>
>    // create a geode to house the text
>    osg::Geode * pTextGeode = new osg::Geode;
>    pTextGeode->addDrawable(pText);
>
>    // create a matrix transform to translate the text infront of the 
> cessna
>    osg::MatrixTransform * pTextMatTrans = new osg::MatrixTransform;
>    osg::MatrixTransform * pHorn1MatTrans = new osg::MatrixTransform;
>    osg::MatrixTransform * pHorn2MatTrans = new osg::MatrixTransform;
>
>    pTextMatTrans->setMatrix(osg::Matrix::translate(0.0, -100.0, 0.0));
>    pHorn1MatTrans = new
> osg::MatrixTransform(osg::Matrix::translate(-10.0, 0.0, 0.0));
>    pHorn2MatTrans = new
> osg::MatrixTransform(osg::Matrix::translate(10.0, 0.0, 0.0));
>    // add the geode to the transform
>    //pTextMatTrans->addChild(pTextGeode);
>    pTextMatTrans->addChild(pHornet2);
>    pHorn1MatTrans->addChild(pHornet2);
>    //pHorn2MatTrans->addChild(pHornet2);
>
>    // attach the objects to their respective groups
>    pLayer0Grp->addChild(pHorn1MatTrans);
>    //pLayer0Grp->addChild(pHorn2MatTrans);
>    pLayer1Grp->addChild(pTextMatTrans);
>
>    // attach the layers to the root
>    pRootGrp->addChild(pLayer0Grp);
>    pRootGrp->addChild(pLayer1Grp);
>
>    // add the data to the scene graph
>    osgViewer.setSceneData(pRootGrp);
>
>    // create a clear depth buffer object
>    ClearRenderBinDepthBuffer * pDepthBufferClearCB = new 
> ClearRenderBinDepthBuffer;
>    // setup the default renderbin callbacks
>
> osgUtil::RenderBin::getRenderBinPrototype("RenderBin")->setDrawCallbac
> k(
> pDepthBufferClearCB);
>
>    // create the window and run threads
>    osgViewer.realize();
>
>    while (!osgViewer.done())
>    {
>       // wait for all cull and draw threads
>       osgViewer.sync();
>
>       // update the scene
>       osgViewer.update();
>
>       // cull and draw portion
>       osgViewer.frame();
>    }
>
>    // wait for completion
>    osgViewer.sync();
>
>    // run clean up procedures
>    osgViewer.cleanup_frame();
>
>    // wiat for clean up completion
>    osgViewer.sync();
>
>    return 0;
> }
>
> Ryan Kawicki
> Software Engineer
> The Boeing Company
> Training Systems and Services
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to