Jump to content
  • Advertisement
Sign in to follow this  
Skykid

converting to 2d screen space

This topic is 4727 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

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 dimensions of 128X128 on the screen. Eventually I will want to move this 128X128 square around. Basically, Im trying to make a 2.5D game and I want the Z=0 plane to be where all the 2D action takes place. So I need a method of placing objects in this plane by only needing to specify the (x,y) screen coordinates. And in addition I want them to appear at the z=0 with their screen size dimension (128X128) intact. suggestions?

Share this post


Link to post
Share on other sites
Advertisement
I'm no opengl expert, but my guess would be to look into the gluOrtho2D() function.

gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);

Share this post


Link to post
Share on other sites
Whats the equivalent of that function in DirectX?

Also, If I was to use orthographic projection on the 2D item ,placing it at (x,y,z) and then placed on top of it an item of the same size using 3D perspective projected coordinates at the same (x,y,z) world wouldnt the two items be somewhat off? It would make for some bad collision detection (visually) I think.

Share this post


Link to post
Share on other sites
I'm not sure if this works for 2.5D, but it's worked for me in 2D: device.Transform.Projection=Matrix.OrthoOffCenterLH(0.0f,screenWidth,screenHeight,0.0f,0.0f,1.0f);

Share this post


Link to post
Share on other sites
hi,

look at these articles:
http://www.andypike.com/tutorials/directx8/011.asp
http://www.gamedev.net/reference/programming/features/2d3dquads/

i had the same problem recently, and succeded with the help of these.

kp

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!