Hi,
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))
{
for(osgUtil::LineSegmentIntersector::Intersections::iterator
hitr =intersections.begin();
hitr!=intersections.end();
++hitr)
{
if(!hitr->nodePath.empty() &&
!(hitr->nodePath.back()->getName().empty()))
{
std::cout<<"Hit:
"<<hitr->nodePath.back()->getName()<<std::endl;
}
else if (hitr->drawable.valid())
{
std::cout<<"Geo: name="<<hitr->drawable->getName()
<<std::endl;
}
}
}
}
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!
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org