Get 3d-coordinates of cursor
I'd like to get the coordinates of cursor (x,y,z).
I use glReadPixels() with DEPTH_COMPONENT and gluUnproject() functions. The method returns correct result when cursor is over a 3d-vertex (or over some other object). But when it isn't over any object I cannot use this method because glReadPixels() always assigns Z to 1 (z=1 as result). Are there any ways to get 3d - coordinates of cursor if it isn't over any object ( it's pointing to nothing, plane)?
I need this to move 3d-vertex by mouse (with changing it's World x,y and z coordinates). I'll be very happy if anybody help me with this problem.
(sorry for my English)