Convert 3D perspective projected point into 2D screen space

Started by
3 comments, last by jsgcdude 18 years, 11 months ago
How is this done?
Advertisement
a 3d perspective projected point doesn't make much sense. sure you don't mean a 4d vertex in clipspace? (ie after it has been multiplied with modelview and projection...)

the process of mapping clipspace coordinates to sceenspace coordinates is usually called viewportmapping, and opengl defines it as something like this

sx = vx + ((x / w) + 1) * (vw / 2)
sy = vy + ((y / w) + 1) * (vh / 2)
sz = ((zfar - znear) * z + (znear + zfar) / 2

where vx, vy, vw and wh are viewport x, y, width and height.
the output (sx, sy and sz) are device-space coordinates.
I think what you may be talking about is Ray Picking. If so this article should help!

If this is infact what you are doing, but the article isn't much help, I can post my own function for doing it. It's written with DirectX though.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
hmm... maybe a I need to be a little clearer

I have a camera positioned at (0,0,-10) with positive Z-values going into the screen. I want to place a texture centered around and located at (0,0,0) that will have retain its dimensions of 128X128 on the screen.

I asked how I can convert the 3D point in space into 2D screen space so that I could work from there in figuring out how to make the 128X128 texture placed at (0,0,0) retain its screen size.

I think kusma may have answered this whole question, but I have not had a chance to try the solution out. Kusma, is the information you posted going to solve this? Can anyone else help?
You might try this quality gamedev affiliate site. ;p

Or the graphics link on this page (I actually don't recall if perspective projection is covered on this site or not....).
------------------<a href="http://jsgc.sourceforge.net>jsgc

This topic is closed to new replies.

Advertisement