Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Krupa <kroopson@wp.pl>2011-12-07 18:02:03 +0400
committerMichael Krupa <kroopson@wp.pl>2011-12-07 18:02:03 +0400
commitc2bb44d9b8b7cb5ab783aa30fe586e04dfacbbd8 (patch)
treebea5f09bb4571d8d2cee126892ef481459f361ef /io_anim_nuke_chan
parent95358abe28a16b085f3ffce691d86d035101aa5b (diff)
Added full support for film back sensor size (2 new properties in ImportChan class - sensor_width and sensor_height)
Diffstat (limited to 'io_anim_nuke_chan')
-rw-r--r--io_anim_nuke_chan/__init__.py19
-rw-r--r--io_anim_nuke_chan/export_nuke_chan.py13
-rw-r--r--io_anim_nuke_chan/import_nuke_chan.py19
3 files changed, 23 insertions, 28 deletions
diff --git a/io_anim_nuke_chan/__init__.py b/io_anim_nuke_chan/__init__.py
index 4a267b02..7df69dff 100644
--- a/io_anim_nuke_chan/__init__.py
+++ b/io_anim_nuke_chan/__init__.py
@@ -22,7 +22,7 @@ bl_info = {
"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.types import Operator
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 @@ class ImportChan(Operator, ImportHelper):
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 @@ class ImportChan(Operator, ImportHelper):
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):
diff --git a/io_anim_nuke_chan/export_nuke_chan.py b/io_anim_nuke_chan/export_nuke_chan.py
index bae6762a..e0fdefb5 100644
--- a/io_anim_nuke_chan/export_nuke_chan.py
+++ b/io_anim_nuke_chan/export_nuke_chan.py
@@ -37,11 +37,6 @@ def save_chan(context, filepath, y_up, rot_ord):
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 @@ def save_chan(context, filepath, y_up, rot_ord):
# 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
diff --git a/io_anim_nuke_chan/import_nuke_chan.py b/io_anim_nuke_chan/import_nuke_chan.py
index 717c3f9d..05bbfa0c 100644
--- a/io_anim_nuke_chan/import_nuke_chan.py
+++ b/io_anim_nuke_chan/import_nuke_chan.py
@@ -24,18 +24,13 @@ from mathutils import Vector, Matrix, Euler
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 @@ def read_chan(context, filepath, z_up, rot_ord):
# 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()