Hi Robert,

I've attached an example code that produces problems.
In fact we have found and correct 2 bugs.
The first one is when the bounding box is flat as Mathieu said.
The second one appears when we are in orthographic view (error in the
algorithm of the computeSilhoette method when the frustum is orthographic
and when the bounding box of the overlay is inside the frustrum)

Elisa.




---------- Forwarded message ----------
> From: Robert Osfield <[EMAIL PROTECTED]>
> Date: 2008/11/30
> Subject: Re: [osg-submissions] OverlayNode bug with flat BBox
> To: OpenSceneGraph Submissions <[email protected]>
>
>
> HI Mathieu,
>
> I've just reviewed the changes and I can't see how the case of flat
> bounding box is fixed here.  I can see that it might  avoid some
> warnings, but make it work...   all it seems to do disable faces of
> the polytope, which in effect makes them unbounded.  If you have a
> flat bounding box then you certainly don't want unbounded box.
>
> Could you please supply an example code that produces problems when
> handling flat bounding boxes, then we can study what might actually
> make sense as a scheme for handling this corner case.
>
> Robert.
>
>
>
> On Fri, Nov 28, 2008 at 12:45 PM, Mathieu MARACHE
> <[EMAIL PROTECTED]> wrote:
> > Hi Robert,
> >
> > Here is a submission to correct a bug we had when OverlayNode's
> > subgraph to overlay had a flat bounding box.
> > This has been found and corrected by Elisa Ciuti.
> >
> > --
> > Mathieu
> >
> > P.S. : this might well be the first submission from a girl :-)
> >
> > _______________________________________________
> > osg-submissions mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
> >
> >
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
#include <osg/Geometry>
#include <osg/Geode>
#include <osgSim/OverlayNode>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>


osg::Group *_root;


osg::Drawable* createSquare(const osg::Vec3d& corner,const osg::Vec3d& 
width,const osg::Vec3d& height, osg::Vec4 color)
{
    osg::Geometry* geom1 = new osg::Geometry;

    osg::Vec3Array* coords = new osg::Vec3Array(4);

    (*coords)[0] = corner;
    (*coords)[1] = corner+width;
    (*coords)[2] = height+width+corner;
    (*coords)[3] = height+corner;

    geom1->setVertexArray(coords);

    osg::Vec3Array* norms = new osg::Vec3Array(1);
    (*norms)[0] = width^height;
    (*norms)[0].normalize();

    geom1->setNormalArray(norms);
    geom1->setNormalBinding(osg::Geometry::BIND_OVERALL);

    osg::Vec4Array* colors = new osg::Vec4Array(1);
    (*colors)[0] = color;
    geom1->setColorArray( colors );
    geom1->setColorBinding( osg::Geometry::BIND_OVERALL );

    geom1->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));

    return geom1;
}

osg::Node* initSceneData()
{
    _root = new osg::Group;

    osg::Geode *smallSquare = new osg::Geode();
    
smallSquare->addDrawable(createSquare(osg::Vec3(5.,5.,0),osg::Vec3(3,0,0),osg::Vec3(0,3,0),osg::Vec4(1,0,0,0.5)));

    osg::Geode *insideSquare = new osg::Geode();
    
insideSquare->addDrawable(createSquare(osg::Vec3(0.,0.,0.),osg::Vec3(20,0,0),osg::Vec3(0,20,0),osg::Vec4(0.9,0.9,0.9,1)));

#define test_overlay
#ifdef test_overlay
    osgSim::OverlayNode *ov = new 
osgSim::OverlayNode(osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
    ov->setOverlayTextureSizeHint( 2048 );
    ov->setOverlaySubgraph(smallSquare);
    ov->addChild(insideSquare);

    _root->addChild(ov);
#else
    _root->addChild(_overlaysGroup);
    _root->addChild(_terrainGroup);
#endif

    return _root;
}  

 
int main(int argc, char *argv[])
{

    // construct the viewer.
    osgViewer::Viewer viewer;

    // construct the viewer.
    osgViewer::Viewer v;
    v.setUpViewInWindow( 20, 20, 640, 480 );
    v.setSceneData(initSceneData());

    v.setCameraManipulator(new osgGA::TrackballManipulator());
    v.addEventHandler( new 
osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );

    return v.run();

}

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to