Main Page | Report this Page
Computers Forum Index  »  Computer - Graphics - API (Opengl)  »  Pixels Coordinates to World ones (Newbie question)...
Page 1 of 1    

Pixels Coordinates to World ones (Newbie question)...

Author Message
Ramon...
Posted: Wed Oct 28, 2009 1:25 am
Guest
Hi, I'm just learning the OpenGL. Assume that there is a pixel whose
coordinates are (0, 9) -- where 9 means 9 pixels. Assume also that the
origin is on the top-left hand side of the screen. How can I find its
equivalent world coordinates?

Thanks.
 
Wolfgang Draxinger...
Posted: Wed Oct 28, 2009 1:38 am
Guest
Ramon wrote:

Quote:
Hi, I'm just learning the OpenGL. Assume that there is a pixel whose
coordinates are (0, 9) -- where 9 means 9 pixels. Assume also that the
origin is on the top-left hand side of the screen. How can I find its
equivalent world coordinates?

Since the image on the screen is a 2D projection from 3D space, this one
pixel corresponds to a whole set of points, all located on the line passing
through that pixel.

You can reconstruct that line using inverting the projction process
(gluUnProject) assuming two (arbitrary) depth values. After rendering a
scene the pixel will also carry a depth value (in the depth buffer), which
you can pass into gluUnProject, too, giving you the 3D world coordinates.

If you want to find out the position of a certain would-be-rendered fragment
in the world it might be more performant to run a ray<->scene collision
test if a proper algorithm and spatial data structure is used (saves the
overhead of rendering the scene). If however the scene is already rendered
and the position shall be retrieved thereafter, then unprojection is the
way to got.


Wolfgang
--
OpenGL tip #42:
How to exactly map texture texels to screen pixels:
<http://preview.tinyurl.com/cgndc8>
 
 
Page 1 of 1    
All times are GMT
The time now is Sat Nov 28, 2009 7:45 pm