[Closed] camera view and projection matrices
Is there a way in max script to get a cameras view matrix and its projection matrix?
the max script help files have nothing on this
The camera view matrix is the inverse of the camera node’s transformation matrix
inverse $Camera01.objecttransform
If the current view is a camera, the above is equivalent to
viewport.getTM()
Also take a look at “How To … Develop a Vertex Renderer” which deals with transforming world space coordinates into view coordinates and projecting them onto the image plane.
The methods and tutorials are there, but they assume that you know what you are looking for…
So to get the camera view matrix, i need to set that as the active viewport first.
Cheers, ill check these out.
Nope, you don’t have to. You can EITHER use the inverse of the camera objecttransform (even if the camera is not set as the active view), OR get the view TM which will let you use whatever view is there, incl. Camera, Perspective, Light etc. (but ortho projections like Top, Front and User might be tricky).
As I said, the results from the two methods are equivalent.
I used viewport.GetTM() in the “How To…” example because that way you can render any viewport even if there is no camera in the scene. But if your script KNOWS the camera, you can just use its matrix…