PDA

View Full Version : emulating mayas camera


laserpanda
11-11-2005, 02:28 AM
Hi
im trying to export mayas camera data into another application, and while ive got translation and rotation right, im having a problem with getting the "lens" right.

im using simple trigonometry to convert my 3d-points to 2d, and with my algoritm (that creates an imaginary image plane in front of the camera) a fov of 800 translates roughly to mayas FOV50... so id like to know if theres a known formula for this... itd be great if i could stay away from matrices since 1. i dont know em, 2. im using a basic scripting languange to import the camera data where it could be a bit tricky to do.

thanks
G

harmless
11-11-2005, 06:06 PM
You sound like a bright person so I won't bother converting this to melscript. Whenever I forget anything about extracting data related to the field-of-view from a camera I always refer to this function and write my new function. I suspect you will be able to do the same.

function VFov2HFov vFOV =
(
--calculate the Horizontal FOV
local halfVFov = vFOV / 2.0
local imageAspect = ((renderHeight as float) / (renderWidth * renderPixelAspect))
local halfHFov = atan ((tan(halfVFov)) / imageAspect)
local HFov = 2 * halfHFov

return HFov
)

laserpanda
11-12-2005, 03:44 AM
Hi

thanks for your answer. maybe im not as smart as you assumed, or i was just not explaining clearly. I need an algoritm to convert 3d coordinates (x,y,z) to 2d (x,y) and i need the results to be exactly the same as they would be in maya with the same values (same fov) (also, does the gate size have to be taken into consideration too?)

this is what im using right now (which works, but doesnt match maya)

x2d = (.5*resolutionX)+(tand(atan2d(x3d,z3d))*fov);
y2d = (.5*resolutionY)+(tand(atan2d(y3d,y3d))*fov);

i hope this explains better what i want to do.
thanks,
G

earlyworm
11-14-2005, 07:14 AM
it sounds like you want to do this:

http://www.ewertb.com/maya/mel/mel.php?howto=87

http://www.185vfx.com/resources/screenSpace.mel

you don't need to do any matrix manipulation on the other end.

I'm assuming the program on the receiving end of this is a compositing package.

laserpanda
11-15-2005, 12:59 AM
awesome!

my script now works, after a whole day worth of bughunting. its a maya->shake 3d camera exporter and i tell yall shake has some serious script compilation issues :)

anyways it all works, thank you earlyworm for the link!
/G

CGTalk Moderation
11-15-2005, 12:59 AM
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.