Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm very new in 3D. I have a DirectX control which I want to be able to resize. A 3D object is shown in the control. On resize, I would like that object to stay the same size, only more of its environments should be visible. As I understand, I only need to change the FOV for this, and I tried to deduce how from the second image here http://msdn.microsoft.com/en-us/library/windows/desktop/bb206341(v=vs.85).aspx.

My "solution" is:

    float newFov = (float)(2 * Math.Atan((height / prevHeight) * Math.Tan(fov / 2)));
    projection = Matrix.PerspectiveFovLH(fov, width / height, zNear, zFar); 

(fov is the vertical fov here before the resize, height is the control's NEW height, width is its NEW width)

Problem is, this is not working, if I change the control's width only it looks OK (but then FOV really doesn't change, only aspect ratio), but if I change the height too my object is scaled. I'm starting to think that something in my thinking is fundamentally wrong. I would appreciate any help from you 3D gurus out there.

share|improve this question
    
Additional info I want to add here: basically, I want to implement the pixel-based scaling method described here en.wikipedia.org/wiki/Field_of_view_in_video_games. –  canahari Jan 20 '13 at 20:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.