Sign in to follow this  
voodoohaust

Camera distance issue.

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this