Im using osgViewer with an exisiting rendering engine as an embedded window. 
But i dont want to use the GUIEvent handler, as Im handling the events myself. 
I have followed the osgpick example, normally the x,y mouse pos is retrieved 
from the osgGA::GUIEventAdapter with the values[0,1]. I am passing the actual 
mouse coords [0,windowsize] to a method with the following code, scaling the 
values to [0,1] based on window size, but i Never get any hits..! Do you see 
what im doing wrong here?


CODE:
std::string Pick(int mouse_x, int mouse_y)
{
    osgUtil::LineSegmentIntersector::Intersections intersections;

      int wx,wy,ww,wh;
      _window->getWindowRectangle(wx,wy,ww,wh);

    float x = (float) mouse_x / (float)ww;                 //ea.getX();
    float y = fabs((float) mouse_y / (float)wh);     //ea.getY();

    if (_viewer->computeIntersections(x,y,intersections))
    {
        for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin(); hitr != intersections.end(); ++hitr)
        {
            if (!hitr->nodePath.empty() && 
!(hitr->nodePath.back()->getName().empty()))
            {
                        return hitr->nodePath.back()->getName();
            }
            else if (hitr->drawable.valid())
            {
                return "No name";
            }
        }
    }
      return "";
}

using osg 2.3.7 on vista-

Thanks!
Erlend
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to