TGC Codebase Backup



Set Camera FOV using x and y values by Plystire

23rd Sep 2007 21:15
Summary

Using this function you can set the FOV of any camera using two angles for x and y.



Description

It is important to understand the parameters passed into this function:

Camnum - Number of the camera you wish to alter the FOV for
XAngle# - The X Angle (Horizontal) that you want the FOV to be changed to
YAngle# - The Y Angle (Vertical) that you want the FOV to be changed to
DX# - The Width of the camera's resolution (Or width of a plane that the camera's image is being textured on to)
DY# - The Height of the camera's resolution (Or height of a plane that the camera's image is being textured on to)
D# - This is the "Near" value of the camera's range, defaulted at 1 or changed by the function "Set Camera Range"

Using the parameters, the "Set Camera FOV" and "Set Camera Aspect" functions are used together to provide the appearance of a new FOV that is based upon two different (or same, even though it would be pointless, since the "Set Camera FOV" function will do that anyway) angles.


~PlystirE~



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function set_camera_fov(camnum, xangle#, yangle#, dx#, dy#, d#)

set camera fov camnum, yangle#
set camera aspect camnum, (d#*tan(0.5*xangle#)*2*dx#)/(d#*tan(0.5*yangle#)*2*dy#)

endfunction