PDA

View Full Version : Simple Coordinate System Problem



jbich
06-17-2005, 06:08 AM
Hey all.

I'm trying to learn this crazy coordinate system thing, and a great example that would help me would be to figure out an equation that calculates a point in the viewport from a real-world number.

For example:

How do I find the bottom of the screen?
I know what the window size is, and what the z coord is. How would I translate that to a vector point?

So far I have this information:

Window Size: 640x400
z = -10
Point I'm trying to get to: 100% (of any direction within the viewport)

How would I translate that into a floating point vector of the top,right, etc. of the screen?

Thanks so much for any insight you can supply me!

j

powerpad
06-17-2005, 06:22 AM
A)
you can give gluProject/gluUnproject a try.

B)
go all the way back from viewport space to world space by applying the inverse matrices that transform from world to viewport space

this will be the matrix which is setup by glViewport
and glOrtho/ glFrustum (depending on the projection)

and the matrix that goes from perspective coordinates to normalized device coordinates
but this matrix is incorporated into the projection matrix.

jbich
06-17-2005, 06:55 AM
Yep.
That'll pretty much do it!

Thanks a lot!

j