2011-11-07 12:55:18 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
import bpy
|
|
|
|
import os
|
|
|
|
from bpy.types import Operator
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
from mathutils import Vector, Matrix
|
|
|
|
|
|
|
|
|
2012-01-05 16:57:15 +00:00
|
|
|
def CLIP_spaces_walk(context, all_screens, tarea, tspace, callback, *args):
|
2011-11-23 17:30:47 +00:00
|
|
|
screens = bpy.data.screens if all_screens else [context.screen]
|
|
|
|
|
|
|
|
for screen in screens:
|
|
|
|
for area in screen.areas:
|
|
|
|
if area.type == tarea:
|
|
|
|
for space in area.spaces:
|
|
|
|
if space.type == tspace:
|
|
|
|
callback(space, *args)
|
|
|
|
|
|
|
|
|
|
|
|
def CLIP_set_viewport_background(context, all_screens, clip, clip_user):
|
|
|
|
def set_background(space_v3d, clip, user):
|
|
|
|
bgpic = None
|
|
|
|
|
|
|
|
for x in space_v3d.background_images:
|
2011-11-30 05:34:32 +00:00
|
|
|
if x.source == 'MOVIE_CLIP':
|
2011-11-23 17:30:47 +00:00
|
|
|
bgpic = x
|
|
|
|
break
|
|
|
|
|
|
|
|
if not bgpic:
|
|
|
|
bgpic = space_v3d.background_images.new()
|
|
|
|
|
2011-11-30 05:34:32 +00:00
|
|
|
bgpic.source = 'MOVIE_CLIP'
|
2011-11-23 17:30:47 +00:00
|
|
|
bgpic.clip = clip
|
|
|
|
bgpic.clip_user.proxy_render_size = user.proxy_render_size
|
|
|
|
bgpic.clip_user.use_render_undistorted = True
|
|
|
|
bgpic.use_camera_clip = False
|
|
|
|
bgpic.view_axis = 'CAMERA'
|
|
|
|
|
|
|
|
space_v3d.show_background_images = True
|
|
|
|
|
2012-01-05 16:57:15 +00:00
|
|
|
CLIP_spaces_walk(context, all_screens, 'VIEW_3D', 'VIEW_3D',
|
2012-10-08 08:28:05 +00:00
|
|
|
set_background, clip, clip_user)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
2012-01-04 09:19:39 +00:00
|
|
|
def CLIP_camera_for_clip(context, clip):
|
|
|
|
scene = context.scene
|
|
|
|
|
|
|
|
camera = scene.camera
|
|
|
|
|
|
|
|
for ob in scene.objects:
|
|
|
|
if ob.type == 'CAMERA':
|
|
|
|
for con in ob.constraints:
|
|
|
|
if con.type == 'CAMERA_SOLVER':
|
2012-02-04 11:12:18 +00:00
|
|
|
cur_clip = scene.active_clip if con.use_active_clip else con.clip
|
2012-01-04 09:19:39 +00:00
|
|
|
|
|
|
|
if cur_clip == clip:
|
|
|
|
return ob
|
|
|
|
|
|
|
|
return camera
|
|
|
|
|
2012-01-17 17:57:20 +00:00
|
|
|
|
2011-11-15 12:20:58 +00:00
|
|
|
def CLIP_track_view_selected(sc, track):
|
|
|
|
if track.select_anchor:
|
|
|
|
return True
|
|
|
|
|
|
|
|
if sc.show_marker_pattern and track.select_pattern:
|
|
|
|
return True
|
|
|
|
|
|
|
|
if sc.show_marker_search and track.select_search:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
2011-11-16 13:39:58 +00:00
|
|
|
|
2012-08-04 10:47:31 +00:00
|
|
|
def CLIP_default_settings_from_track(clip, track, framenr):
|
2012-01-26 15:04:25 +00:00
|
|
|
settings = clip.tracking.settings
|
|
|
|
|
|
|
|
width = clip.size[0]
|
|
|
|
height = clip.size[1]
|
|
|
|
|
2012-08-04 10:47:31 +00:00
|
|
|
marker = track.markers.find_frame(framenr, False)
|
|
|
|
pattern_bb = marker.pattern_bound_box
|
|
|
|
|
|
|
|
pattern = Vector(pattern_bb[1]) - Vector(pattern_bb[0])
|
|
|
|
search = marker.search_max - marker.search_min
|
2012-01-26 15:04:25 +00:00
|
|
|
|
2012-04-08 13:11:25 +00:00
|
|
|
pattern[0] = pattern[0] * width
|
|
|
|
pattern[1] = pattern[1] * height
|
2012-01-26 15:04:25 +00:00
|
|
|
|
2012-04-08 13:11:25 +00:00
|
|
|
search[0] = search[0] * width
|
|
|
|
search[1] = search[1] * height
|
2012-01-26 15:04:25 +00:00
|
|
|
|
|
|
|
settings.default_correlation_min = track.correlation_min
|
|
|
|
settings.default_pattern_size = max(pattern[0], pattern[1])
|
|
|
|
settings.default_search_size = max(search[0], search[1])
|
|
|
|
settings.default_frames_limit = track.frames_limit
|
|
|
|
settings.default_pattern_match = track.pattern_match
|
|
|
|
settings.default_margin = track.margin
|
2012-08-04 10:47:31 +00:00
|
|
|
settings.default_motion_model = track.motion_model
|
|
|
|
settings.use_default_brute = track.use_brute
|
|
|
|
settings.use_default_normalization = track.use_normalization
|
|
|
|
settings.use_default_mask = track.use_mask
|
2012-01-26 15:33:16 +00:00
|
|
|
settings.use_default_red_channel = track.use_red_channel
|
|
|
|
settings.use_default_green_channel = track.use_green_channel
|
|
|
|
settings.use_default_blue_channel = track.use_blue_channel
|
2014-02-19 12:58:37 +00:00
|
|
|
settings.default_weight = track.weight
|
2012-01-26 15:04:25 +00:00
|
|
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
class CLIP_OT_track_to_empty(Operator):
|
|
|
|
"""Create an Empty object which will be copying movement of active track"""
|
|
|
|
|
|
|
|
bl_idname = "clip.track_to_empty"
|
2011-11-15 12:20:58 +00:00
|
|
|
bl_label = "Link Empty to Track"
|
2011-11-07 12:55:18 +00:00
|
|
|
bl_options = {'UNDO', 'REGISTER'}
|
|
|
|
|
2012-01-04 09:19:39 +00:00
|
|
|
def _link_track(self, context, clip, tracking_object, track):
|
2011-11-07 12:55:18 +00:00
|
|
|
sc = context.space_data
|
|
|
|
constraint = None
|
|
|
|
ob = None
|
|
|
|
|
|
|
|
ob = bpy.data.objects.new(name=track.name, object_data=None)
|
|
|
|
ob.select = True
|
2011-11-23 17:30:47 +00:00
|
|
|
context.scene.objects.link(ob)
|
|
|
|
context.scene.objects.active = ob
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
for con in ob.constraints:
|
|
|
|
if con.type == 'FOLLOW_TRACK':
|
|
|
|
constraint = con
|
|
|
|
break
|
|
|
|
|
|
|
|
if constraint is None:
|
|
|
|
constraint = ob.constraints.new(type='FOLLOW_TRACK')
|
|
|
|
|
2012-02-09 10:24:44 +00:00
|
|
|
constraint.use_active_clip = False
|
2011-11-07 12:55:18 +00:00
|
|
|
constraint.clip = sc.clip
|
|
|
|
constraint.track = track.name
|
2011-11-14 06:41:42 +00:00
|
|
|
constraint.use_3d_position = False
|
2012-01-04 09:19:39 +00:00
|
|
|
constraint.object = tracking_object.name
|
2012-01-17 17:57:20 +00:00
|
|
|
constraint.camera = CLIP_camera_for_clip(context, clip)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-11-15 12:20:58 +00:00
|
|
|
def execute(self, context):
|
|
|
|
sc = context.space_data
|
|
|
|
clip = sc.clip
|
2012-01-04 09:19:39 +00:00
|
|
|
tracking_object = clip.tracking.objects.active
|
2011-11-15 12:20:58 +00:00
|
|
|
|
2012-01-04 09:19:39 +00:00
|
|
|
for track in tracking_object.tracks:
|
2011-11-15 12:20:58 +00:00
|
|
|
if CLIP_track_view_selected(sc, track):
|
2012-01-17 17:57:20 +00:00
|
|
|
self._link_track(context, clip, tracking_object, track)
|
2011-11-15 12:20:58 +00:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
2011-11-21 17:05:27 +00:00
|
|
|
class CLIP_OT_bundles_to_mesh(Operator):
|
|
|
|
"""Create vertex cloud using coordinates of reconstructed tracks"""
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-11-21 17:05:27 +00:00
|
|
|
bl_idname = "clip.bundles_to_mesh"
|
|
|
|
bl_label = "3D Markers to Mesh"
|
2011-11-07 12:55:18 +00:00
|
|
|
bl_options = {'UNDO', 'REGISTER'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
sc = context.space_data
|
2011-11-16 16:38:37 +00:00
|
|
|
return (sc.type == 'CLIP_EDITOR') and sc.clip
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
def execute(self, context):
|
2011-11-24 21:59:43 +00:00
|
|
|
from bpy_extras.io_utils import unpack_list
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
sc = context.space_data
|
|
|
|
clip = sc.clip
|
2012-01-04 09:19:39 +00:00
|
|
|
tracking_object = clip.tracking.objects.active
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
new_verts = []
|
|
|
|
|
2014-02-26 13:40:04 +00:00
|
|
|
scene = context.scene
|
|
|
|
camera = scene.camera
|
|
|
|
matrix = Matrix.Identity(4)
|
|
|
|
if camera:
|
|
|
|
reconstruction = tracking_object.reconstruction
|
|
|
|
framenr = scene.frame_current - clip.frame_start + 1
|
2014-02-26 21:38:14 +00:00
|
|
|
reconstructed_matrix = reconstruction.cameras.matrix_from_frame(framenr)
|
2014-02-26 13:40:04 +00:00
|
|
|
matrix = camera.matrix_world * reconstructed_matrix.inverted()
|
|
|
|
|
2011-11-14 06:41:42 +00:00
|
|
|
mesh = bpy.data.meshes.new(name="Tracks")
|
2012-01-04 09:19:39 +00:00
|
|
|
for track in tracking_object.tracks:
|
2011-11-07 12:55:18 +00:00
|
|
|
if track.has_bundle:
|
|
|
|
new_verts.append(track.bundle)
|
|
|
|
|
|
|
|
if new_verts:
|
|
|
|
mesh.vertices.add(len(new_verts))
|
|
|
|
mesh.vertices.foreach_set("co", unpack_list(new_verts))
|
|
|
|
|
2011-11-14 06:41:42 +00:00
|
|
|
ob = bpy.data.objects.new(name="Tracks", object_data=mesh)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2014-02-26 13:40:04 +00:00
|
|
|
ob.matrix_world = matrix
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
context.scene.objects.link(ob)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
|
|
|
class CLIP_OT_delete_proxy(Operator):
|
|
|
|
"""Delete movie clip proxy files from the hard drive"""
|
|
|
|
|
|
|
|
bl_idname = "clip.delete_proxy"
|
|
|
|
bl_label = "Delete Proxy"
|
2011-11-19 20:14:57 +00:00
|
|
|
bl_options = {'REGISTER'}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2011-11-16 11:52:31 +00:00
|
|
|
if context.space_data.type != 'CLIP_EDITOR':
|
|
|
|
return False
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
sc = context.space_data
|
|
|
|
|
|
|
|
return sc.clip
|
|
|
|
|
|
|
|
def invoke(self, context, event):
|
|
|
|
wm = context.window_manager
|
|
|
|
|
|
|
|
return wm.invoke_confirm(self, event)
|
|
|
|
|
|
|
|
def _rmproxy(self, abspath):
|
2011-11-24 21:59:43 +00:00
|
|
|
import shutil
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
if not os.path.exists(abspath):
|
|
|
|
return
|
|
|
|
|
|
|
|
if os.path.isdir(abspath):
|
|
|
|
shutil.rmtree(abspath)
|
|
|
|
else:
|
|
|
|
os.remove(abspath)
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
sc = context.space_data
|
|
|
|
clip = sc.clip
|
|
|
|
if clip.use_proxy_custom_directory:
|
|
|
|
proxydir = clip.proxy.directory
|
|
|
|
else:
|
|
|
|
clipdir = os.path.dirname(clip.filepath)
|
2011-12-22 03:56:21 +00:00
|
|
|
proxydir = os.path.join(clipdir, "BL_proxy")
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
clipfile = os.path.basename(clip.filepath)
|
|
|
|
proxy = os.path.join(proxydir, clipfile)
|
|
|
|
absproxy = bpy.path.abspath(proxy)
|
|
|
|
|
|
|
|
# proxy_<quality>[_undostorted]
|
|
|
|
for x in (25, 50, 75, 100):
|
2011-12-22 03:56:21 +00:00
|
|
|
d = os.path.join(absproxy, "proxy_%d" % x)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
self._rmproxy(d)
|
2011-12-22 03:56:21 +00:00
|
|
|
self._rmproxy(d + "_undistorted")
|
|
|
|
self._rmproxy(os.path.join(absproxy, "proxy_%d.avi" % x))
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-22 03:56:21 +00:00
|
|
|
tc = ("free_run.blen_tc",
|
|
|
|
"interp_free_run.blen_tc",
|
|
|
|
"record_run.blen_tc")
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
for x in tc:
|
|
|
|
self._rmproxy(os.path.join(absproxy, x))
|
|
|
|
|
|
|
|
# remove proxy per-clip directory
|
|
|
|
try:
|
|
|
|
os.rmdir(absproxy)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# remove [custom] proxy directory if empty
|
|
|
|
try:
|
|
|
|
absdir = bpy.path.abspath(proxydir)
|
|
|
|
os.rmdir(absdir)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
|
|
|
class CLIP_OT_set_viewport_background(Operator):
|
2012-02-08 04:37:37 +00:00
|
|
|
"""Set current movie clip as a camera background in 3D view-port """ \
|
|
|
|
"""(works only when a 3D view-port is visible)"""
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
bl_idname = "clip.set_viewport_background"
|
|
|
|
bl_label = "Set as Background"
|
2011-11-19 20:14:57 +00:00
|
|
|
bl_options = {'REGISTER'}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
if context.space_data.type != 'CLIP_EDITOR':
|
|
|
|
return False
|
|
|
|
|
|
|
|
sc = context.space_data
|
|
|
|
|
|
|
|
return sc.clip
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
sc = context.space_data
|
2011-11-23 17:30:47 +00:00
|
|
|
CLIP_set_viewport_background(context, False, sc.clip, sc.clip_user)
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
|
|
|
class CLIP_OT_constraint_to_fcurve(Operator):
|
2011-11-16 13:39:58 +00:00
|
|
|
"""Create F-Curves for object which will copy \
|
|
|
|
object's movement caused by this constraint"""
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
bl_idname = "clip.constraint_to_fcurve"
|
|
|
|
bl_label = "Constraint to F-Curve"
|
|
|
|
bl_options = {'UNDO', 'REGISTER'}
|
|
|
|
|
|
|
|
def _bake_object(self, scene, ob):
|
|
|
|
con = None
|
|
|
|
clip = None
|
|
|
|
sfra = None
|
|
|
|
efra = None
|
|
|
|
frame_current = scene.frame_current
|
|
|
|
matrices = []
|
|
|
|
|
2012-02-08 04:37:37 +00:00
|
|
|
# Find constraint which would be converting
|
2011-11-07 12:55:18 +00:00
|
|
|
# TODO: several camera solvers and track followers would fail,
|
2012-02-08 04:37:37 +00:00
|
|
|
# but can't think about real work-flow where it'll be useful
|
2011-11-07 12:55:18 +00:00
|
|
|
for x in ob.constraints:
|
2012-01-04 08:43:28 +00:00
|
|
|
if x.type in {'CAMERA_SOLVER', 'FOLLOW_TRACK', 'OBJECT_SOLVER'}:
|
2011-11-07 12:55:18 +00:00
|
|
|
con = x
|
|
|
|
|
|
|
|
if not con:
|
2011-11-20 11:44:32 +00:00
|
|
|
self.report({'ERROR'},
|
2012-10-08 08:28:05 +00:00
|
|
|
"Motion Tracking constraint to be converted not found")
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-11-20 11:44:32 +00:00
|
|
|
return {'CANCELLED'}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
# Get clip used for parenting
|
|
|
|
if con.use_active_clip:
|
|
|
|
clip = scene.active_clip
|
|
|
|
else:
|
|
|
|
clip = con.clip
|
|
|
|
|
|
|
|
if not clip:
|
2011-11-20 11:44:32 +00:00
|
|
|
self.report({'ERROR'},
|
2012-10-08 08:28:05 +00:00
|
|
|
"Movie clip to use tracking data from isn't set")
|
2011-11-20 11:44:32 +00:00
|
|
|
|
|
|
|
return {'CANCELLED'}
|
|
|
|
|
|
|
|
if con.type == 'FOLLOW_TRACK' and con.use_3d_position:
|
|
|
|
mat = ob.matrix_world.copy()
|
|
|
|
ob.constraints.remove(con)
|
|
|
|
ob.matrix_world = mat
|
|
|
|
|
|
|
|
return {'FINISHED'}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
# Find start and end frames
|
|
|
|
for track in clip.tracking.tracks:
|
|
|
|
if sfra is None:
|
|
|
|
sfra = track.markers[0].frame
|
|
|
|
else:
|
|
|
|
sfra = min(sfra, track.markers[0].frame)
|
|
|
|
|
|
|
|
if efra is None:
|
|
|
|
efra = track.markers[-1].frame
|
|
|
|
else:
|
|
|
|
efra = max(efra, track.markers[-1].frame)
|
|
|
|
|
|
|
|
if sfra is None or efra is None:
|
2011-11-08 01:32:34 +00:00
|
|
|
return
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
# Store object matrices
|
2011-11-08 01:32:34 +00:00
|
|
|
for x in range(sfra, efra + 1):
|
2011-11-07 12:55:18 +00:00
|
|
|
scene.frame_set(x)
|
|
|
|
matrices.append(ob.matrix_world.copy())
|
|
|
|
|
|
|
|
ob.animation_data_create()
|
|
|
|
|
2012-02-08 04:37:37 +00:00
|
|
|
# Apply matrices on object and insert key-frames
|
2011-11-07 12:55:18 +00:00
|
|
|
i = 0
|
2011-11-08 01:32:34 +00:00
|
|
|
for x in range(sfra, efra + 1):
|
2011-11-07 12:55:18 +00:00
|
|
|
scene.frame_set(x)
|
|
|
|
ob.matrix_world = matrices[i]
|
|
|
|
|
|
|
|
ob.keyframe_insert("location")
|
|
|
|
|
|
|
|
if ob.rotation_mode == 'QUATERNION':
|
|
|
|
ob.keyframe_insert("rotation_quaternion")
|
|
|
|
else:
|
|
|
|
ob.keyframe_insert("rotation_euler")
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
ob.constraints.remove(con)
|
|
|
|
|
|
|
|
scene.frame_set(frame_current)
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
scene = context.scene
|
2011-12-22 03:56:21 +00:00
|
|
|
# XXX, should probably use context.selected_editable_objects
|
|
|
|
# since selected objects can be from a lib or in hidden layer!
|
2011-11-07 12:55:18 +00:00
|
|
|
for ob in scene.objects:
|
|
|
|
if ob.select:
|
|
|
|
self._bake_object(scene, ob)
|
|
|
|
|
|
|
|
return {'FINISHED'}
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CLIP_OT_setup_tracking_scene(Operator):
|
|
|
|
"""Prepare scene for compositing 3D objects into this footage"""
|
|
|
|
|
|
|
|
bl_idname = "clip.setup_tracking_scene"
|
|
|
|
bl_label = "Setup Tracking Scene"
|
|
|
|
bl_options = {'UNDO', 'REGISTER'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
sc = context.space_data
|
|
|
|
|
|
|
|
if sc.type != 'CLIP_EDITOR':
|
|
|
|
return False
|
|
|
|
|
|
|
|
clip = sc.clip
|
|
|
|
|
|
|
|
return clip and clip.tracking.reconstruction.is_valid
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _setupScene(context):
|
|
|
|
scene = context.scene
|
|
|
|
scene.active_clip = context.space_data.clip
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _setupWorld(context):
|
|
|
|
scene = context.scene
|
|
|
|
world = scene.world
|
|
|
|
|
|
|
|
if not world:
|
|
|
|
world = bpy.data.worlds.new(name="World")
|
|
|
|
scene.world = world
|
|
|
|
|
|
|
|
world.light_settings.use_ambient_occlusion = True
|
|
|
|
world.light_settings.ao_blend_type = 'MULTIPLY'
|
|
|
|
|
|
|
|
world.light_settings.use_environment_light = True
|
|
|
|
world.light_settings.environment_energy = 0.1
|
|
|
|
|
|
|
|
world.light_settings.distance = 1.0
|
|
|
|
world.light_settings.sample_method = 'ADAPTIVE_QMC'
|
|
|
|
world.light_settings.samples = 7
|
|
|
|
world.light_settings.threshold = 0.005
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _findOrCreateCamera(context):
|
|
|
|
scene = context.scene
|
|
|
|
|
|
|
|
if scene.camera:
|
|
|
|
return scene.camera
|
|
|
|
|
|
|
|
cam = bpy.data.cameras.new(name="Camera")
|
|
|
|
camob = bpy.data.objects.new(name="Camera", object_data=cam)
|
|
|
|
scene.objects.link(camob)
|
|
|
|
|
|
|
|
scene.camera = camob
|
|
|
|
|
|
|
|
camob.matrix_local = (Matrix.Translation((7.481, -6.508, 5.344)) *
|
2012-10-08 08:28:05 +00:00
|
|
|
Matrix.Rotation(0.815, 4, 'Z') *
|
|
|
|
Matrix.Rotation(0.011, 4, 'Y') *
|
|
|
|
Matrix.Rotation(1.109, 4, 'X'))
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
return camob
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _setupCamera(context):
|
2011-12-11 15:48:15 +00:00
|
|
|
sc = context.space_data
|
|
|
|
clip = sc.clip
|
|
|
|
tracking = clip.tracking
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
camob = CLIP_OT_setup_tracking_scene._findOrCreateCamera(context)
|
2011-12-11 15:48:15 +00:00
|
|
|
cam = camob.data
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
# Remove all constraints to be sure motion is fine
|
|
|
|
camob.constraints.clear()
|
|
|
|
|
|
|
|
# Append camera solver constraint
|
|
|
|
con = camob.constraints.new(type='CAMERA_SOLVER')
|
|
|
|
con.use_active_clip = True
|
|
|
|
con.influence = 1.0
|
|
|
|
|
2011-12-11 15:48:15 +00:00
|
|
|
cam.sensor_width = tracking.camera.sensor_width
|
|
|
|
cam.lens = tracking.camera.focal_length
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
@staticmethod
|
|
|
|
def _setupViewport(context):
|
|
|
|
sc = context.space_data
|
|
|
|
CLIP_set_viewport_background(context, True, sc.clip, sc.clip_user)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _setupRenderLayers(context):
|
|
|
|
scene = context.scene
|
|
|
|
rlayers = scene.render.layers
|
|
|
|
|
|
|
|
if not scene.render.layers.get("Foreground"):
|
|
|
|
if len(rlayers) == 1:
|
|
|
|
fg = rlayers[0]
|
|
|
|
fg.name = 'Foreground'
|
|
|
|
else:
|
2012-07-04 21:41:05 +00:00
|
|
|
fg = scene.render.layers.new("Foreground")
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
fg.use_sky = False
|
|
|
|
fg.layers = [True] + [False] * 19
|
|
|
|
fg.layers_zmask = [False] * 10 + [True] + [False] * 9
|
|
|
|
fg.use_pass_vector = True
|
|
|
|
|
|
|
|
if not scene.render.layers.get("Background"):
|
2012-07-04 21:41:05 +00:00
|
|
|
bg = scene.render.layers.new("Background")
|
2011-11-23 17:30:47 +00:00
|
|
|
bg.use_pass_shadow = True
|
|
|
|
bg.use_pass_ambient_occlusion = True
|
|
|
|
bg.layers = [False] * 10 + [True] + [False] * 9
|
|
|
|
|
2014-06-02 07:12:01 +00:00
|
|
|
@staticmethod
|
|
|
|
def _wipeDefaultNodes(tree):
|
|
|
|
if len(tree.nodes) != 2:
|
|
|
|
return False
|
|
|
|
types = [node.type for node in tree.nodes]
|
|
|
|
types.sort()
|
|
|
|
|
|
|
|
if types[0] == 'COMPOSITE' and types[1] == 'R_LAYERS':
|
|
|
|
while tree.nodes:
|
|
|
|
tree.nodes.remove(tree.nodes[0])
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
@staticmethod
|
|
|
|
def _findNode(tree, type):
|
|
|
|
for node in tree.nodes:
|
|
|
|
if node.type == type:
|
|
|
|
return node
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _findOrCreateNode(tree, type):
|
|
|
|
node = CLIP_OT_setup_tracking_scene._findNode(tree, type)
|
|
|
|
|
|
|
|
if not node:
|
|
|
|
node = tree.nodes.new(type=type)
|
|
|
|
|
|
|
|
return node
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _needSetupNodes(context):
|
|
|
|
scene = context.scene
|
|
|
|
tree = scene.node_tree
|
|
|
|
|
|
|
|
if not tree:
|
|
|
|
# No compositor node tree found, time to create it!
|
|
|
|
return True
|
|
|
|
|
|
|
|
for node in tree.nodes:
|
|
|
|
if node.type in {'MOVIECLIP', 'MOVIEDISTORTION'}:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _offsetNodes(tree):
|
|
|
|
for a in tree.nodes:
|
|
|
|
for b in tree.nodes:
|
|
|
|
if a != b and a.location == b.location:
|
|
|
|
b.location += Vector((40.0, 20.0))
|
|
|
|
|
|
|
|
def _setupNodes(self, context):
|
|
|
|
if not self._needSetupNodes(context):
|
|
|
|
# compositor nodes were already setup or even changes already
|
|
|
|
# do nothing to prevent nodes damage
|
|
|
|
return
|
|
|
|
|
|
|
|
# Enable backdrop for all compositor spaces
|
|
|
|
def setup_space(space):
|
|
|
|
space.show_backdrop = True
|
|
|
|
|
2012-01-05 16:57:15 +00:00
|
|
|
CLIP_spaces_walk(context, True, 'NODE_EDITOR', 'NODE_EDITOR',
|
2012-07-04 21:41:05 +00:00
|
|
|
setup_space)
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
sc = context.space_data
|
|
|
|
scene = context.scene
|
|
|
|
scene.use_nodes = True
|
|
|
|
tree = scene.node_tree
|
|
|
|
clip = sc.clip
|
|
|
|
|
|
|
|
need_stabilization = False
|
|
|
|
|
2014-06-02 07:12:01 +00:00
|
|
|
# Remove all the nodes if they came from default node setup.
|
|
|
|
# This is simplest way to make it so final node setup is
|
|
|
|
# is correct.
|
|
|
|
self._wipeDefaultNodes(tree)
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
# create nodes
|
2013-04-11 13:25:05 +00:00
|
|
|
rlayer_fg = self._findOrCreateNode(tree, 'CompositorNodeRLayers')
|
|
|
|
rlayer_bg = tree.nodes.new(type='CompositorNodeRLayers')
|
|
|
|
composite = self._findOrCreateNode(tree, 'CompositorNodeComposite')
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2013-04-11 13:25:05 +00:00
|
|
|
movieclip = tree.nodes.new(type='CompositorNodeMovieClip')
|
|
|
|
distortion = tree.nodes.new(type='CompositorNodeMovieDistortion')
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
if need_stabilization:
|
2013-04-11 13:25:05 +00:00
|
|
|
stabilize = tree.nodes.new(type='CompositorNodeStabilize2D')
|
|
|
|
|
|
|
|
scale = tree.nodes.new(type='CompositorNodeScale')
|
|
|
|
invert = tree.nodes.new(type='CompositorNodeInvert')
|
|
|
|
add_ao = tree.nodes.new(type='CompositorNodeMixRGB')
|
|
|
|
add_shadow = tree.nodes.new(type='CompositorNodeMixRGB')
|
|
|
|
mul_shadow = tree.nodes.new(type='CompositorNodeMixRGB')
|
|
|
|
mul_image = tree.nodes.new(type='CompositorNodeMixRGB')
|
|
|
|
vector_blur = tree.nodes.new(type='CompositorNodeVecBlur')
|
|
|
|
alphaover = tree.nodes.new(type='CompositorNodeAlphaOver')
|
|
|
|
viewer = tree.nodes.new(type='CompositorNodeViewer')
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
# setup nodes
|
|
|
|
movieclip.clip = clip
|
|
|
|
|
|
|
|
distortion.clip = clip
|
|
|
|
distortion.distortion_type = 'UNDISTORT'
|
|
|
|
|
|
|
|
if need_stabilization:
|
|
|
|
stabilize.clip = clip
|
|
|
|
|
|
|
|
scale.space = 'RENDER_SIZE'
|
|
|
|
|
|
|
|
rlayer_bg.scene = scene
|
|
|
|
rlayer_bg.layer = "Background"
|
|
|
|
|
|
|
|
rlayer_fg.scene = scene
|
|
|
|
rlayer_fg.layer = "Foreground"
|
|
|
|
|
|
|
|
add_ao.blend_type = 'ADD'
|
2013-04-11 13:34:51 +00:00
|
|
|
add_ao.show_preview = False
|
2011-11-23 17:30:47 +00:00
|
|
|
add_shadow.blend_type = 'ADD'
|
2013-04-11 13:34:51 +00:00
|
|
|
add_shadow.show_preview = False
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
mul_shadow.blend_type = 'MULTIPLY'
|
2012-07-04 21:41:05 +00:00
|
|
|
mul_shadow.inputs["Fac"].default_value = 0.8
|
2013-04-11 13:34:51 +00:00
|
|
|
mul_shadow.show_preview = False
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
mul_image.blend_type = 'MULTIPLY'
|
2012-07-04 21:41:05 +00:00
|
|
|
mul_image.inputs["Fac"].default_value = 0.8
|
2013-04-11 13:34:51 +00:00
|
|
|
mul_image.show_preview = False
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
vector_blur.factor = 0.75
|
|
|
|
|
|
|
|
# create links
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(movieclip.outputs["Image"], distortion.inputs["Image"])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
if need_stabilization:
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(distortion.outputs["Image"],
|
2012-10-08 08:28:05 +00:00
|
|
|
stabilize.inputs["Image"])
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(stabilize.outputs["Image"], scale.inputs["Image"])
|
2011-11-23 17:30:47 +00:00
|
|
|
else:
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(distortion.outputs["Image"], scale.inputs["Image"])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(rlayer_bg.outputs["Alpha"], invert.inputs["Color"])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(invert.outputs["Color"], add_shadow.inputs[1])
|
|
|
|
tree.links.new(rlayer_bg.outputs["Shadow"], add_shadow.inputs[2])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(invert.outputs["Color"], add_ao.inputs[1])
|
|
|
|
tree.links.new(rlayer_bg.outputs["AO"], add_ao.inputs[2])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(add_ao.outputs["Image"], mul_shadow.inputs[1])
|
|
|
|
tree.links.new(add_shadow.outputs["Image"], mul_shadow.inputs[2])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(scale.outputs["Image"], mul_image.inputs[1])
|
|
|
|
tree.links.new(mul_shadow.outputs["Image"], mul_image.inputs[2])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(rlayer_fg.outputs["Image"], vector_blur.inputs["Image"])
|
|
|
|
tree.links.new(rlayer_fg.outputs["Z"], vector_blur.inputs["Z"])
|
|
|
|
tree.links.new(rlayer_fg.outputs["Speed"], vector_blur.inputs["Speed"])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(mul_image.outputs["Image"], alphaover.inputs[1])
|
|
|
|
tree.links.new(vector_blur.outputs["Image"], alphaover.inputs[2])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-07-04 21:41:05 +00:00
|
|
|
tree.links.new(alphaover.outputs["Image"], composite.inputs["Image"])
|
|
|
|
tree.links.new(alphaover.outputs["Image"], viewer.inputs["Image"])
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
# place nodes
|
|
|
|
movieclip.location = Vector((-300.0, 350.0))
|
|
|
|
|
|
|
|
distortion.location = movieclip.location
|
|
|
|
distortion.location += Vector((200.0, 0.0))
|
|
|
|
|
|
|
|
if need_stabilization:
|
|
|
|
stabilize.location = distortion.location
|
|
|
|
stabilize.location += Vector((200.0, 0.0))
|
|
|
|
|
|
|
|
scale.location = stabilize.location
|
|
|
|
scale.location += Vector((200.0, 0.0))
|
|
|
|
else:
|
|
|
|
scale.location = distortion.location
|
|
|
|
scale.location += Vector((200.0, 0.0))
|
|
|
|
|
|
|
|
rlayer_bg.location = movieclip.location
|
|
|
|
rlayer_bg.location -= Vector((0.0, 350.0))
|
|
|
|
|
|
|
|
invert.location = rlayer_bg.location
|
|
|
|
invert.location += Vector((250.0, 50.0))
|
|
|
|
|
|
|
|
add_ao.location = invert.location
|
|
|
|
add_ao.location[0] += 200
|
|
|
|
add_ao.location[1] = rlayer_bg.location[1]
|
|
|
|
|
|
|
|
add_shadow.location = add_ao.location
|
|
|
|
add_shadow.location -= Vector((0.0, 250.0))
|
|
|
|
|
|
|
|
mul_shadow.location = add_ao.location
|
|
|
|
mul_shadow.location += Vector((200.0, -50.0))
|
|
|
|
|
|
|
|
mul_image.location = mul_shadow.location
|
|
|
|
mul_image.location += Vector((300.0, 200.0))
|
|
|
|
|
|
|
|
rlayer_fg.location = rlayer_bg.location
|
|
|
|
rlayer_fg.location -= Vector((0.0, 500.0))
|
|
|
|
|
2011-11-29 20:36:34 +00:00
|
|
|
vector_blur.location[0] = mul_image.location[0]
|
2011-11-23 17:30:47 +00:00
|
|
|
vector_blur.location[1] = rlayer_fg.location[1]
|
|
|
|
|
2011-11-29 20:36:34 +00:00
|
|
|
alphaover.location[0] = vector_blur.location[0] + 350
|
2011-11-23 17:30:47 +00:00
|
|
|
alphaover.location[1] = \
|
|
|
|
(vector_blur.location[1] + mul_image.location[1]) / 2
|
|
|
|
|
|
|
|
composite.location = alphaover.location
|
|
|
|
composite.location += Vector((200.0, -100.0))
|
|
|
|
|
|
|
|
viewer.location = composite.location
|
|
|
|
composite.location += Vector((0.0, 200.0))
|
|
|
|
|
|
|
|
# ensure no nodes were creates on position of existing node
|
|
|
|
self._offsetNodes(tree)
|
|
|
|
|
2013-04-11 13:25:05 +00:00
|
|
|
scene.render.alpha_mode = 'TRANSPARENT'
|
2014-06-02 06:55:05 +00:00
|
|
|
if hasattr(scene, 'cycles'):
|
2013-04-11 13:29:51 +00:00
|
|
|
scene.cycles.film_transparent = True
|
2013-04-11 13:25:05 +00:00
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
@staticmethod
|
|
|
|
def _createMesh(scene, name, vertices, faces):
|
2012-04-08 13:11:25 +00:00
|
|
|
from bpy_extras.io_utils import unpack_list
|
2011-11-24 21:59:43 +00:00
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
mesh = bpy.data.meshes.new(name=name)
|
|
|
|
|
|
|
|
mesh.vertices.add(len(vertices))
|
|
|
|
mesh.vertices.foreach_set("co", unpack_list(vertices))
|
|
|
|
|
2012-03-27 09:10:05 +00:00
|
|
|
nbr_loops = len(faces)
|
|
|
|
nbr_polys = nbr_loops // 4
|
|
|
|
mesh.loops.add(nbr_loops)
|
|
|
|
mesh.polygons.add(nbr_polys)
|
2011-11-23 17:30:47 +00:00
|
|
|
|
2012-03-27 09:10:05 +00:00
|
|
|
mesh.polygons.foreach_set("loop_start", range(0, nbr_loops, 4))
|
|
|
|
mesh.polygons.foreach_set("loop_total", (4,) * nbr_polys)
|
|
|
|
mesh.loops.foreach_set("vertex_index", faces)
|
|
|
|
|
|
|
|
mesh.update()
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
ob = bpy.data.objects.new(name=name, object_data=mesh)
|
|
|
|
|
|
|
|
scene.objects.link(ob)
|
|
|
|
|
|
|
|
return ob
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _getPlaneVertices(half_size, z):
|
|
|
|
|
|
|
|
return [(-half_size, -half_size, z),
|
|
|
|
(-half_size, half_size, z),
|
|
|
|
(half_size, half_size, z),
|
|
|
|
(half_size, -half_size, z)]
|
|
|
|
|
|
|
|
def _createGround(self, scene):
|
|
|
|
vertices = self._getPlaneVertices(4.0, 0.0)
|
2012-03-27 09:10:05 +00:00
|
|
|
faces = [0, 1, 2, 3]
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
ob = self._createMesh(scene, "Ground", vertices, faces)
|
|
|
|
ob["is_ground"] = True
|
|
|
|
|
|
|
|
return ob
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _findGround(context):
|
|
|
|
scene = context.scene
|
|
|
|
|
|
|
|
for ob in scene.objects:
|
|
|
|
if ob.type == 'MESH' and "is_ground" in ob:
|
|
|
|
return ob
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _mergeLayers(layers_a, layers_b):
|
|
|
|
|
|
|
|
return [(layers_a[i] | layers_b[i]) for i in range(len(layers_a))]
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _createLamp(scene):
|
|
|
|
lamp = bpy.data.lamps.new(name="Lamp", type='POINT')
|
|
|
|
lampob = bpy.data.objects.new(name="Lamp", object_data=lamp)
|
|
|
|
scene.objects.link(lampob)
|
|
|
|
|
|
|
|
lampob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904))
|
|
|
|
|
|
|
|
lamp.distance = 30
|
|
|
|
lamp.shadow_method = 'RAY_SHADOW'
|
|
|
|
|
|
|
|
return lampob
|
|
|
|
|
|
|
|
def _createSampleObject(self, scene):
|
|
|
|
vertices = self._getPlaneVertices(1.0, -1.0) + \
|
|
|
|
self._getPlaneVertices(1.0, 1.0)
|
2012-03-27 09:10:05 +00:00
|
|
|
faces = (0, 1, 2, 3,
|
|
|
|
4, 7, 6, 5,
|
|
|
|
0, 4, 5, 1,
|
|
|
|
1, 5, 6, 2,
|
|
|
|
2, 6, 7, 3,
|
|
|
|
3, 7, 4, 0)
|
2011-11-23 17:30:47 +00:00
|
|
|
|
|
|
|
return self._createMesh(scene, "Cube", vertices, faces)
|
|
|
|
|
|
|
|
def _setupObjects(self, context):
|
|
|
|
scene = context.scene
|
|
|
|
|
|
|
|
fg = scene.render.layers.get("Foreground")
|
|
|
|
bg = scene.render.layers.get("Background")
|
|
|
|
|
|
|
|
all_layers = self._mergeLayers(fg.layers, bg.layers)
|
|
|
|
|
2012-02-08 04:37:37 +00:00
|
|
|
# ensure all lamps are active on foreground and background
|
2011-11-23 17:30:47 +00:00
|
|
|
has_lamp = False
|
|
|
|
has_mesh = False
|
|
|
|
for ob in scene.objects:
|
|
|
|
if ob.type == 'LAMP':
|
|
|
|
ob.layers = all_layers
|
|
|
|
has_lamp = True
|
|
|
|
elif ob.type == 'MESH' and "is_ground" not in ob:
|
|
|
|
has_mesh = True
|
|
|
|
|
|
|
|
# create sample lamp if there's no lamps in the scene
|
|
|
|
if not has_lamp:
|
|
|
|
lamp = self._createLamp(scene)
|
|
|
|
lamp.layers = all_layers
|
|
|
|
|
|
|
|
# create sample object if there's no meshes in the scene
|
|
|
|
if not has_mesh:
|
|
|
|
ob = self._createSampleObject(scene)
|
|
|
|
ob.layers = fg.layers
|
|
|
|
|
|
|
|
# create ground object if needed
|
|
|
|
ground = self._findGround(context)
|
|
|
|
if not ground:
|
|
|
|
ground = self._createGround(scene)
|
|
|
|
ground.layers = bg.layers
|
|
|
|
else:
|
|
|
|
# make sure ground is available on Background layer
|
|
|
|
ground.layers = self._mergeLayers(ground.layers, bg.layers)
|
|
|
|
|
|
|
|
# layers with background and foreground should be rendered
|
|
|
|
scene.layers = self._mergeLayers(scene.layers, all_layers)
|
|
|
|
|
|
|
|
def execute(self, context):
|
2014-06-02 06:46:55 +00:00
|
|
|
scene = context.scene
|
|
|
|
current_active_layer = scene.active_layer
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
self._setupScene(context)
|
|
|
|
self._setupWorld(context)
|
|
|
|
self._setupCamera(context)
|
|
|
|
self._setupViewport(context)
|
|
|
|
self._setupRenderLayers(context)
|
|
|
|
self._setupNodes(context)
|
|
|
|
self._setupObjects(context)
|
|
|
|
|
2014-06-02 06:46:55 +00:00
|
|
|
# Active layer has probably changed, set it back to the original value.
|
|
|
|
# NOTE: The active layer is always true.
|
|
|
|
scene.layers[current_active_layer] = True
|
|
|
|
|
2011-11-23 17:30:47 +00:00
|
|
|
return {'FINISHED'}
|
2012-01-26 15:04:25 +00:00
|
|
|
|
2012-02-04 11:12:18 +00:00
|
|
|
|
2012-01-26 15:04:25 +00:00
|
|
|
class CLIP_OT_track_settings_as_default(Operator):
|
2012-01-30 20:41:36 +00:00
|
|
|
"""Copy tracking settings from active track to default settings"""
|
2012-01-26 15:04:25 +00:00
|
|
|
|
|
|
|
bl_idname = "clip.track_settings_as_default"
|
|
|
|
bl_label = "Track Settings As Default"
|
|
|
|
bl_options = {'UNDO', 'REGISTER'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
sc = context.space_data
|
|
|
|
|
|
|
|
if sc.type != 'CLIP_EDITOR':
|
|
|
|
return False
|
|
|
|
|
|
|
|
clip = sc.clip
|
|
|
|
|
|
|
|
return clip and clip.tracking.tracks.active
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
sc = context.space_data
|
|
|
|
clip = sc.clip
|
|
|
|
|
2012-08-04 10:47:31 +00:00
|
|
|
track = clip.tracking.tracks.active
|
|
|
|
framenr = context.scene.frame_current - clip.frame_start + 1
|
|
|
|
|
|
|
|
CLIP_default_settings_from_track(clip, track, framenr)
|
2012-01-26 15:04:25 +00:00
|
|
|
|
|
|
|
return {'FINISHED'}
|