FBX import/export: Fix Camera rotation #104500

Open
Inho Lee wants to merge 1 commits from Inho-Lee/blender-addons:main into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 7 additions and 5 deletions

View File

@ -44,6 +44,7 @@ from .fbx_utils import (
BLENDER_OTHER_OBJECT_TYPES, BLENDER_OBJECT_TYPES_MESHLIKE,
FBX_LIGHT_TYPES, FBX_LIGHT_DECAY_TYPES,
RIGHT_HAND_AXES, FBX_FRAMERATES,
MAT_CONVERT_CAMERA_INVERSE,
# Miscellaneous utils.
PerfMon,
units_blender_to_fbx_factor, units_convertor, units_convertor_iter,
@ -625,8 +626,8 @@ def fbx_data_camera_elements(root, cam_obj, scene_data):
# Real data now, good old camera!
# Object transform info.
loc, rot, scale, matrix, matrix_rot = cam_obj.fbx_object_tx(scene_data)
up = matrix_rot @ Vector((0.0, 1.0, 0.0))
to = matrix_rot @ Vector((0.0, 0.0, -1.0))
up = matrix @ MAT_CONVERT_CAMERA_INVERSE @ Vector((0.0, 1.0, 0.0))
to = matrix @ MAT_CONVERT_CAMERA_INVERSE @ Vector((0.0, 0.0, -1.0))
# Render settings.
# TODO We could export much more...
render = scene_data.scene.render
@ -649,8 +650,8 @@ def fbx_data_camera_elements(root, cam_obj, scene_data):
props = elem_properties(cam)
elem_props_template_set(tmpl, props, "p_vector", b"Position", loc)
elem_props_template_set(tmpl, props, "p_vector", b"UpVector", up)
elem_props_template_set(tmpl, props, "p_vector", b"InterestPosition", loc + to) # Point, not vector!
elem_props_template_set(tmpl, props, "p_vector", b"UpVector", up - loc) # Vector
elem_props_template_set(tmpl, props, "p_vector", b"InterestPosition", to) # Point
# Should we use world value?
elem_props_template_set(tmpl, props, "p_color", b"BackgroundColor", (0.0, 0.0, 0.0))
elem_props_template_set(tmpl, props, "p_bool", b"DisplayTurnTableIcon", True)

View File

@ -57,6 +57,7 @@ FBX_KTIME = 46186158000 # This is the number of "ktimes" in one second (yep, pr
MAT_CONVERT_LIGHT = Matrix.Rotation(math.pi / 2.0, 4, 'X') # Blender is -Z, FBX is -Y.
MAT_CONVERT_CAMERA = Matrix.Rotation(math.pi / 2.0, 4, 'Y') # Blender is -Z, FBX is +X.
Review

Would rename this to MAT_CONVERT_CAMERA_IMPORT

Would rename this to `MAT_CONVERT_CAMERA_IMPORT`
MAT_CONVERT_CAMERA_INVERSE = Matrix.Rotation(-math.pi / 2.0, 4, 'Y')

Would rename this to MAT_CONVERT_CAMERA_EXPORT

Would rename this to `MAT_CONVERT_CAMERA_EXPORT`

I'm not sure MAT_CONVERT_CAMERA_EXPORT is a proper name here. MAT_CONVERT_CAMERA is need for export operations too. However this inverse matrix is required in order to property calculate special properties UpVector, InterestPosition.

I'm not sure MAT_CONVERT_CAMERA_EXPORT is a proper name here. MAT_CONVERT_CAMERA is need for export operations too. However this inverse matrix is required in order to property calculate special properties UpVector, InterestPosition.
# XXX I can't get this working :(
# MAT_CONVERT_BONE = Matrix.Rotation(math.pi / 2.0, 4, 'Z') # Blender is +Y, FBX is -X.
MAT_CONVERT_BONE = Matrix()

View File

@ -44,7 +44,7 @@ convert_deg_to_rad_iter = units_convertor_iter("degree", "radian")
MAT_CONVERT_BONE = fbx_utils.MAT_CONVERT_BONE.inverted()
MAT_CONVERT_LIGHT = fbx_utils.MAT_CONVERT_LIGHT.inverted()
MAT_CONVERT_CAMERA = fbx_utils.MAT_CONVERT_CAMERA.inverted()
MAT_CONVERT_CAMERA = fbx_utils.MAT_CONVERT_CAMERA
def validate_blend_names(name):