Attached is a simple OSG example that, on Mac with nVidia card, seems to show 
point geometry with the Point StateAttribute set causing other geometry to be 
clipped.  We did not see this on a Mac with an ATI card.  This has been 
reproduced on the OSG trunk, but has been seen on older versions as well.

The example has a ClipNode, and a Geode with a Point, Line, and Triangle.  When 
we set the Point attribute on the StateSet, the Triangle and Line don't appear. 
 When we skip setting the Point attribute, all three Geometry drawables appear.

If you build the example and run it with no arguments, the Point attribute is 
not set.  If you run with an argument (doesn't matter what it is), the Point 
attribute is set.

Leaving out the ClipNode causes all the Geometry objects to show, whether or 
not the Point is set.

We suspect the part of Point::apply() which handles some of the extensions.  
Could there be a problem in the nVidia driver?

If someone with an nVidia card on a Mac could try this out and give us some 
input, we would appreciate it.

Also, if it turns out to be an issue we would report to nVidia, could we report 
it with an OSG example?  In other words, does nVidia have the ability to build 
OSG examples, and have you reported problems to them with OSG to demonstrate?

In our real app, we saw triangle geometry move when we set the point attribute. 
 That pushed it out of the clipping planes, sometimes partially.  This example 
only shows the triangle disappearing, but it may be moving.  Any idea for why 
these things (settings on point attribute and transform of triangle) might be 
connected?

thanks,
andy

#include <osg/Geometry>
#include <osg/ClipNode>
#include <osg/Point>
#include <osg/Geode>
#include <osgViewer/Viewer>


int main(int argc, char *){

    
    // GL_LINES
    osg::ref_ptr<osg::Vec3Array> xAxis = new osg::Vec3Array;    
    xAxis->push_back( osg::Vec3( -10.f, 0.f, 0.0f) );
    xAxis->push_back( osg::Vec3( 10.f, 0.f, 0.0f) );    

    osg::ref_ptr< osg::Vec4Array> xColor = new osg::Vec4Array;
    xColor->push_back( osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));      

    osg::ref_ptr<osg::Geometry> X = new osg::Geometry;  
    X->setVertexArray( xAxis.get() );           
    X->setColorArray( xColor.get() );
    X->setColorBinding( osg::Geometry::BIND_OVERALL );

    X->addPrimitiveSet( new osg::DrawArrays( GL_LINES,0 , 2 ) );

    // GL_Triangles
    osg::ref_ptr<osg::Vec3Array> tVertices = new osg::Vec3Array;
    tVertices->push_back( osg::Vec3(0.0f, 0.0f,  0.0f) );       
    tVertices->push_back( osg::Vec3(10.0f, 0.0f, 0.0f) );
    tVertices->push_back( osg::Vec3(10.0f, 10.0f,10.0f) );

    osg::ref_ptr<osg::Vec4Array> tColor = new osg::Vec4Array;
    tColor->push_back( osg::Vec4( 1.0f, 0.0f, 0.0f, 1.0f) );

    osg::ref_ptr< osg::Geometry > tri = new osg::Geometry;
    tri->setVertexArray( tVertices.get() );
    tri->setColorArray( tColor.get() );
    tri->setColorBinding( osg::Geometry::BIND_OVERALL );
    tri->addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLES, 0, 3 ) );

        
    // GL_POINTS
    osg::ref_ptr<osg::Geometry> geom(new osg::Geometry());
    osg::ref_ptr<osg::StateSet> stateSet(geom->getOrCreateStateSet());

    osg::ref_ptr<osg::Vec4Array> pColor = new osg::Vec4Array;
    pColor->push_back( osg::Vec4( 0.0f, 1.0f, 0.0f, 1.0f) );

    osg::ref_ptr<osg::Point> p(new osg::Point());
    osg::ref_ptr<osg::Vec3Array> pVertices = new osg::Vec3Array;
    for( float idx = 0.; idx < 10; idx = idx + 1.){
        pVertices->push_back( osg::Vec3( idx, idx, idx ) );
    }   
        
    geom->setColorArray( pColor.get() );
    geom->setColorBinding( osg::Geometry::BIND_OVERALL );
    geom->setVertexArray(pVertices.get());
    int numVerts = pVertices->size();

    geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 7));

    float ptSize = 20.f; // some large size       
    p->setSize(ptSize);
    if (argc > 1){
        // This seems to cause the triangle and line to disappear
        stateSet->setAttributeAndModes(p.get(), osg::StateAttribute::ON);
    }

    osg::ref_ptr<osg::Geode>root = new osg::Geode;
    root->addDrawable ( X.get() );
    root->addDrawable( tri.get() );
    root->addDrawable( geom.get() );
    
    // This is needed
    osg::ref_ptr<osg::ClipNode>clipper = new osg::ClipNode;
    osg::BoundingBox bb(-5., -10., -10., 5., 5., 5.);   
    clipper->createClipBox(bb);
    clipper->addChild(root);


    osgViewer::Viewer viewer;
    viewer.setLightingMode(osg::View::NO_LIGHT);
    viewer.setSceneData( clipper.get() );
    viewer.setUpViewInWindow(20, 20, 640, 480);
    viewer.realize();   
    return viewer.run();        
}



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

Reply via email to