FBX import/export: Fix Camera rotation #104500
@ -44,6 +44,7 @@ from .fbx_utils import (
|
|||||||
BLENDER_OTHER_OBJECT_TYPES, BLENDER_OBJECT_TYPES_MESHLIKE,
|
BLENDER_OTHER_OBJECT_TYPES, BLENDER_OBJECT_TYPES_MESHLIKE,
|
||||||
FBX_LIGHT_TYPES, FBX_LIGHT_DECAY_TYPES,
|
FBX_LIGHT_TYPES, FBX_LIGHT_DECAY_TYPES,
|
||||||
RIGHT_HAND_AXES, FBX_FRAMERATES,
|
RIGHT_HAND_AXES, FBX_FRAMERATES,
|
||||||
|
MAT_CONVERT_CAMERA_INVERSE,
|
||||||
# Miscellaneous utils.
|
# Miscellaneous utils.
|
||||||
PerfMon,
|
PerfMon,
|
||||||
units_blender_to_fbx_factor, units_convertor, units_convertor_iter,
|
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!
|
# Real data now, good old camera!
|
||||||
# Object transform info.
|
# Object transform info.
|
||||||
loc, rot, scale, matrix, matrix_rot = cam_obj.fbx_object_tx(scene_data)
|
loc, rot, scale, matrix, matrix_rot = cam_obj.fbx_object_tx(scene_data)
|
||||||
up = matrix_rot @ Vector((0.0, 1.0, 0.0))
|
up = matrix @ MAT_CONVERT_CAMERA_INVERSE @ Vector((0.0, 1.0, 0.0))
|
||||||
to = matrix_rot @ Vector((0.0, 0.0, -1.0))
|
to = matrix @ MAT_CONVERT_CAMERA_INVERSE @ Vector((0.0, 0.0, -1.0))
|
||||||
# Render settings.
|
# Render settings.
|
||||||
# TODO We could export much more...
|
# TODO We could export much more...
|
||||||
render = scene_data.scene.render
|
render = scene_data.scene.render
|
||||||
@ -649,8 +650,8 @@ def fbx_data_camera_elements(root, cam_obj, scene_data):
|
|||||||
props = elem_properties(cam)
|
props = elem_properties(cam)
|
||||||
|
|
||||||
elem_props_template_set(tmpl, props, "p_vector", b"Position", loc)
|
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"UpVector", up - loc) # Vector
|
||||||
elem_props_template_set(tmpl, props, "p_vector", b"InterestPosition", loc + to) # Point, not vector!
|
elem_props_template_set(tmpl, props, "p_vector", b"InterestPosition", to) # Point
|
||||||
# Should we use world value?
|
# 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_color", b"BackgroundColor", (0.0, 0.0, 0.0))
|
||||||
elem_props_template_set(tmpl, props, "p_bool", b"DisplayTurnTableIcon", True)
|
elem_props_template_set(tmpl, props, "p_bool", b"DisplayTurnTableIcon", True)
|
||||||
|
@ -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_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.
|
MAT_CONVERT_CAMERA = Matrix.Rotation(math.pi / 2.0, 4, 'Y') # Blender is -Z, FBX is +X.
|
||||||
|
|||||||
|
MAT_CONVERT_CAMERA_INVERSE = Matrix.Rotation(-math.pi / 2.0, 4, 'Y')
|
||||||
Bastien Montagne
commented
Would rename this to Would rename this to `MAT_CONVERT_CAMERA_EXPORT`
Inho Lee
commented
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 :(
|
# 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.Rotation(math.pi / 2.0, 4, 'Z') # Blender is +Y, FBX is -X.
|
||||||
MAT_CONVERT_BONE = Matrix()
|
MAT_CONVERT_BONE = Matrix()
|
||||||
|
@ -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_BONE = fbx_utils.MAT_CONVERT_BONE.inverted()
|
||||||
MAT_CONVERT_LIGHT = fbx_utils.MAT_CONVERT_LIGHT.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):
|
def validate_blend_names(name):
|
||||||
|
Loading…
Reference in New Issue
Block a user
Would rename this to
MAT_CONVERT_CAMERA_IMPORT