-->

With this post I’m taking a quick step back from my First Steps in Papervision3D series to examine the zoom, focus and field of view camera parameters. With OpenGL, which is what I’m used to, the viewport is specified with a field of view (FoV), being the vertical visible angle, and then translations are made to bring the observer closer or further away from a particular subject. With a camera, as in Papervision3D, its only normal that you can modify the zoom and change the focus, but what do these variables mean and how do these change the visible aspects of the rendered scene?

I decided to write a little demo to explore the effects of each of these variables to get a better feeling of what they do visually. I have to admit that before doing this it wasn’t immediately obvious what was happening when I changed the focus : zoom I could understand because objects got larger when I increased the zoom. What I didn’t realise was that for a particular value of zoom, changing the focus changes the field of view and vice versa. So, unlike OpenGL, the field of view isn’t constant : zooming and changing the focus are related through the field of vision.

Looking in the code of Papervision3D, specifically the class CameraObject3D, you’ll see that the equation governing the three variables is :

f = h / (z * tan α)

where f = focus, h = half the viewport height and α is half the vertical field of view. This is shown more clearly in this diagram, where, if we ignore the zoom then tan α = h / f from simple trigonometry.

So we see that clearly focus, in Papervision3D, is simply the distance between the camera and the viewport, given by the field of vision (being 2 * α).

Zooming is equivalent to magnifying elements at the viewport. With a 2* zoom, an object appears twice as big. Hence, without changing focus, we need to diminish the field of vision so that an object has an effective size twice its actual. As seen below this relates to tan α = h / (2 * f)

Generalising this rule we get tan α = h / (z * f).

So what does this mean? When you create a camera object in Papervision3D, the field of vision does not remain fixed if you zoom or change the focus. If you change the field of vision (manually), this relates to a change in focus (keeping the zoom fixed). Visually, if you reduce the zoom (keeping focus fixed) or decrease the focus (keeping zoom fixed) you will increase the field of vision and can easily have a fish-eye lens effect occurring on the screen - a distorted, extreme perspective view. Similarly, by increasing either the zoom or focus you decrease the field of vision, so for a large focus and large zoom you can have a very small field of vision at which point the perspective becomes much less noticeable.

So, here’s the demo (click on the image below) that illustrates these characteristics. You can use the sliders to change the zoom and focus - you’ll see the field of vision change. Similarly you can specify the field of vision and see the focus change. Also, to illustrate another way of “zooming” you can simply modify the position of the camera (keeping zoom and focus fixed) - this is what I’ve been used to in OpenGL transformations. You can move the camera around the scene by clicking on the scene and moving the mouse. You can see quite clearly that decreasing either zoom or focus can easily produce a fish-eye lens effect on the scene.