Hi,
since I'm facing the same problem again and I was not able to find a decent explaination / solution, I will just ask here. Everytime I was hooking into the Endscene of a game in order to render my stuff ingame, I was trying to rebuild the gamematrices. Since most of the games use D3D, I simply used the god old:
Code:
D3DXVECTOR3 lookAt;
D3DXVECTOR3 eye;
lookAt = GetCameraManager()->GetLookAt();
eye = GetCameraManager()->GetEye();
D3DXMatrixLookAtLH(&viewMatrix, &eye, &lookAt, &D3DXVECTOR3(0, 0, -1));
D3DXMatrixPerspectiveFovLH(&projectionMatrix,fieldOfView,aspectratio,near_plane,far_plane);
D3DXMatrixIdentity(&worldMatrix);
pdevice->SetTransform(D3DTS_VIEW, &viewMatrix);
pdevice->SetTransform(D3DTS_PROJECTION, &projectionMatrix);
pdevice->SetTransform(D3DTS_WORLD, &worldMatrix);
With this extremlazy n easy way, I only needed to grab the variables:
CameraPosition
CameraLookAt
The problem why I'm writing this post comes from:
Aspectratio (= device->ViewPort.Width / Viewport.Height)
FoV (is a static afaik.)
Everytime one is resizing his screen, the drawn stuff is not allocated at the correct position anymore (which is logical since the perspective is changing). Now the thing is, FieldOfView is a static from what I know and the aspectratio is also (always???) calculated from pretty much self explaining values (width/height). Is it even possible to match the ingame-matrices with the rebuild ones all the time? Is there a formula to calculate the correct FoV or aspectratio? Am I mixing horizontal and vertical FoV somehow?
Thanks for a hint^^