From 3c1e39718cc56ff9db7b0ed576c4e79697170362 Mon Sep 17 00:00:00 2001 From: Alan O'Cull Date: Mon, 29 Jan 2024 13:21:04 -0500 Subject: [PATCH] Pipeline tool updates --- animations/insurrectionist/anims-alan.blend | 4 +- pipeline/export_anims.py | 84 +++++++++++++++++++ {ironpress => pipeline}/ironpress.exe | 0 .../pipeline_insurrectionist.cmd | 0 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 pipeline/export_anims.py rename {ironpress => pipeline}/ironpress.exe (100%) rename {ironpress => pipeline}/pipeline_insurrectionist.cmd (100%) diff --git a/animations/insurrectionist/anims-alan.blend b/animations/insurrectionist/anims-alan.blend index ab86b93..2351ed3 100644 --- a/animations/insurrectionist/anims-alan.blend +++ b/animations/insurrectionist/anims-alan.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:af0f0fdf4e9dfb3bdf54ba428fb83818c2f0196e429c29aa8480b514a730a8b8 -size 3330800 +oid sha256:9259a8c6f49512ce4be9db233d2c7ef47ac360a96b364fe620416082f40e3d78 +size 3578836 diff --git a/pipeline/export_anims.py b/pipeline/export_anims.py new file mode 100644 index 0000000..d95260c --- /dev/null +++ b/pipeline/export_anims.py @@ -0,0 +1,84 @@ +import bpy + +# Get export directory +path: str = bpy.data.filepath +pathPrefix = max(path.rfind('animations/'), path.rfind('animations\\')) +pathStart = pathPrefix + len('animations/') +pathEnd = max(path.rfind('/'), path.rfind('\\')) + +# Figure out who made these animations based on filepath +fileIndividual = '' +if 'tommy' in path: + fileIndividual = 'tommy' +elif 'shelby' in path: + fileIndividual = 'shelby' +elif 'alan' in path: + fileIndividual = 'alan' + +# Build export filepath +dirName = path[pathStart:pathEnd] +filePath = path[:pathPrefix] + 'export\\' + dirName + '\\anims_' + dirName + '_' + fileIndividual + '.fbx' + + +# RIG MUST BE ACTIVE +armature = bpy.context.active_object.data +# Set all bone layers, but not mechanical bones, to be visible +for i in range(0, 29): + armature.layers[i] = True +for i in range(29,32): + armature.layers[i] = False + +bpy.ops.object.mode_set(mode='POSE') # Enter pose mode +bpy.ops.pose.transforms_clear() # Clear all transforms + +# Export animations +bpy.ops.export_scene.fbx( + # I/O + filepath = filePath, + check_existing = False, + path_mode = 'STRIP', + batch_mode = 'OFF', + use_visible = True, + object_types = {'MESH', 'ARMATURE'}, + axis_forward = '-Y', + axis_up = 'Z', + + # Mesh Settings + use_mesh_modifiers = True, + use_mesh_modifiers_render = False, + use_triangles = True, + colors_type = 'NONE', + + # Animation + use_armature_deform_only = True, + add_leaf_bones = True, + bake_anim = True, + bake_anim_use_all_bones = True, + bake_anim_use_nla_strips = False, + bake_anim_use_all_actions = True, + bake_anim_force_startend_keying = True, +) + +bpy.ops.pose.transforms_clear() # Clear all transforms +bpy.ops.object.mode_set(mode='OBJECT') + +## FOR DEBUGGING, see https://blender.stackexchange.com/questions/93728/blender-script-run-print-to-console +# from bpy import context +# import builtins as __builtin__ +# def console_print(*args, **kwargs): +# for a in context.screen.areas: +# if a.type == 'CONSOLE': +# c = {} +# c['area'] = a +# c['space_data'] = a.spaces.active +# c['region'] = a.regions[-1] +# c['window'] = context.window +# c['screen'] = context.screen +# s = " ".join([str(arg) for arg in args]) +# for line in s.split("\n"): +# bpy.ops.console.scrollback_append(c, text=line) + +# def print(*args, **kwargs): +# """Console print() function.""" +# console_print(*args, **kwargs) # to py consoles +# __builtin__.print(*args, **kwargs) # to system console diff --git a/ironpress/ironpress.exe b/pipeline/ironpress.exe similarity index 100% rename from ironpress/ironpress.exe rename to pipeline/ironpress.exe diff --git a/ironpress/pipeline_insurrectionist.cmd b/pipeline/pipeline_insurrectionist.cmd similarity index 100% rename from ironpress/pipeline_insurrectionist.cmd rename to pipeline/pipeline_insurrectionist.cmd