Jump to content
  • Advertisement
Sign in to follow this  
Carnevil_

Creating perspective view with X/Z FOV

This topic is 3902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to create a perspective view with an FOV of 45 degrees along the X or Z axis; NOT the Y axis. My problem is that D3DXMatrixPerspectiveFovLH takes a FOV parameter for the Y axis, and I'm having a great deal of difficulty of converting my FOV in the X/Z axis to a FOV in the Y axis that I can pass in. I've tried a number of different methods (such as "fovy = fovx / aspect"), but nothing seems to get me the result I'm looking for. I have a camera set up in the center of a box, and the corners of the box should be exactly at the left and right sides of my screen. What's the best way to do this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
It sounds like the box is really a cube, right? (to make the corners of the box to be at the sides of the screen for both x and z directions)

The field of view from the center of a cube to the corners is 90 degrees, not 45. Your eyept would have to be at the back wall of a cube for the front corners to be 45 degrees apart ( 22.5 degrees to either side ).

If your eyept is at the back wall (to get a 45 deg fov along x-z axes), the y angle is 2*atan( h/(2*w) ) where h is the height of the screen and w is the width. If your aspect is w/h, then y-angle = 2*atan(1/(2*aspect)).

Does that help?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!