feat: update replay

This commit is contained in:
Swann 2022-01-21 09:06:56 +01:00
parent 3fbe769928
commit 48eded1a9b

View File

@ -69,7 +69,7 @@ stop_modal_executor = False
CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras', CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras',
'collections', 'curves', 'filepath', 'fonts', 'collections', 'curves', 'fonts',
'grease_pencils', 'images', 'lattices', 'libraries', 'grease_pencils', 'images', 'lattices', 'libraries',
'lightprobes', 'lights', 'linestyles', 'masks', 'lightprobes', 'lights', 'linestyles', 'masks',
'materials', 'meshes', 'metaballs', 'movieclips', 'materials', 'meshes', 'metaballs', 'movieclips',
@ -113,7 +113,6 @@ def draw_user(username, metadata, radius=0.01, intensity=10.0):
scene = metadata.get('scene_current', bpy.context.scene.name) scene = metadata.get('scene_current', bpy.context.scene.name)
user_collection = bpy.data.collections.new(username) user_collection = bpy.data.collections.new(username)
# User Color # User Color
user_mat = bpy.data.materials.new(username) user_mat = bpy.data.materials.new(username)
user_mat.use_nodes = True user_mat.use_nodes = True
@ -155,7 +154,7 @@ def draw_user(username, metadata, radius=0.01, intensity=10.0):
camera_obj.modifiers.new("wireframe", "SKIN") camera_obj.modifiers.new("wireframe", "SKIN")
camera_obj.data.skin_vertices[0].data[0].use_root = True camera_obj.data.skin_vertices[0].data[0].use_root = True
for v in camera_mesh.skin_vertices[0].data: for v in camera_obj.data.skin_vertices[0].data:
v.radius = [radius, radius] v.radius = [radius, radius]
camera_mesh.materials.append(user_mat) camera_mesh.materials.append(user_mat)
@ -1032,12 +1031,12 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
user_skin_radius: bpy.props.FloatProperty( user_skin_radius: bpy.props.FloatProperty(
name="Wireframe radius", name="Wireframe radius",
description="Wireframe radius", description="Wireframe radius",
default=0.005, default=0.01,
) )
user_color_intensity: bpy.props.FloatProperty( user_color_intensity: bpy.props.FloatProperty(
name="Shading intensity", name="Shading intensity",
description="Shading intensity", description="Shading intensity",
default=10.0, default=1.0,
) )
files: bpy.props.CollectionProperty( files: bpy.props.CollectionProperty(
@ -1431,6 +1430,26 @@ def menu_func_import(self, context):
def menu_func_export(self, context): def menu_func_export(self, context):
self.layout.operator(SessionSaveBackupOperator.bl_idname, text='Multi-user session snapshot (.db)') self.layout.operator(SessionSaveBackupOperator.bl_idname, text='Multi-user session snapshot (.db)')
class SessionRenderReplay(bpy.types.Operator):
bl_idname = "session.render_replay"
bl_label = "Render Replay"
bl_description = "Render Replay"
@classmethod
def poll(cls, context):
return context.window_manager.session.replay_files
def execute(self, context):
base_path = str(context.scene.render.filepath)
for frame in range(0,context.scene.frame_end):
logging.info(f"Rendering frame {frame} to {base_path}_{frame}.png")
context.scene.frame_current = frame
filename = Path(bpy.context.window_manager.session.replay_files[context.scene.active_replay_file].name)
context.scene.render.filepath = f"{base_path}{frame}_{filename.stem}"
bpy.ops.render.render(write_still=True)
context.scene.render.filepath = base_path
return {'FINISHED'}
classes = ( classes = (
SessionConnectOperator, SessionConnectOperator,
@ -1457,6 +1476,7 @@ classes = (
RefreshServerStatus, RefreshServerStatus,
GetDoc, GetDoc,
FirstLaunch, FirstLaunch,
SessionRenderReplay,
) )