Is there any way to set camera’s projection matrix or to create a new one with it.
I am exchanging xml files with view-world and projection matrices between different software and in blender I am stuck.
I use the calc_matrix_camera() to get the projection matrix but how to set it ?
One option would be to decompose the matrix, do the math and then apply the properties to their appropriate fields, although this way would be really annoying and not that accurate since floats will be trimmed and more trial and error will be needed.
Any suggestions ?
Thanks in advance!
Python api dosen’t expose camera projection matrix setter.
As an alternative you could use well documented external format like .obj, set your camera matrix and then import the camera.
@stephen_leger , I see thank you for your quick response. If I set them manually to the related fields should I force update then Blender’s UI ?
Forgot another alternative.
You may use view3d matrix property, and then create a camera from view.
Take a look at stored views 2.79 addon as reference
https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/stored_views
If you are both creating / updating camera and perform another action in the same script, then yes you have to properly update (probably scene.update() ) your context in the between.
1 Like