Skip to main content
gamedev.net
🔒 Locked

Distance from perspective camera

Started by Rhapsodus Mar 1, 2004 at 6:19 PM 0 replies 350+ views
Original Post
Rhapsodus
Rhapsodus
I think this is a simple formula, but I can''t find a reference to it at the moment, probably one that is asked for a lot... I have a perspective camera set up...
D3DXMATRIX matProj;
// Set the projection matrix

FLOAT      fFOV = D3DX_PI/3;
FLOAT      fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, fFOV, fAspect, 10.0f,12000.0f);
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

//given x & y,

//need to find,  Position( x, y, z ), fWidth, fHeight

// such that a pixel in the texture file, is a pixel on the screen

Now, what I am trying to solve for is the distance away from the camera such that a pixel in a texture for a 2d billboard floating in world space is still a pixel... What I mean is, I have a texture mapped to a dynamic billboard. And I am trying to put this billboard at location P( x, y ) where x and y is in pixels, but I can''t figure out how far away from the camera the billboard has to be such that a pixel remains a pixel.... Any ideas?
Fantasio
Fantasio
use distance from a point to a plane formula:

Dist = DotProduct(Plane.Normal,Point);

and plane will be, camera projection plane

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.