|
本帖最后由 vinsonxp 于 2012-3-28 11:08 编辑
我也想用鼠标选中线段,我原来是用射线求交器LineSegmentIntersector来做的,但根本选不到。后来看到"osg鼠标选中线段 "这个帖子http://bbs.osgchina.org/forum.ph ... &extra=page%3D1后才知道要用多面体求交器来做,虽然知道了思路,但我还是不知道具体怎么写程序代码,射线求交判断选中可以用下面错码,那么用多面体求交怎样写呢?- void PickHandler::pick(osgViewer::View* view, const osgGA::GUIEventAdapter& ea)
- {
- osgUtil::LineSegmentIntersector::Intersections intersections;
- float x = ea.getX();
- float y = ea.getY();
- if (view->computeIntersections(x,y,intersections))
- {
- for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
- hitr != intersections.end();
- ++hitr)
- {
- ....
- }
- }
- }
复制代码 |
|