Original Post
I am using D3DXVec3Project() to output text located in 3D world space onto the screen when it's in the my cameras view. This works fine when the text is in the cameras view. However, if I move the camera (view matrix) away from the text depending upon where I am in the world sometimes D3DXVec3Project() thinks this text should be visible and so the text appears. Any ideas why? Here is my source:
D3DXVECTOR3 screenOut;
D3DXVECTOR3 source;
// Text is at origin (0,0,0)
source.x = source.y = source.z = 0;
D3DVIEWPORT9 vp;
D3DXMATRIX matProj;
D3DXMATRIX matView;
D3DXMATRIX matWorld;
m_pD3DDevice->GetViewport(&vp);
m_pD3DDevice->GetTransform(D3DTS_PROJECTION, &matProj);
m_pD3DDevice->GetTransform(D3DTS_VIEW, &matView);
m_pD3DDevice->GetTransform(D3DTS_WORLD, &matWorld);
D3DXVec3Project(&screenOut, &source, &vp, &matProj, &matView, &matWorld);
// Make certain pOut is in valid screen coordinates
if(screenOut.x >= 0 && screenOut.y >= 0 && screenOut.x < nWidth && screenOut.y < nHeight)
m_pFont->Print("(0,0,0)", screenOut.x, screenOut.y, 0, 0, 0xFFFFFF00);
Thanks for your help.
[edited by - strahan on January 8, 2004 1:34:49 PM]