Danny Lesnik wrote:
I just can't realize I have only one object its bs radius os 43. what is the object that I can intersect with on x =12,5? There supposed to be nothing.
Thank you!
The only suggestion I have is to check out what is really going on by writing a small OSG app that shows both your model and the bounding sphere (using e.g. osg::Sphere and an osg::ShapeDrawable). Here, let me do it for you :) (see attachement)

Paul
/* Show the bouding sphere for a given scenegraph
 *
 * Paul E.C. Melis (p.e.c.me...@alumnus.utwente.nl),
 * August 2009
 *
 * g++ -g -o ob osgbound.cpp -I ~/osg2.8/include/ -L ~/osg2.8/lib/ -losg -losgDB -losgViewer -losgUtil -losgGA -losgText
 */

#include <osg/PolygonMode>
#include <osg/Shape>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>

class UpdateBoundCallback : public osg::NodeCallback
{
public:
    UpdateBoundCallback(osg::Sphere* s)
    {
        sphere = s;
    }

    virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
    {
        osg::BoundingSphere bound = node->getBound();
        sphere->set(bound.center(), bound.radius());
    }

    osg::ref_ptr<osg::Sphere>   sphere;
};

int
main(int argc, char *argv[])
{
    osg::ref_ptr<osg::Node> model;
    osg::ref_ptr<osg::Group> root;

    if (--argc != 1)
        return 0;

    model = osgDB::readNodeFile(argv[1]);
    root = new osg::Group;
    root->addChild(model.get());

    osg::BoundingSphere bs = model->getBound();
    osg::Sphere *sphere = new osg::Sphere(bs.center(), bs.radius());
    osg::ShapeDrawable *shape = new osg::ShapeDrawable(sphere);
    shape->setUseDisplayList(false);

    model->setUpdateCallback(new UpdateBoundCallback(sphere));

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

    osg::PolygonMode *polymode = new osg::PolygonMode;
    polymode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
    geode->getOrCreateStateSet()->setAttributeAndModes(polymode, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
    root->addChild(geode);

    osgViewer::Viewer viewer;
    viewer.setSceneData(root.get());
    viewer.realize();
    return viewer.run();
}


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to