Hi Carlos,

This type or error usually comes from picking code that is trying to
handle models of zero radius.  I can't see any picking code in your
app though...

Could you try upgrading to 2.0 and see if the warning persists.

Robert.

On 7/11/07, Carlos Nava <[EMAIL PROTECTED]> wrote:
I´m trying to make a very simple SceneGraph, with a model and 3 planes, but
when I run it I get ha next warning twice:
     Warning: invalid line segment passed to IntersectVisitor::addLine
Segment<..>
                  0 0 0 0 0 0 segment ignored
and then get a blank console...

I saw many other mails about this kind of error but none of them seems to
apply, here's y code:



#include <osg/Node>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/BlendFunc>
#include <osg/ColorMask>
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#include <osgProducer/Viewer>

osg::Node* createMirrors(float xMin,float xMax,float zMin,float zMax,float
y)
{

    // set up the Geometry.
    osg::Geometry* geom = new osg::Geometry;

    osg::Vec3Array* coords = new osg::Vec3Array(6);
   coords->push_back( osg::Vec3(   0,0,zMax) ); // front top
   coords->push_back( osg::Vec3(xMin,0,zMin) ); // front left
   coords->push_back( osg::Vec3(xMax,0,zMin) ); // front right
   coords->push_back( osg::Vec3(   0,y,zMax) ); // back top
   coords->push_back( osg::Vec3(xMin,y,zMin) ); // back left
   coords->push_back( osg::Vec3(xMax,y,zMin) ); // back right
   geom->setVertexArray(coords);

   osg::DrawElementsUInt* espejoBase =
      new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
   espejoBase->push_back(4);
   espejoBase->push_back(5);
   espejoBase->push_back(2);
   espejoBase->push_back(1);
   geom->addPrimitiveSet(espejoBase);

   osg::DrawElementsUInt* espejoIzq =
      new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
   espejoIzq->push_back(1);
   espejoIzq->push_back(0);
   espejoIzq->push_back(3);
   espejoIzq->push_back(4);
   geom->addPrimitiveSet(espejoIzq);

   osg::DrawElementsUInt* espejoDer =
      new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
   espejoDer->push_back(2);
   espejoDer->push_back(5);
   espejoDer->push_back(3);
   espejoDer->push_back(0);
   geom->addPrimitiveSet(espejoDer);

   osg::Vec3Array* norms = new osg::Vec3Array(1);
    (*norms)[0].set(0.0f,0.0f,1.0f);
    geom->setNormalArray(norms);
    geom->setNormalBinding(osg::Geometry::BIND_OVERALL);

    osg::Vec4Array* colours = new osg::Vec4Array(1);
    (*colours)[0].set(1.0f,1.0f,1.0,1.0f);
    geom->setColorArray(colours);
    geom->setColorBinding(osg::Geometry::BIND_OVERALL);

        osg::Geode* geode = new osg::Geode;
    geode->addDrawable(geom);

        return geode;
}

osg::Node* createCaleidoscope(osg::Node* model)
{

    // calculate where to place the mirror according to the
    // loaded models bounding sphere.
    const osg::BoundingSphere& bs = model->getBound();

    float xMin = bs.center().x()-bs.radius()*.9129;
    float xMax = bs.center().x()+bs.radius()*.9129;
    float zMin = bs.center().z()-bs.radius();
    float zMax = bs.center().z()+bs.radius()*1.5;
    float y = bs.center().y()-bs.radius()*10.5;

        osg::Group* rootNode = new osg::Group;
    // create a textured, transparent node at the appropriate place.
    osg::Node* mirrors = createMirrors(xMin,xMax,zMin,zMax,y);

        rootNode->addChild(mirrors);

    return rootNode;
}

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

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // construct the viewer.
    osgProducer::Viewer viewer(arguments);

    // set up the value with sensible default event handlers.
    viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);

    // any option left unread are converted into errors to write out later.
    arguments.reportRemainingOptionsAsUnrecognized();

    // report any errors if they have occured when parsing the program
aguments.
    if (arguments.errors())
    {
        arguments.writeErrorMessages(std::cout);
        return 1;
    }

    if (arguments.argc()<=1)
    {

arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
        return 1;
    }


    // read the scene from the list of file specified commandline args.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);

    // if no model has been successfully loaded report failure.
    if (!loadedModel)
    {
        std::cout << arguments.getApplicationName() <<": No data loaded" <<
std::endl;
        return 1;
    }


    // optimize the scene graph, remove rendundent nodes and state etc.
    osgUtil::Optimizer optimizer;
    optimizer.optimize(loadedModel.get());

    // add a transform with a callback to animate the loaded model.
    osg::ref_ptr<osg::MatrixTransform> loadedModelTransform = new
osg::MatrixTransform;
    loadedModelTransform->addChild(loadedModel.get());

    osg::ref_ptr<osg::Node> rootNode =
createCaleidoscope(loadedModelTransform.get());


    // set the scene to render
    viewer.setSceneData(rootNode.get());

    // create the windows and run the threads.
    viewer.realize();

    while( !viewer.done() )
    {
        // wait for all cull and draw threads to complete.
        viewer.sync();

        // update the scene by traversing it with the the update visitor
which will
        // call all node update callbacks and animations.
        viewer.update();

        // fire off the cull and draw traversals of the scene.
        viewer.frame();

    }

    // wait for all cull and draw threads to complete.
    viewer.sync();

    // run a clean up frame to delete all OpenGL objects.
    viewer.cleanup_frame();

    // wait for all the clean up frame to complete.
    viewer.sync();

    return 0;

}

Thanks for any elp you can provide...

_________________________________________________________________
El mejor destino, con los mejores contenidos http://www.prodigy.msn.com

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to