[Bf-extensions-cvs] [7ad943d5] master: initial commit render shots: T47403 T51145
meta-androcto
noreply at git.blender.org
Mon Apr 17 05:02:48 CEST 2017
Commit: 7ad943d59a3e39f083ed6d6b0b232be650ece3db
Author: meta-androcto
Date: Mon Apr 17 13:02:22 2017 +1000
Branches: master
https://developer.blender.org/rBAC7ad943d59a3e39f083ed6d6b0b232be650ece3db
initial commit render shots: T47403 T51145
===================================================================
A render_shots.py
===================================================================
diff --git a/render_shots.py b/render_shots.py
new file mode 100644
index 00000000..22203ca0
--- /dev/null
+++ b/render_shots.py
@@ -0,0 +1,726 @@
+# ***** 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 LICENCE BLOCK *****
+
+
+bl_info = {
+ "name": "Render Shots",
+ "author": "Aaron Symons",
+ "version": (0, 3, 2),
+ "blender": (2, 76, 0),
+ "location": "Properties > Render > Render Shots",
+ "description": "Render an image or animation from different camera views",
+ "warning": "",
+ "wiki_url": "http://wiki.blender.org/index.php?title=Extensions:2.6/Py"\
+ "/Scripts/Render/Render_Shots",
+ "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
+ "category": "Render"}
+
+
+import bpy
+from bpy.props import BoolProperty, IntProperty, StringProperty
+from bpy.app.handlers import persistent
+import os, shutil
+
+
+#####################################
+# Update Functions
+#####################################
+def shape_nav(self, context):
+ nav = self.rs_shotshape_nav
+
+ if self.rs_shotshape_shape != "":
+ shapeVerts = bpy.data.objects[self.rs_shotshape_shape].data.vertices
+ max = len(shapeVerts)-1
+ min = max - (max+max)
+
+ if nav > max or nav < min:
+ nav = 0
+
+ v = shapeVerts[nav].co
+ self.location = (v[0], v[1], v[2])
+ return None
+
+
+def is_new_object(ob):
+ try:
+ isNew = ob["rs_shotshape_use_frames"]
+ except:
+ isNew = None
+
+ return True if isNew is None else False
+
+
+def update_shot_list(scn):
+ scn.rs_is_updating = True
+ if hasattr(scn, 'rs_create_folders'):
+ scn.rs_create_folders = False
+
+ for ob in bpy.data.objects:
+ if ob.type == 'CAMERA':
+ if is_new_object(ob):
+ ob["rs_shot_include"] = True
+ ob["rs_shot_start"] = scn.frame_start
+ ob["rs_shot_end"] = scn.frame_end
+ ob["rs_shot_output"] = ""
+ ob["rs_toggle_panel"] = True
+ ob["rs_settings_use"] = False
+ ob["rs_resolution_x"] = scn.render.resolution_x
+ ob["rs_resolution_y"] = scn.render.resolution_y
+ ob["rs_cycles_samples"] = 10
+ ob["rs_shotshape_use"] = False
+ ob["rs_shotshape_shape"] = ""
+ ob["rs_shotshape_nav"] = 0
+ ob["rs_shotshape_nav_start"] = False
+ ob["rs_shotshape_offset"] = 1
+ ob["rs_shotshape_use_frames"] = False
+ else:
+ ob["rs_shot_include"]
+ ob["rs_shot_start"]
+ ob["rs_shot_end"]
+ ob["rs_shot_output"]
+ ob["rs_toggle_panel"]
+ ob["rs_settings_use"]
+ ob["rs_resolution_x"]
+ ob["rs_resolution_y"]
+ ob["rs_cycles_samples"]
+ ob["rs_shotshape_use"]
+ ob["rs_shotshape_shape"]
+ ob["rs_shotshape_nav"]
+ ob["rs_shotshape_nav_start"]
+ ob["rs_shotshape_offset"]
+ ob["rs_shotshape_use_frames"]
+
+ scn.rs_is_updating = False
+
+
+#####################################
+# Initialisation
+#####################################
+def init_props():
+ object = bpy.types.Object
+ scene = bpy.types.Scene
+
+ # Camera properties
+ object.rs_shot_include = BoolProperty(name="",
+ description="Include this shot during render", default=True)
+
+ object.rs_shot_start = IntProperty(name="Start",
+ description="First frame in this shot",
+ default=0, min=0, max=300000)
+
+ object.rs_shot_end = IntProperty(name="End",
+ description="Last frame in this shot",
+ default=0, min=0, max=300000)
+
+ object.rs_shot_output = StringProperty(name="",
+ description="Directory/name to save to", subtype='DIR_PATH')
+
+ object.rs_toggle_panel = BoolProperty(name="",
+ description="Show/hide options for this shot", default=True)
+
+ # Render settings
+ object.rs_settings_use = BoolProperty(name = "", default=False,
+ description = "Use specific render settings for this shot")
+
+ object.rs_resolution_x = IntProperty(name="X",
+ description="Number of horizontal pixels in the rendered image",
+ default=2000, min=4, max=10000)
+
+ object.rs_resolution_y = IntProperty(name="Y",
+ description = "Number of vertical pixels in the rendered image",
+ default=2000, min=4, max=10000)
+
+ object.rs_cycles_samples = IntProperty(name="Samples",
+ description = "Number of samples to render for each pixel",
+ default=10, min=1, max=2147483647)
+
+ # Shot shapes
+ object.rs_shotshape_use = BoolProperty(name="", default=False,
+ description="Use a shape to set a series of shots for this camera")
+
+ object.rs_shotshape_shape = StringProperty(name="Shape:",
+ description="Select an object")
+
+ object.rs_shotshape_nav = IntProperty(name="Navigate",
+ description="Navigate through this shape's vertices (0 = first vertex)",
+ default=0, update=shape_nav)
+
+ object.rs_shotshape_nav_start = BoolProperty(name="Start from here",
+ default=False,
+ description="Start from this vertex (skips previous vertices)")
+
+ object.rs_shotshape_offset = IntProperty(name="Offset",
+ description="Offset between frames (defines animation length)",
+ default=1, min=1, max=200)
+
+ object.rs_shotshape_use_frames = BoolProperty(name="Use frame range",
+ description="Use the shot's frame range instead of the object's vertex"\
+ " count", default=False)
+
+ # Internal
+ scene.rs_is_updating = BoolProperty(name="", description="", default=False)
+
+ scene.rs_create_folders = BoolProperty(name="", description="", default=False)
+
+ scene.rs_main_folder = StringProperty(name="Main Folder",
+ subtype='DIR_PATH', default="",
+ description="Main folder in which to create the sub folders")
+
+ scene.rs_overwrite_folders = BoolProperty(name="Overwrite", default=False,
+ description="Overwrite existing folders (this will delete all"\
+ " files inside any existing folders)")
+
+
+
+#####################################
+# Operators and Functions
+#####################################
+RENDER_DONE = True
+RENDER_SETTINGS_HELP = False
+TIMELINE = {"start": 1, "end": 250, "current": 1}
+RENDER_SETTINGS = {"cycles_samples": 10, "res_x": 1920, "res_y": 1080}
+
+
+ at persistent
+def render_finished(unused):
+ global RENDER_DONE
+ RENDER_DONE = True
+
+
+def using_cycles(scn):
+ return True if scn.render.engine == 'CYCLES' else False
+
+
+def timeline_handler(scn, mode):
+ global TIMELINE
+
+ if mode == 'GET':
+ TIMELINE["start"] = scn.frame_start
+ TIMELINE["end"] = scn.frame_end
+ TIMELINE["current"] = scn.frame_current
+
+ elif mode == 'SET':
+ scn.frame_start = TIMELINE["start"]
+ scn.frame_end = TIMELINE["end"]
+ scn.frame_current = TIMELINE["current"]
+
+
+def render_settings_handler(scn, mode, cycles_on, ob):
+ global RENDER_SETTINGS
+
+ if mode == 'GET':
+ RENDER_SETTINGS["cycles_samples"] = scn.cycles.samples
+ RENDER_SETTINGS["res_x"] = scn.render.resolution_x
+ RENDER_SETTINGS["res_y"] = scn.render.resolution_y
+
+ elif mode == 'SET':
+ if cycles_on:
+ scn.cycles.samples = ob["rs_cycles_samples"]
+ scn.render.resolution_x = ob["rs_resolution_x"]
+ scn.render.resolution_y = ob["rs_resolution_y"]
+
+ elif mode == 'REVERT':
+ if cycles_on:
+ scn.cycles.samples = RENDER_SETTINGS["cycles_samples"]
+ scn.render.resolution_x = RENDER_SETTINGS["res_x"]
+ scn.render.resolution_y = RENDER_SETTINGS["res_y"]
+
+
+def frames_from_verts(ob, end, shape, mode):
+ start = ob.rs_shot_start
+ frame_range = (end - start)+1
+ verts = len(shape.data.vertices)
+
+ if frame_range % verts != 0:
+ end += 1
+ return create_frames_from_verts(ob, end, shape, mode)
+ else:
+ if mode == 'OFFSET':
+ return frame_range / verts
+ elif mode == 'END':
+ return end
+
+
+def keyframes_handler(scn, ob, shape, mode):
+ bpy.ops.object.select_all(action='DESELECT')
+ ob.select = True
+
+ start = ob.rs_shotshape_nav if ob.rs_shotshape_nav_start else 0
+
+ if ob.rs_shotshape_use_frames and shape is not None:
+ firstframe = ob.rs_shot_start
+ offset = frames_from_verts(ob, ob.rs_shot_end, shape, 'OFFSET')
+ else:
+ firstframe = 1
+ offset = ob.rs_shotshape_offset
+
+ if mode == 'SET':
+ scn.frame_current = firstframe
+ for vert in shape.data.vertices:
+ if vert.index >= start:
+ ob.location = vert.co
+ bpy.ops.anim.keyframe_insert_menu(type='Location')
+ scn.frame_current += offset
+ return (len(shape.data.vertices) - start) * offset
+
+ elif mode == 'WIPE':
+ ob.animation_data_clear()
+
+
+class RENDER_OT_RenderShots_create_folders(bpy.types.Operator):
+ ''' Create the output folders for all cameras '''
+ bl_idname = "render.rendersh
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list