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:
authorBartek Skorupa <bartekskorupa@bartekskorupa.com>2018-02-23 14:39:20 +0300
committerBartek Skorupa <bartekskorupa@bartekskorupa.com>2018-02-23 14:39:20 +0300
commit31e5c6b980a276850c0da11fab42403ab496a534 (patch)
tree158ec4ace6c133d1d1f873510d4bc7d725b2fab5 /io_export_after_effects.py
parent6184673253f5adb275b9f4919dc7bc5c50cc7bb4 (diff)
Added option to set AE Comp size.
Diffstat (limited to 'io_export_after_effects.py')
-rw-r--r--io_export_after_effects.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/io_export_after_effects.py b/io_export_after_effects.py
index aafa8ecb..4a5c6b92 100644
--- a/io_export_after_effects.py
+++ b/io_export_after_effects.py
@@ -23,8 +23,8 @@ bl_info = {
"description": "Export cameras, selected objects & camera solution "
"3D Markers to Adobe After Effects CS3 and above",
"author": "Bartek Skorupa",
- "version": (0, 64),
- "blender": (2, 69, 0),
+ "version": (0, 65),
+ "blender": (2, 79, 0),
"location": "File > Export > Adobe After Effects (.jsx)",
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
@@ -150,7 +150,7 @@ def convert_name(name):
# get object's blender's location rotation and scale and return AE's Position, Rotation/Orientation and scale
# this function will be called for every object for every frame
-def convert_transform_matrix(matrix, width, height, aspect, x_rot_correction=False):
+def convert_transform_matrix(matrix, width, height, aspect, x_rot_correction=False, ae_size=100.0):
# get blender transform data for ob
b_loc = matrix.to_translation()
@@ -159,9 +159,9 @@ def convert_transform_matrix(matrix, width, height, aspect, x_rot_correction=Fal
# convert to AE Position Rotation and Scale
# Axes in AE are different. AE's X is blender's X, AE's Y is negative Blender's Z, AE's Z is Blender's Y
- x = (b_loc.x * 100.0) / aspect + width / 2.0 # calculate AE's X position
- y = (-b_loc.z * 100.0) + (height / 2.0) # calculate AE's Y position
- z = b_loc.y * 100.0 # calculate AE's Z position
+ x = (b_loc.x * ae_size) / aspect + width / 2.0 # calculate AE's X position
+ y = (-b_loc.z * ae_size) + (height / 2.0) # calculate AE's Y position
+ z = b_loc.y * ae_size # calculate AE's Z position
# Convert rotations to match AE's orientation.
rx = degrees(b_rot.x) # if not x_rot_correction - AE's X orientation = blender's X rotation if 'ZYX' euler.
ry = -degrees(b_rot.y) # AE's Y orientation is negative blender's Y rotation if 'ZYX' euler
@@ -240,7 +240,7 @@ def convert_lens(camera, width, height, aspect):
# jsx script for AE creation
-def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles):
+def write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, ae_size):
print("\n---------------------------\n- Export to After Effects -\n---------------------------")
# store the current frame to restore it at the end of export
@@ -382,7 +382,7 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
# bundles are in camera space. Transpose to world space
matrix = Matrix.Translation(cam.matrix_basis.copy() * track.bundle)
# convert the position into AE space
- ae_transform = convert_transform_matrix(matrix, data['width'], data['height'], data['aspect'], x_rot_correction=False)
+ ae_transform = convert_transform_matrix(matrix, data['width'], data['height'], data['aspect'], False, ae_size)
js_data['bundles_cam'][name_ae]['position'] += '[%f,%f,%f],' % (ae_transform[0], ae_transform[1], ae_transform[2])
# get all keyframes for each object and store in dico
@@ -407,7 +407,7 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
# get cam name
name_ae = active_cam_name
# convert cam transform properties to AE space
- ae_transform = convert_transform_matrix(active_cam.matrix_world.copy(), data['width'], data['height'], data['aspect'], x_rot_correction=True)
+ ae_transform = convert_transform_matrix(active_cam.matrix_world.copy(), data['width'], data['height'], data['aspect'], True, ae_size)
# convert Blender's lens to AE's zoom in pixels
zoom = convert_lens(active_cam, data['width'], data['height'], data['aspect'])
# store all values in dico
@@ -437,7 +437,7 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
# get cam name
name_ae = selection['cameras'][i][1]
# convert cam transform properties to AE space
- ae_transform = convert_transform_matrix(cam[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], x_rot_correction=True)
+ ae_transform = convert_transform_matrix(cam[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], True, ae_size)
# convert Blender's lens to AE's zoom in pixels
zoom = convert_lens(cam[0], data['width'], data['height'], data['aspect'])
# store all values in dico
@@ -475,7 +475,7 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
name_ae = selection['lights'][i][1]
type = selection['lights'][i][0].data.type
# convert ob transform properties to AE space
- ae_transform = convert_transform_matrix(ob[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], x_rot_correction=True)
+ ae_transform = convert_transform_matrix(ob[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], True, ae_size)
color = ob[0].data.color
# store all values in dico
position = '[%f,%f,%f],' % (ae_transform[0], ae_transform[1], ae_transform[2])
@@ -522,7 +522,7 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
# get object name
name_ae = selection['nulls'][i][1]
# convert ob transform properties to AE space
- ae_transform = convert_transform_matrix(ob[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], x_rot_correction=True)
+ ae_transform = convert_transform_matrix(ob[0].matrix_world.copy(), data['width'], data['height'], data['aspect'], True, ae_size)
# store all values in dico
position = '[%f,%f,%f],' % (ae_transform[0], ae_transform[1], ae_transform[2])
orientation = '[%f,%f,%f],' % (ae_transform[3], ae_transform[4], ae_transform[5])
@@ -676,10 +676,10 @@ def write_jsx_file(file, data, selection, include_animation, include_active_cam,
##########################################
-def main(file, context, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles):
+def main(file, context, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, ae_size):
data = get_comp_data(context)
selection = get_selected(context)
- write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles)
+ write_jsx_file(file, data, selection, include_animation, include_active_cam, include_selected_cams, include_selected_objects, include_cam_bundles, ae_size)
print ("\nExport to After Effects Completed")
return {'FINISHED'}
@@ -688,7 +688,7 @@ def main(file, context, include_animation, include_active_cam, include_selected_
##########################################
from bpy_extras.io_utils import ExportHelper
-from bpy.props import StringProperty, BoolProperty
+from bpy.props import StringProperty, BoolProperty, FloatProperty
class ExportJsx(bpy.types.Operator, ExportHelper):
@@ -728,11 +728,18 @@ class ExportJsx(bpy.types.Operator, ExportHelper):
# description="Include 3D Markers of Object Motion Solution for selected cameras",
# default=True,
# )
+ ae_size = FloatProperty(
+ name="AE Size",
+ description="Size of AE Composition (pixels per 1BU)",
+ default=100.0,
+ )
def draw(self, context):
layout = self.layout
box = layout.box()
+ box.label('Size fo AE Comp (pixels per 1 BU)')
+ box.prop(self, 'ae_size')
box.label('Animation:')
box.prop(self, 'include_animation')
box.label('Include Cameras and Objects:')
@@ -752,7 +759,7 @@ class ExportJsx(bpy.types.Operator, ExportHelper):
return ok
def execute(self, context):
- return main(self.filepath, context, self.include_animation, self.include_active_cam, self.include_selected_cams, self.include_selected_objects, self.include_cam_bundles)
+ return main(self.filepath, context, self.include_animation, self.include_active_cam, self.include_selected_cams, self.include_selected_objects, self.include_cam_bundles, self.ae_size)
def menu_func(self, context):