Hello,

[I am using Panda3d python APIs]

I have a physical camera’s intrinsic matrix that I am trying to mirror to a panda3d virtual camera. I came across a number of forums posts that indicated that in order to create a Lens with a custom projectionmatrix I have to use MatrixLens.setUserMat() and pass it my projection matrix. I created a projection matrix that is similar to an OpenGL projectionMatrix such as this:

camera_matrix = [focal_length_x 0 0 0

0 0 A 1

0 focal_length_y 0 0

0 0 B 0 ]

Where A = (zfar + znear) / (zfar - znear)

and B = -2 * znear*zfar / (zfar - znear)

matrix_lens = MatrixLens()

matrix_lens.setUserMat(camera_matrix)

On setting the projection matrix as such, I tried to query the parameters of the matrix such as:

matrix_lens.getAspectRatio()

matrix_lens.getFilmSize()

matrix_lens.getFocalLength()

matrix_lens.getFar()

matrix_lens.getNear()

matrix_lens.getFov()

However, the corresponding values that are returned do not seem to be computed from the projection matrix that was passed, so I get values that seem like defaults such as these:

Aspect Ratio: 1.0

Film Size: LVecBase2f(2, 2)

Focal Length: 1.0

Coordinate system: 0

Far: 100000.0

Near: 1.0

FOV: LVecBase2f(30, 30)

Keystone: LVecBase2f(0, 0)

If I query the projection matrix using matrix_lens.getProjectionMat() I get back the matrix that I passed in. I also find that the camera does not render the objects in the scene as intended.

My question (a) is why are the lens properties (such as FOV, aspectratio) not computed when I pass in a projection matrix? Do I have to call some other function to have Panda3D compute these values?

(b) In an OpenGL projection matrix I was also able to set the offsets to the principal point. How do we set the same in a panda3D projection matrix? When I set it as the corresponding fields C (x-coordinates) and D (y-coordinates) in the below matrix, the camera was no longer pointing at the scene I intended:

[ focal_length_x 0 C 0

0 0 A 1

0 focal_length_y D 0

0 0 B 0]

Thanks.