View Full Version : back projecting from screen to camera space

08-14-2005, 08:27 PM
Currently, I only know how to use opengl to project from camera space to screen via setting to GL_PROJECTION and setting gluPerspective.
But what I need to do now is, given an already projected image in 2D taken by a camera, project that back onto a 2D quad in camera space.

Let's say that the camera is located at 0,0,-3, looking at 0,0,0. How do I, given an image of x,y size, project that onto a quad of the same or smaller size (i know it's not going to fit) which will be part of a voxel slice in a cube.

I've read a bit about doing ray traces from mouse positions to locate what you're clicking on in 3D space and I think this is connected, I just don't know how atm.

My train of thought goes along the path of taking each corner of the image as a position of the mouse click and projecting that ray through the viewing volume to intersect with the plane which the slice lies on...

Need some advice :)


08-14-2005, 08:57 PM
To get back to camera space, you need to invert the viewport and projection transformations. You could use gluUnProject for this, if you supply an identity matrix for the modelview...

08-14-2005, 10:24 PM
yes, good :) that was what i wanted to hear :)
thank you,