Jump to content
  • Advertisement
Sign in to follow this  
voodoohaust

Camera distance issue.

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

Hello, how can I compute the right camera distance so that, say, a NxM rectangle in the world look like the same (NxM) on the screen. The inputs are camera fov and screen resolution. Note : the camera IS perspective (mandatory) not orthogonal and is used for UI rendering. Thank.

Share this post


Link to post
Share on other sites
Advertisement
If I understand you correctly, you're trying to draw 2D rectangles using Direct3D, right? If so, I'd like to direct you to these articles:

http://www.gamedev.net/reference/articles/article1972.asp
http://www.toymaker.info/Games/html/sprites.html

Share this post


Link to post
Share on other sites
Thank but no you don't understand correctly :)

I know how to display a sprite with an ortho camera or with D3DDECLUSAGE_POSITIONT (XYZRHW).

What I want is to setup a correct PERSPECTIVE camera so that a NxM rectangle in 3D look like a NxM rectangle on the screen.

The problem is this, we have :
- a rectangle of size (100, 50, 0) located at (0, 0, 0)
- a 640x480 viewport
- a 45 degree PERSPECTIVE camera located at (0, 0, Z)
What is the formula to find Z so that a 100x50 PIXELS is rendered on the screen ??

Thank.

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!