I have custom exporter which exports data from blender to opengl app.
To convert meshes to opengl space I used:
global_matrix = axis_conversion(to_forward="-Z", to_up="Y").to_4x4()
Then when I export mesh I call mesh.transform(global_matrix)
and vertex position is correct.
Each object I export as reference to mesh and transform matrix. To convert transform matrix I use:
matrix_world = global_matrix * obj.matrix_world * global_matrix
If I set axis_conversion forward to Z it works (but model is not facing camera), but -Z have wrong results.
Bellow is scene in blender, there are two triangle shaped objects and three cones.
This is wrong image, triangles are placed correctly but cones are upside down (used forward_axis -Z)
This image is shows objects exported with correct positions but wrong axis (used Z instead of -Z)
How can I fix this? Why are the results wrong with -Z?
matrix_world = global_matrix.transposed() * obj.matrix_world * global_matrix
? $\endgroup$matrix_world = global_matrix * obj.matrix_world * global_matrix.transposed()
and it is working $\endgroup$