|
楼主 |
发表于 2010-6-25 09:35:37
|
显示全部楼层
pick的代码也贴出来吧- void ScreenHandler::Pick(osgViewer::View* view , float x, float y)
- {
- osgUtil::LineSegmentIntersector::Intersections intersections;
- std::string gdlist="";
- if (view->computeIntersections(x,y,intersections))
- {
- osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
-
- {
- std::ostringstream os;
- if (!hitr->nodePath.empty() && !(hitr->nodePath.back()->getName().empty()))
- {
- // the geodes are identified by name.
- os<<"Object ""<<hitr->nodePath.back()->getName()<<"""<<std::endl;
- }
- else if (hitr->drawable.valid())
- {
- os<<"Object ""<<hitr->drawable->className()<<"""<<std::endl;
- }
- //os<<" local coords vertex("<< hitr->getLocalIntersectPoint()<<")"<<" normal("<<hitr->getLocalIntersectNormal()<<")"<<std::endl;
- //os<<" world coords vertex("<< hitr->getWorldIntersectPoint()<<")"<<" normal("<<hitr->getWorldIntersectNormal()<<")"<<std::endl;
- const osgUtil::LineSegmentIntersector::Intersection::IndexList& vil = hitr->indexList;
- for(unsigned int i=0;i<vil.size();++i)
- {
- os<<" vertex indices ["<<i<<"] = "<<vil[i]<<std::endl;
- }
- gdlist += os.str();
- }
- }
- std::cout<<gdlist;
- }
复制代码 |
|