PDA

View Full Version : Window Pixels to 3D World Coords Transformation



darie17
05-21-2008, 02:11 AM
Hi! I have to write a small scene in openGL which includes animating an object, moving an object in the scene. The movement must describe a Bezier-curve.
The problem looks as follows: I must click 2 points on the screen, and together with the other two, start and endpoint, i have four. I now should have the four control-points. For detailed description of this process, see the image on the right of the screen in this page >>> http://en.wikipedia.org/wiki/B%C3%A9zier_curve .
The program must then draw a line between each two points. When I click on the the window, the program calculates the coordinates (in pixels) of the points four points. But what I need in order to move my object on a Bezier-curve are not (window)pixels, but "real" openGL 3D "meters". So, it doesn't help me to know that my object should move from point A(223,89) to point B(600,28) (for eg.), because I need to transform those pixels, calculated by the program after the mouse clicks, into my world's coordinates.

Does anyone know how to make such transformations from pixels into (3D) world coordinates?

Thanks in advance!

Darie

-NiCo-
05-21-2008, 02:39 AM
gluUnproject (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/unproject.html) is probably what you're looking for.