View Full Version : translating c++ function into maxscript gives different results.
12-09-2010, 11:56 AM
I'm writing a exporter in maxscript, right now I'm working on getting the FOV correctly.
I just took the c++ code line (which works perfectly):
FOV = cam->GetFOV(t) * 360 / ( 2*PI );
and translated it into maxscript:
FOV = ($.fov * 360) / (2*pi)
The problem is that from c++ the output (which is correct) gives the value:
"float fov" [31.596395]
but the weirdest thing is that maxscript gives this:
"float fov" [3059.87]
What am I doing wrong?
Is there a workaround?
any help is greatly appreciated.
thanks in advance.
12-09-2010, 12:08 PM
I am not really familiar with the sdk but from the looks of your code I am guessing that cam->GetFOV(t) returns the angle in radians which is why you are multiplying by 180/PI (to convert to degrees) where the cam.fov property in maxscript already returns the value in degrees
12-09-2010, 12:09 PM
EDIT: duplicate post...
12-09-2010, 01:39 PM
hi thanks for the reply,
i see what you say, but still there's something else going on.
When the camera has a FOV value of "67,697" set on the camera
it outputs "float fov" [53.404789]
and then maxscript outputs the value directly:
"float fov" [67.6969]
If i then render the maxscript value it looks off from the result I need, which is the one that c++ outputs..
so there has to be something going on in that c++ function that does this to the numbers..
12-09-2010, 01:56 PM
ok so my next guess is that cam->GetFOV(t) returns the vertical FOV where as cam.fov in maxscript returns the horizontal fov. to get the vertical FOV in mxs you need to set the camera's fovType property to 2 (meaning vertical) and then get the FOV using cam.curFov
12-09-2010, 02:16 PM
i got an error when trying to get the property you said,
but then I found a piece of script in the helpfile that got me the value I needed.
the results are very accurate now.
thank you for pointing me in the right direction.
I use the following code to accomplish my result:
r_aspect=(renderWidth as float)/renderHeight
corrected_fov = 2.0*atan(tan($.fov/2.0)/r_aspect)
12-09-2010, 02:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.