[osg-users] How to select or pick an object in OSG?

hesicong2006 hesicong2006 at 163.com
Thu Sep 6 07:05:30 PDT 2007

I'm new to OSG and now I 'm trying to do picking (or say selecting) in 
OSG. I create a scene by 3DSMAX. It contains a teapot, a box. And then 
it is exported by OSGExp to IVE format.
I loaded this scene in my program. I create an PickHandler just like the 
osgPick does.
The core pick function is:

void PickHandler::pick(osgViewer::Viewer* viewer, const 
osgGA::GUIEventAdapter& ea)
    osgUtil::LineSegmentIntersector::Intersections intersections;

    if(viewer->computeIntersections(ea.getX(),ea.getY(), intersections))
hitr =intersections.begin();
            if(!hitr->nodePath.empty() && 
            else if (hitr->drawable.valid())
                std::cout<<"Geo: name="<<hitr->drawable->getName() 

I notice that the osgUtil::LineSegmentIntersector::Intersections gives 
me only the drawable list but the object list. My aim is to pick the 
"object" (teapot or the box), but it pick the drawable only. And how can 
I pick the object?
Thanks very much for your reply!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070906/b573e24a/attachment-0002.htm>

More information about the osg-users mailing list