I want to achieve a similar result, but to specify the matrix with OpenGL co-ordinates. Is this possible without converting from OpenGL -> window manager co-ordinates (using UnProject() or something)?
My app will draw the same objects to multiple outputs (eg. multiple screens / windows / etc…) which could be looking at different parts of the scene.
Therefore a mouse click in one window will not result in the same objects picked, as a mouse click at the same window co-ordinates in another window. Instead, i want the mouse click to be translated to the co-ordinates in my scene and a function for all windows called -
int Pick(double x, double y)
where x and y are co-ordinates in my scene.
How do i set the picking matrix for these two co-ordinates?
The net result of the matrix created by gluPickMatrix() is to transform the clipping region into the unit cube -1 ≤ (x, y, z) ≤ 1 (or -w ≤ (wx, wy, wz) ≤ w). The picking matrix effectively performs an orthogonal transformation that maps a subregion of this unit cube to the unit cube. Since the transformation is arbitrary, you can make picking work for different sorts of regions - for example, for rotated rectangular portions of the window. In certain situations, you might find it easier to specify additional clipping planes to define the picking region.