[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2750] trunk/py/scripts/addons/ io_anim_nuke_chan: Added full support for film back sensor size ( 2 new properties in ImportChan class - sensor_width and sensor_height)
Michael Krupa
kroopson at wp.pl
Wed Dec 7 15:02:06 CET 2011
Revision: 2750
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2750
Author: kroopson
Date: 2011-12-07 14:02:03 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
Added full support for film back sensor size (2 new properties in ImportChan class - sensor_width and sensor_height)
Modified Paths:
--------------
trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py
trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py
trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py 2011-12-07 06:53:15 UTC (rev 2749)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py 2011-12-07 14:02:03 UTC (rev 2750)
@@ -22,7 +22,7 @@
"name": "Nuke Animation Format (.chan)",
"author": "Michael Krupa",
"version": (1, 0),
- "blender": (2, 6, 0),
+ "blender": (2, 6, 1),
"api": 36079,
"location": "File > Import/Export > Nuke (.chan)",
"description": "Import/Export object's animation with nuke",
@@ -49,7 +49,8 @@
from bpy_extras.io_utils import ImportHelper, ExportHelper
from bpy.props import (StringProperty,
BoolProperty,
- EnumProperty)
+ EnumProperty,
+ FloatProperty)
# property shared by both operators
rotation_order = EnumProperty(
@@ -81,6 +82,16 @@
description="Switch the Y and Z axis",
default=True)
+ sensor_width = FloatProperty(
+ name="Camera sensor width",
+ description="Imported camera sensor width",
+ default=32.0)
+
+ sensor_height = FloatProperty(
+ name="Camera sensor height",
+ description="Imported camera sensor height",
+ default=18.0)
+
@classmethod
def poll(cls, context):
return context.active_object is not None
@@ -90,7 +101,9 @@
return import_nuke_chan.read_chan(context,
self.filepath,
self.z_up,
- self.rotation_order)
+ self.rotation_order,
+ self.sensor_width,
+ self.sensor_height)
class ExportChan(Operator, ExportHelper):
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py 2011-12-07 06:53:15 UTC (rev 2749)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py 2011-12-07 14:02:03 UTC (rev 2750)
@@ -37,11 +37,6 @@
f_start = scene.frame_start
f_end = scene.frame_end
- # get the resolution (needed by nuke)
- res_x = scene.render.resolution_x
- res_y = scene.render.resolution_y
- res_ratio = res_y / res_x
-
# prepare the correcting matrix
rot_mat = Matrix.Rotation(radians(-90.0), 4, 'X').to_4x4()
@@ -76,12 +71,8 @@
# if we have a camera, add the focal length
if camera:
- if camera.sensor_fit == 'VERTICAL':
- sensor_x = camera.sensor_width
- sensor_y = camera.sensor_height
- else:
- sensor_x = camera.sensor_width
- sensor_y = sensor_x * res_ratio
+ sensor_x = camera.sensor_width
+ sensor_y = camera.sensor_height
cam_lens = camera.lens
# calculate the vertical field of view
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py 2011-12-07 06:53:15 UTC (rev 2749)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py 2011-12-07 14:02:03 UTC (rev 2750)
@@ -24,18 +24,13 @@
from math import radians, tan
-def read_chan(context, filepath, z_up, rot_ord):
+def read_chan(context, filepath, z_up, rot_ord, sensor_width, sensor_height):
# 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
- res_y = scene.render.resolution_y
- res_ratio = res_y / res_x
-
# prepare the correcting matrix
rot_mat = Matrix.Rotation(radians(90.0), 4, 'X').to_4x4()
@@ -109,14 +104,10 @@
# check if the object is camera and fov data is present
if camera and len(data) > 7:
v_fov = float(data[7])
- if camera.sensor_fit == 'VERTICAL':
- sensor_x = camera.sensor_width
- sensor_y = camera.sensor_height
- else:
- sensor_x = camera.sensor_width
- sensor_y = sensor_x * res_ratio
-
- camera.lens = ((sensor_y / 2.0) / tan(radians(v_fov / 2.0)))
+ camera.sensor_fit = 'HORIZONTAL'
+ camera.sensor_width = sensor_width
+ camera.sensor_height = sensor_height
+ camera.lens = (sensor_height / 2.0) / tan(radians(v_fov / 2.0))
camera.keyframe_insert("lens")
filehandle.close()
More information about the Bf-extensions-cvs
mailing list