Field of view control
by Mac McGaffigan · in Torque Game Engine · 06/14/2005 (7:53 pm) · 12 replies
How difficult would it be to create a field of view control (like ut 2004) I personally despise a wide angle view, or rather the distortion it creates, but some people like it? just a point in the right direction would be appreciated.
About the author
#2
06/14/2005 (9:04 pm)
Alright now I have a slider control. Thank you. If i can just get the zoom to scale with it, I'll be in business.
#3
x2 Zoom would be current FOV / 2
x4 Zoom would be current FOV / 4
x8 Zoom would be current FOV / 8
So using 90 degrees as our default FOV (which is what TGE uses)
setDefaultFOV(90); (this is stored in $pref::Player::defaultFov)
To do a x2 zoom we would use
setFov(45);
for x4 zoom: (90/4 = 22.5)
setFov(22.5);
for x8 zoom: (90/8 = 11.25)
setFOV(11.25);
NOTE: FOV can only be between 5 and 120 degrees
06/14/2005 (10:40 pm)
Well technically the Zoom is nothing more then setting the FOV.x2 Zoom would be current FOV / 2
x4 Zoom would be current FOV / 4
x8 Zoom would be current FOV / 8
So using 90 degrees as our default FOV (which is what TGE uses)
setDefaultFOV(90); (this is stored in $pref::Player::defaultFov)
To do a x2 zoom we would use
setFov(45);
for x4 zoom: (90/4 = 22.5)
setFov(22.5);
for x8 zoom: (90/8 = 11.25)
setFOV(11.25);
NOTE: FOV can only be between 5 and 120 degrees
#4
06/15/2005 (1:50 am)
Thanks. I've been trying to something similar myself!!
#5
06/15/2005 (7:30 am)
I meant that i wanted to get the FOV change from zoom to be half of whatever new FOV the user sets with the FOV slider. Thanks for your help.
#6
$cameraFov is the global variable that tracks the camera's FOV. I just assigned it to the global $oldFov before updating the FOV to be half the current FOV when zooming.
06/15/2005 (10:31 am)
In client/scripts/default.bind.cs change the toggleZoom function.$cameraFov is the global variable that tracks the camera's FOV. I just assigned it to the global $oldFov before updating the FOV to be half the current FOV when zooming.
function toggleZoom( %val )
{
if ( %val )
{
$ZoomOn = true;
$oldFov = $cameraFov;
setFov( $cameraFov / 2 );
}
else
{
$ZoomOn = false;
setFov( $oldFov );
}
}
#7
I take it they're built into the engine...
Why these particular numbers? Do some of the 3d algorithms start choking past this range, or is this just a practical thing?
06/15/2005 (10:50 am)
Quote:
NOTE: FOV can only be between 5 and 120 degrees
I take it they're built into the engine...
Why these particular numbers? Do some of the 3d algorithms start choking past this range, or is this just a practical thing?
#8
06/15/2005 (12:13 pm)
Lower than 5, can't really see anything, so what's the point? Beyond 120 you get some cool fisheye distortion, and as you reach 180, things blow up. At least, that's what happened in my own 3d work.
#9
08/03/2005 (2:03 pm)
I submited a resource on this topic it should be appearing shortly.
#10
Cast a ray from the players position, and physically move the viewing frustrum(camera) along this line. This way the zoomed in image doesn't distort/stretch or alter perspective too much.
To stop the camera viewing behind walls etc. do a collision test along this line.
The only reason I am looking at that as a solution is it 'feels' more realistic. (sorry if it is hard to visualise, it is a concept that I would like to play around with).
08/03/2005 (3:03 pm)
Why change the FOV, this does distort the image a bit you do tend to get strange fisheye effects and really bad tunnel vision with traditional FOV adjustments. Why not try this (it is an idea I'm dying to try out).Cast a ray from the players position, and physically move the viewing frustrum(camera) along this line. This way the zoomed in image doesn't distort/stretch or alter perspective too much.
To stop the camera viewing behind walls etc. do a collision test along this line.
The only reason I am looking at that as a solution is it 'feels' more realistic. (sorry if it is hard to visualise, it is a concept that I would like to play around with).
#11
08/03/2005 (4:53 pm)
I'd be interested to see some examples of the difference this gives. In general for sniper and zoom stuff, altering the FOV is the correct solution - it accurately models the optics of the situation.
#12
08/04/2005 (3:48 pm)
Http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3428 I think this is what you're talking about Roger but as Ben pointed out FOV technicaly would be the correct solution. I submitted it recently they need to check it first which has taken a while in previous experiences. The FOV worked well. And the camera solution has problems going through walls and is all in all harder. I have code in resource form that never got posted if anybody wants that.
Torque Owner Harold "LabRat" Brown
press ~
type:
setFov(45);
press enter