Jump to content
  • Advertisement
Sign in to follow this  
Skykid

Convert 3D perspective projected point into 2D screen space

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!