I have a problem with a small osc callback which changes the camera data.
Setting camera lens and manipulating the projection matrix seems not to work at the same time. I can either change the lens or manipulate projection matrix per frame.
I’m not much into the internals, maybe someone can help me out or give a pointer how the projection_matrix is applied.
OSC Callback:
def update_camera(self, path, args):
scene = bge.logic.getCurrentScene()
camera = scene.cameras[args[0]]
camera.lens = args[1]
camera.ortho_scale = args[2]
camera.near = args[3]
camera.far = args[4]
camera.perspective = args[5]
# if lens is changed the lensshift code will be ignored
projection_matrix = camera.projection_matrix
shift_x = args[6]
shift_y = args[7]
projection_matrix[0][2] = 2*shift_x
projection_matrix[1][2] = 2*shift_y
camera.projection_matrix = projection_matrix
The lens parameter is one parameter that is used to calculate the projection matrix.
I do not know the implementation details. It might be that changing the lens does not immediately change the projection matrix and vice versa.
I suggest to use one method only whether camera arguments or matrix manipulation. One is like clicking “idiot-proof-buttons”. The other one is like an open-heart surgery ;). It allows much more freedom but has no security net if it fails.
Additional I recommend to read the wiki about projection matrix. I think that should help :).
In reflection, I don’t think that math.e is relevant. I had glanced over and thought you were deriving it by hand but it appears to be completely irrelevant.
It’s just a variable name in this case. As far as I understand, it’s the scaling of the projection matrix that’s equivalent to the camera lens or viewing angle.