| 127 | | // convert Produce's non dimensional x,y coords back into pixel coords. |
| 128 | | int winX = (int)((x+1.0f)*0.5f*(float)width); |
| 129 | | int winY = (int)((y+1.0f)*0.5f*(float)height); |
| 130 | | |
| 131 | | osg::Vec3 nearPoint, farPoint; |
| 132 | | _sceneView->projectWindowXYIntoObject(winX,winY,nearPoint,farPoint); |
| 133 | | |
| 134 | | std::cout<<"nearPoint "<<nearPoint<<" farPoint "<<farPoint<<std::endl; |
| 135 | | |
| 136 | | // make a line segment |
| 137 | | osg::ref_ptr<osg::LineSegment> lineSegment = new osg::LineSegment(nearPoint,farPoint); |
| 138 | | |
| 139 | | // create the IntersectVisitor to do the line intersection traversals. |
| 140 | | osgUtil::IntersectVisitor intersector; |
| 141 | | intersector.addLineSegment(lineSegment.get()); |
| 142 | | |
| 143 | | scene->accept(intersector); |
| 144 | | |
| 145 | | osgUtil::IntersectVisitor::HitList& hits=intersector.getHitList(lineSegment.get()); |
| 146 | | if (!hits.empty()) |
| | 126 | // convert Producer's non dimensional x,y coords back into pixel coords. |
| | 127 | int pixel_x = (int)((x+1.0f)*0.5f*(float)width); |
| | 128 | int pixel_y = (int)((y+1.0f)*0.5f*(float)height); |
| | 129 | |
| | 130 | |
| | 131 | osgUtil::PickVisitor pick(_sceneView->getViewport(), |
| | 132 | _sceneView->getProjectionMatrix(), |
| | 133 | _sceneView->getViewMatrix(), |
| | 134 | pixel_x, pixel_y); |
| | 135 | |
| | 136 | scene->accept(pick); |
| | 137 | |
| | 138 | osgUtil::PickVisitor::LineSegmentHitListMap& segHitList = pick.getSegHitList(); |
| | 139 | if (!segHitList.empty() && !segHitList.begin()->second.empty()) |