Perspective camera and field of view
I am trying to figure out where to position the camera to view a certain rectangle (of a planar slice) in my scene. I need to do this on the fly so I can't just find a position that works, I need to be able to calculate it. When this didn't seem to work I went back to a very basic test scene and it appears that I do not fully understand how it works. Here is a simple setup:
I have a 100*100*100 cube positioned at (50, 0, 0). This should mean that one of the faces have the four corners (0, -50, -50), (0, 50, -50), (0, 50, 50) and (0, -50, 50), ie a 100*100 square on the X=0 plane. Next I place a camera at (-x, 0, 0) looking in the direction of positive x, towards this face. The question is how far away, ie what must x be, to show the entire height of the face (but no more), like shown in this picture.
The vertical field of view for the camera is set to 90 degrees, so the angle up the the camera midline to the upper frustrum should be 45 degrees, and this should view half of the height of the cube face, which is 50, like in this delightful piece of coder art.
So basic trigonometry should indicate tan(45 deg) = 50 / x, which yields x = 50. However setting the camera x position to -50 does not show the full height of the cube, hand adjusting it seems to end up showing the full height at around -88. Am I completely misunderstanding the camera system?
asked Apr 28 '14 at 11:45 PM in Using UE4
Problem solved! Apparently, despite what the tooltip says, the FOV is horizontal.
answered May 05 '14 at 12:24 AM
Actually, FOV is calculated from the widest dimension of the render target (texture).
Say, you have a SceneCapture2D and a target texture. If that texture has dimensions w > h, then further growth of w won't alter horizontal FOV (it remains the same for horizon). Otherwise, if h > w, then the FOV of your SceneCapture2D remains the same for the vertical view. You can test it playing with dimensions of the target texture.
answered Apr 04 '16 at 09:00 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here