   Field of view and window resizing
  How do I work out the field of view to enable me to squeeze/scale all of my objects so they're always within the field of view?  At the moment the items all scale correctly when I change the vertical height of the window, but when I squash the horizontal width of the window, they don't (going off the left and right edges of the screen as the width of the window gets smaller).I calculate the projection as follows:RECT r;GetClientRect(MyWindow, &r);float w = static_cast<float>(r.right - r.left);float h = static_cast<float>(r.bottom - r.top); float ratio = (w / h); MyCamera.SetProjection(D3DX_PI / 4, ratio, 0.1f, 10.0f); What I want is the view to be contained within a box that maintains a fixed aspect ratio, regardless of the dimensions of the window its contained within.  Anyone got any ideas on this?   
  As you suspect, you'll have to recalculate the FOV, which you currently have fixed at pi/4.You'll need to calculate the angle from your eyepoint needed to show all the objects side-to-side.You can start with the vertical angle as pi/4 and calculate the horizontal angle within the window as ratio*(D3DX_PI/4). If the window's horizontal angle is less than the needed horizontal angle, recalculate the FOV to suit.// assume horzAngle is required angle to show all objects side-to-side// you need to calculate that EDIT: in radians, of coursefloat fov = D3DX_PI/4.0f;if( ratio*fov < horzAngle ) fov = horzAngle/ratio;SetProjection( fov, ratio, ... );[Edited by - Buckeye on June 2, 2010 6:48:54 AM];  Much better than it was so thanks for that.  But it still goes off the edge a little at certain window widths:// Assumes objects cover -2.5 to 2.2 on the x axisD3DXVECTOR3 v1 = (D3DXVECTOR3(-2.5f, 0.0f, 0.0f) - MyCamera.GetEyePt());D3DXVECTOR3 v2 = (D3DXVECTOR3(2.2f, 0.0f, 0.0f) - MyCamera.GetEyePt());D3DXVec3Normalize(&v1, &v1;D3DXVec3Normalize(&v2, &v2;float angle = acos(D3DXVec3Dot(&v1, &v2));RECT r;GetClientRect(MyWindow, &r);float w = static_cast<float>(r.right - r.left);float h = static_cast<float>(r.bottom - r.top);float ratio = (w / h);// Assume we prefer a 60 degree field of view.float fov = D3DXToRadian(60.0f);if(ratio * fov < angle)    fov = angle / ratio; MyCamera.SetProjection(fov, ratio, 0.1f, 10.0f); ;  K I found the problem.  The points I'm using to work out the visible extents are wrong.  They were right for z = 0, but the geometry extends out into Z. So fixing that, it's working sweetly.Cheers.   