|
楼主 |
发表于 2015-10-16 14:52:18
|
显示全部楼层
找了段代码,用这种方法效果也差不多,有时候能交到面,有时候交不到。。。怎么回事?
osg::Viewport* viewport = view->getCamera()->getViewport();
float mx = viewport->x() + (int)( (float)viewport->width() * (ea.getXnormalized() * 0.5f + 0.5f) );
float my = viewport->y() + (int)( (float)viewport->height() * (ea.getYnormalized() * 0.5f + 0.5f) );
osgUtil:ineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, mx, my );
osgUtil::IntersectionVisitor iv(picker);
view->getCamera()->accept(iv);
|
|