Camera's intrinsic and extrinsic matrices

From my understanding, in real world cameras the extrinsic matrix of the camera is the “transformation matrix” that defines xyz position and rotation, and intrinsic matrix is the “projection matrix” that maps 3D space to 2D pixel space.

In 3D graphics there’s the projection matrix that the fragment shader uses to project the clipped space to pixel coordinates (intrinsic?), and the position+rotation+scale of the camera that defines the transformation matrix (I’m guessing extrinsic?)

Question is, are these assumptions correct and if so how do I set them in panda?
I found the MatrixLens.setUserMat(), and base.make_camera() but don’t really know what do to from here

Thanks

UPDATE:
I got the matrices wrong according to this article:

You know the extrinsic matrix corresponds to the modelview matrix and the intrinsic is the projection matrix

So what’s the difference between all the matrices?

My understanding is this, in short and perhaps a little broadly:

  • The model-matrix provides the transformation between the local space of a model (such as its vertices might be defined in) to world s[ace.
  • The view-matrix provides the transformation between world space and camera-relative space
  • The projection matrix provides the transformation between camera-space and screen space.

Matrices like “ModelView”, then, are simply combinations of the above.

See the following manual page for more:
https://docs.panda3d.org/1.10/python/programming/shaders/coordinate-spaces

1 Like

To set a custom projection matrix, you can create a new MatrixLens, apply the matrix using the method you found, and then replace the existing lens on the camera using base.cam.node().setLens(lens).

To set the “view” matrix (the modelview matrix includes the transformation of the model currently being rendered) you simply set the transformation of the camera in 3D space, using base.camera.setMat(render, mat)

1 Like