Sign up ×
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

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

closed as off-topic by Josh Petrie Aug 1 '14 at 15:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

Additional info I want to add here: basically, I want to implement the pixel-based scaling method described here – canahari Jan 20 '13 at 20:41
Shouldn't that there be float newFov = (float)(2*Math.Atan(width/(2*zNear))); ? – Anurup Dey Jun 26 '14 at 16:45

Browse other questions tagged or ask your own question.