diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-06 21:40:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-06 21:40:39 +0400 |
commit | 5da257ab5d6cfb0c2e2a3aa44a2dfa3b776901e0 (patch) | |
tree | 6f43e0f8b40288cada45d009529b9f868227d4d8 /io_anim_nuke_chan/import_nuke_chan.py | |
parent | 07584de9c16ced5bbebbfcd44ebf4c04f00b3003 (diff) |
minor edits
- remove check if sensor width exists for chan files
- tag nuke chan files to be pep8
- remove unused import
Diffstat (limited to 'io_anim_nuke_chan/import_nuke_chan.py')
-rw-r--r-- | io_anim_nuke_chan/import_nuke_chan.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/io_anim_nuke_chan/import_nuke_chan.py b/io_anim_nuke_chan/import_nuke_chan.py index ec76955d..717c3f9d 100644 --- a/io_anim_nuke_chan/import_nuke_chan.py +++ b/io_anim_nuke_chan/import_nuke_chan.py @@ -16,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# <pep8-80 compliant> + """ This script is an importer for the nuke's .chan files""" from mathutils import Vector, Matrix, Euler @@ -27,6 +29,7 @@ def read_chan(context, filepath, z_up, rot_ord): # get the active object scene = context.scene obj = context.active_object + camera = obj.data if obj.type == 'CAMERA' else None # get the resolution (needed to calculate the camera lens) res_x = scene.render.resolution_x @@ -104,23 +107,17 @@ def read_chan(context, filepath, z_up, rot_ord): # check if the object is camera and fov data is present - if obj.type == 'CAMERA' and len(data) > 7: + if camera and len(data) > 7: v_fov = float(data[7]) - sensor_x = 0 - sensor_y = 0 - if hasattr(obj.data, "sensor_width"): # Preserve compatibility - if obj.data.sensor_fit == 'VERTICAL': - sensor_x = obj.data.sensor_width - sensor_y = obj.data.sensor_height - else: - sensor_x = obj.data.sensor_width - sensor_y = sensor_x * res_ratio + if camera.sensor_fit == 'VERTICAL': + sensor_x = camera.sensor_width + sensor_y = camera.sensor_height else: - sensor_x = 32 # standard blender's sensor size + sensor_x = camera.sensor_width sensor_y = sensor_x * res_ratio - lenslen = ((sensor_y / 2.0) / tan(radians(v_fov / 2.0))) - obj.data.lens = lenslen - obj.data.keyframe_insert("lens") + + camera.lens = ((sensor_y / 2.0) / tan(radians(v_fov / 2.0))) + camera.keyframe_insert("lens") filehandle.close() return {'FINISHED'} |