Page MenuHome

nuke_cam.diff

File Metadata

Author
Ejner Fergo (ejnersan)
Created
Nov 13 2013, 3:07 PM

nuke_cam.diff

Index: io_anim_nuke_chan/export_nuke_chan.py
===================================================================
--- io_anim_nuke_chan/export_nuke_chan.py (revision 2751)
+++ io_anim_nuke_chan/export_nuke_chan.py (working copy)
@@ -23,7 +23,7 @@
into a text file with .chan extension."""
from mathutils import Matrix
-from math import radians, degrees, atan2
+from math import radians, degrees
def save_chan(context, filepath, y_up, rot_ord):
@@ -44,7 +44,7 @@
fw = filehandle.write
# iterate the frames
- for frame in range(f_start, f_end, 1):
+ for frame in range(f_start, f_end + 1, 1):
# set the current frame
scene.frame_set(frame)
@@ -69,18 +69,9 @@
fw("%f\t%f\t%f\t" % (degrees(r[0]), degrees(r[1]), degrees(r[2])))
- # if we have a camera, add the focal length
+ # if we have a camera, add the vertical field of view
if camera:
- sensor_x = camera.sensor_width
- sensor_y = camera.sensor_height
- cam_lens = camera.lens
-
- # calculate the vertical field of view
- # we know the vertical size of (virtual) sensor, the focal length
- # of the camera so all we need to do is to feed this data to
- # atan2 function whitch returns the degree (in radians) of
- # an angle formed by a triangle with two legs of a given lengths
- vfov = degrees(atan2(sensor_y / 2, cam_lens)) * 2.0
+ vfov = degrees(camera.angle_y)
fw("%f" % vfov)
fw("\n")
Index: io_anim_nuke_chan/import_nuke_chan.py
===================================================================
--- io_anim_nuke_chan/import_nuke_chan.py (revision 2751)
+++ io_anim_nuke_chan/import_nuke_chan.py (working copy)
@@ -21,7 +21,7 @@
""" This script is an importer for the nuke's .chan files"""
from mathutils import Vector, Matrix, Euler
-from math import radians, tan
+from math import radians
def read_chan(context, filepath, z_up, rot_ord, sensor_width, sensor_height):
@@ -103,11 +103,10 @@
# check if the object is camera and fov data is present
if camera and len(data) > 7:
- v_fov = float(data[7])
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.angle_y = radians(float(data[7]))
camera.keyframe_insert("lens")
filehandle.close()

Event Timeline