Corona Renderer Forum

General Category => Porting and API => Corona Standalone => Topic started by: Ondra on 2013-06-06, 13:02:14

Title: How to compute camera from TM matrix
Post by: Ondra on 2013-06-06, 13:02:14
Suppose you only have the camera transformation matrix and want to compute camera parameters from it. The easiest way to do this is to just transform these points with the inverse of the camera TM:
a: 0, 0, 0
b: 0, 0, -1
c: 0, 1, -1
Camera origin is then A, camera target is B, and camera roll is (C-A) normalized. This makes sense if you realize that the camera transformation matrix does nothing else than transforming points from world space to a space where camera origin is at 0 0 0, view direction is in the negative z axis, and "up" is in the y axis. It is possible that your 3D application uses another convention, then just modify the three input points.

If your camera does not provide FOV information, then again just compute point D projected into (0, 0) image point and point E projected into (0, width/2), and do acos(dot(norm(D-A), norm(E-A))), where A is the projected 0, 0, 0 point
Title: Re: How to compute camera from TM matrix
Post by: ohsnapitsjoel on 2013-06-19, 07:54:07
Man, I wish I understood all this but I don't think I'm smart enough!  Could you by chance dumb it down a shade for me?  :)

Title: Re: How to compute camera from TM matrix
Post by: Ondra on 2013-06-19, 10:42:15
just ignore the explanation and transform the three points with the inverse of camera matrix ;). Or contact me on skype, my id is ondra.karlik