Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Vertical FOV and Horizontal FOV

Author
Message
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 9th Jun 2011 17:23
Hello,

I have been working on something. But I discovered I need the horizontal AND the vertical FOV. I guessed that the dbSetCameraFOV(float iFOV); command works somehow with both of them. And after that I considered the possibility that it can have to do with the camera aspect or the presetted screen width and height in pixels.

I am wondering if I can retrieve the HFOV and VFOV, and if so how?

Thanks,

RedEye

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 10th Jun 2011 09:27 Edited at: 10th Jun 2011 09:30
im not quite sure, but i think dbSetCameraFOV sets the VFOV, and the HFOV = aspect * VFOV where aspect = width/height

you can try that out and if it doesn't work, try to assume that dbSetCameraFOV sets the HFOV and VFOV = (1/aspect) * HFOV and we used 1/aspect because aspect = width/height, we want height/width in this case

Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 10th Jun 2011 14:07
Aye, cool. Will try, thanks!

Another question with on the same subject.

If we are talking about the zoom of a camera, we normally mean the fov of the camera, am I right?

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 10th Jun 2011 17:25 Edited at: 10th Jun 2011 17:26
i dont know whether the zoom is the FOV, but since less field of view would make things look bigger, that could be one way of achieving a zoom effect.

though, i have never implemented such thing, well i know that, zoom = camera distance from a point, you could do like, have a 3D point representing the camera original position, and in every frame, re-position the camera there, and dbMove the camera with the amount of zoom you want, but i could imagine a nice looking effect if you could merge both, displacement and FOV

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Jun 2011 10:45 Edited at: 11th Jun 2011 10:50
A little "googling" (if that's a verb?) will find you the formula to convert between horizontal and vertical field of view. I didn't know either but it seems that that the aspect ratio is applied to the tangent of the angle, not the angle itself.

http://www.rjdown.co.uk/projects/bfbc2/fovcalculator.php

http://forums.create.msdn.com/forums/t/82737.aspx

I also had a quick look at the Dark GDK source code. It seems that the Dark GDK command sets the vertical field of view, because it eventually ends up calling D3DXMatrixPerspectiveFovLH and one parameter of that function is FOV "in y direction".

http://msdn.microsoft.com/en-us/library/bb205350%28v=vs.85%29.aspx

I also found an article about field of view in video games, it doesn't mention horizontal-vertical but talks about scaling.

http://en.wikipedia.org/wiki/Field_of_view_in_video_games
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Jun 2011 10:49
About zooming: Changing the camera distance and FOV is not quite the same effect. When you move the camera closer, the perspective distortion will be bigger. If the camera is far away, but you "zoom in" by reducing the FOV, the objects will look bigger but with less perspective effect. In one newsletter article for example, it was recommended to use a large camera distance and a narrow FOV to remove perspective from a game which was supposed to look like 2D.
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 11th Jun 2011 10:59
Thank you for the information both Hassan and Mireben. I learnt some cool new things!

But I asked that question about zoom, because of this:

http://freespace.virgin.net/hugo.elias/routines/3d_to_2d.htm

...where there is stated:
Quote: "
zoom is the is the distance beetween the origin and the 45° mark. By altering the zoom, or changing it independantly for the x and y lines, effects like fish eye can be produced."


It sounded like the same effect as fov does, doesnt it?

Cheers,

Leo

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Jun 2011 12:01 Edited at: 11th Jun 2011 12:24
It sounds similar. My 3D math is long forgotten unfortunately, but according to my book, the way to convert 3D coordinates to screen is this (based on two similar triangles):

x_perspective = x / z * viewing_distance;

The difference in the article you quoted is that he does not multiply with viewing distance (that's the distance of the camera from the projection plane), but substitutes a distance in the perpendicular direction. Actually, the final effect should be very similar than changing the camera distance in the above equation. Maybe he uses this value because it's easier to calculate than the camera distance, if the angle and position of the camera changes, or maybe it somehow combines the effect of distance and FOV. Just guessing, I don't pretend to be a mathematician...
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 12th Jun 2011 02:35
Aah thanks for the information! I got it sorted out. It is working. Hope to get this soon on WIP Forum. Thanks guys.

Greets,

Leo

Login to post a reply

Server time is: 2024-11-19 10:29:08
Your offset time is: 2024-11-19 10:29:08