When I click outside the earth ellipsoid displayed on the screen I have x and y coordinates in screen space of the clicked point.
I can easilly convert x,y into workdspace using the current view's projection, view and window matrices. But I need to find out an intersection with the earth which is orthogonal from the earth horizon to the clicked point. Visualy for the user this means the closes point on earth to that clicked point in the sky above.
I hope that I made myself clear and someone could help me, please excuse my english.
Are you trying to find the location on the earth under the mouse? If so, you can use the viewer->computeIntersections method to compute the XYZ location on the earth (see the OpenSceneGraph osgpick example). The XYZ that you get will be in geocentric coordinates if you are using a globe. If you need those converted to latitude,longitude and height you can find the osg::CoordinateSystemNode using the findTopMostNodeOfType function in osgEarth's FindNode header.
Thanks for your reply.
I know how to find the XYZ in earth coordinates when the mouse click is *over* the earth.
But I need to find out something different: when the mouse click is outside the earth globe, i.e. in the empty space outside the earth elliposid. In that case I need to find the XYZ of the closest point on the horizon. Please check the image I attached, hope it makes it clear:
The intersection of the point on the horizon that is orthogonal to the earth on the horizon and ends at the mouse click. I.e. I don't know how to specify the Z of the mouse clicked point when intersecting with the center of the earth (0, 0, 0).