| 197 | | float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f)); |
| 198 | | float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f)); |
| 199 | | |
| 200 | | float width = 10.0f; |
| 201 | | float height = 10.0f; |
| 202 | | |
| 203 | | float min_x = mx - width*0.5; |
| 204 | | float max_x = mx + width*0.5; |
| 205 | | float min_y = my - height*0.5; |
| 206 | | float max_y = my + height*0.5; |
| 207 | | |
| 208 | | osg::Polytope polytope; |
| 209 | | polytope.add(osg::Plane(1,0,0,-min_x)); |
| 210 | | polytope.add(osg::Plane(-1,0,0,max_x)); |
| 211 | | polytope.add(osg::Plane(0,1,0,-min_y)); |
| 212 | | polytope.add(osg::Plane(0,-1,0,max_y)); |
| 213 | | polytope.add(osg::Plane(0,0,1,0)); |
| 214 | | |
| 215 | | osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, polytope ); |
| 216 | | |
| | 199 | double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5)); |
| | 200 | double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5)); |
| | 201 | |
| | 202 | // half width, height. |
| | 203 | double w = 5.0f; |
| | 204 | double h = 5.0f; |
| | 205 | osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h ); |
| | 206 | #else |
| | 207 | double mx = ea.getXnormalized(); |
| | 208 | double my = ea.getYnormalized(); |
| | 209 | double w = 0.05; |
| | 210 | double h = 0.05; |
| | 211 | osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h ); |
| | 212 | #endif |
| 238 | | // use non dimension coordinates - in projection/clip space |
| 239 | | osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),-1.0), osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),1.0) ); |
| | 234 | // use non dimensional coordinates - in projection/clip space |
| | 235 | osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::PROJECTION, ea.getXnormalized(),ea.getYnormalized() ); |