Hi Miguel,

It sounds like you are on to something w.r.t bounding volume being 0.
Could try disabling small feature culling for the viewer's main Camera
to see if it's the traversal of the subgraph that is not happening due
to small feature culling cutting short the traversal?

You can disable small feature culling via:

viewer.getCamera()->setCullingMode(
    viewer.getCamera()->getCullingMode()  &
~osg::CullSettings:SMALL_FEATURE_CULLING);

Robert.

On Fri, Mar 4, 2011 at 10:54 AM, Miguel Lokida <mlok...@yahoo.fr> wrote:
> I have found the problem but don't know where it comes from.
>
> So I have this:
>
> Root
> -> positionAttitudeTransform -> Group -> AutoTransform -> Geode1
>                                                         -> Geode2
>
> When geode2 has a bound radius that is equal to zero, then nothing is 
> displayed. When it is greater than 0 everything is displayed.
>
> Here the example code (modification from an osg example) that give me this 
> strange behaviour:
>
> ie: you can see the problem by modifying here in the code:
>
> //Modify size of the quad here. 0 size and no display
> group->addChild(setupQuad(0)); // DON'T WORK
> //group->addChild(setupQuad(1)); // WORK
>
>
> [/code]
> #include <iostream>
> #include <osg/AutoTransform>
> #include <osg/Geometry>
> #include <osg/PositionAttitudeTransform>
> #include <osg/Shape>
> #include <osg/ShapeDrawable>
> #include <osgViewer/Viewer>
> #include <osgGA/TrackballManipulator>
> #include <osg/MatrixTransform>
> #include <osg/Material>
> #include <osgAnimation/Sampler>
>
> osg::Geode* createAxis()
> {
>    osg::Geode* geode  = new osg::Geode;
>    osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry());
>
>    osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
>    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
>    vertices->push_back (osg::Vec3 ( 10.0, 0.0, 0.0));
>    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
>    vertices->push_back (osg::Vec3 ( 0.0, 10.0, 0.0));
>    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
>    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 10.0));
>    geometry->setVertexArray (vertices.get());
>
>    osg::ref_ptr<osg::Vec4Array> colors (new osg::Vec4Array());
>    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
>    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
>    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
>    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
>    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
>    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
>    geometry->setColorArray (colors.get());
>
>    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
>    geometry->addPrimitiveSet(new 
> osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
>
>    geode->addDrawable( geometry.get() );
>    geode->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
>    return geode;
> }
>
> osg::Node* setupQuad(int size)
> {
>    osg::Geode* geode = new osg::Geode;
>
>        osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
>
>        unsigned int numCoords = 4;
>        osg::Vec3 coords[] =
>        {
>                osg::Vec3(-size, size, 0),
>                osg::Vec3(-size, -size, 0),
>                osg::Vec3(size, -size, 0),
>                osg::Vec3(size, size, 0),
>        };
>
>        osg::ref_ptr<osg::Vec3Array> sommets = new osg::Vec3Array(numCoords, 
> coords);
>
>        // vertices
>    geom->setVertexArray(sommets);
>
>        // normal
>        osg::ref_ptr<osg::Vec3Array> normale = new osg::Vec3Array;
>        normale->push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
>        geom->setNormalArray(normale);
>        geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
>
>        // texture coords
>        osg::ref_ptr<osg::Vec2Array> texCoords = new osg::Vec2Array(4);
>
>        (*texCoords)[0].set(1.0f, 1.0f);
>        (*texCoords)[1].set(1.0f, 0.0f);
>        (*texCoords)[2].set(0.0f, 0.0f);
>        (*texCoords)[3].set(0.0f, 1.0f);
>
>        geom->setTexCoordArray(0, texCoords);
>
>        osg::ref_ptr<osg::DrawArrays> array = new 
> osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4);
>
>        geom->addPrimitiveSet(array);
>
>        geode->addDrawable(geom);
>
>    return geode;
> }
>
> int main (int argc, char* argv[])
> {
>    osg::ArgumentParser arguments(&argc, argv);
>    osgViewer::Viewer viewer(arguments);
>
>    osgGA::TrackballManipulator* manipulator = new 
> osgGA::TrackballManipulator();
>    viewer.setCameraManipulator(manipulator);
>
>    osg::Group* root = new osg::Group;
>    root->setInitialBound(osg::BoundingSphere(osg::Vec3(10,0,10), 30));
>    root->addChild(createAxis());
>
>        //Add a simple quad to the group
>        osg::ref_ptr<osg::PositionAttitudeTransform> pat = new 
> osg::PositionAttitudeTransform();
>        pat->setPosition( osg::Vec3(0,0, 0));
>
>        osg::ref_ptr<osg::Group> group = new osg::Group();
>
>        osg::ref_ptr<osg::AutoTransform> autoTransformNode = new 
> osg::AutoTransform();
>        autoTransformNode->setAutoScaleToScreen(true);
>
>        autoTransformNode->addChild(setupQuad(5));
>
>        group->addChild(autoTransformNode);
>
>        //Add an other quad to the group
>
>        //Modify size of the quad here. 0 size and no display
>        group->addChild(setupQuad(0)); // DON'T WORK
>        //group->addChild(setupQuad(1)); // WORK
>
>        pat->addChild(group);
>
>        root->addChild(pat);
>
>    viewer.setSceneData( root );
>    viewer.realize();
>
>    while (!viewer.done())
>    {
>        viewer.frame();
>    }
> }
> [/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=37325#37325
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to