From 8e13608e135ed1c21135ebbf4f246248d2f3b639 Mon Sep 17 00:00:00 2001 From: Tommy Hochstetler Date: Fri, 12 Apr 2024 12:10:17 -0400 Subject: [PATCH 1/6] Update anims-tommy6.blend --- animations/insurrectionist/anims-tommy6.blend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/animations/insurrectionist/anims-tommy6.blend b/animations/insurrectionist/anims-tommy6.blend index 9d55595..e65c840 100644 --- a/animations/insurrectionist/anims-tommy6.blend +++ b/animations/insurrectionist/anims-tommy6.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a54553dbe38695573acdda0f8c6ed79c83fffab249e1edbfb0dab44a89a7f815 -size 9833404 +oid sha256:46f9907e4091239a1e02650fbfa55aa8d278eff6a8d66243ca41661b3f99b07c +size 9836956 From 3ed4f6a8d25244a4e77d5530b5afaf2b33e43eac Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 12 Apr 2024 12:16:47 -0400 Subject: [PATCH 2/6] Itch promo materials --- promotional/itch/background.jpg | 3 +++ promotional/itch/screenshot1.png | 3 +++ promotional/itch/screenshot2.png | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 promotional/itch/background.jpg create mode 100644 promotional/itch/screenshot1.png create mode 100644 promotional/itch/screenshot2.png diff --git a/promotional/itch/background.jpg b/promotional/itch/background.jpg new file mode 100644 index 0000000..8a8fe51 --- /dev/null +++ b/promotional/itch/background.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a6168bc139e3fc149fcdfbc8c41d8448215594e7c182c782f679acd4bd2ddf6 +size 1439581 diff --git a/promotional/itch/screenshot1.png b/promotional/itch/screenshot1.png new file mode 100644 index 0000000..46a187f --- /dev/null +++ b/promotional/itch/screenshot1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bc01c2583be6d68d7b8eaada415aad04646bd29f8dc528bded09218d507aef2 +size 2645360 diff --git a/promotional/itch/screenshot2.png b/promotional/itch/screenshot2.png new file mode 100644 index 0000000..83dd219 --- /dev/null +++ b/promotional/itch/screenshot2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab60e506f5413415ea7fcff508222c7c4acbd2a6cd94e257889434bc832031c6 +size 2360287 From e0802adf02be70d248ab3c47605a49cca641be32 Mon Sep 17 00:00:00 2001 From: Tommy Hochstetler Date: Fri, 12 Apr 2024 15:05:36 -0400 Subject: [PATCH 3/6] Update anims-tommy6.blend --- animations/insurrectionist/anims-tommy6.blend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/animations/insurrectionist/anims-tommy6.blend b/animations/insurrectionist/anims-tommy6.blend index e65c840..40199cd 100644 --- a/animations/insurrectionist/anims-tommy6.blend +++ b/animations/insurrectionist/anims-tommy6.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:46f9907e4091239a1e02650fbfa55aa8d278eff6a8d66243ca41661b3f99b07c -size 9836956 +oid sha256:8ffc99bdfebaaa1f4b33f080c8d2f640ad6e06880fa28c8b411db0c6c27ca2ab +size 9842240 From 83f3a77a883479aadaecbc0d3c1e6d14dfb35d63 Mon Sep 17 00:00:00 2001 From: Alan O'Cull Date: Mon, 15 Apr 2024 12:05:32 -0400 Subject: [PATCH 4/6] Upload covers --- promotional/itch/cover1.png | 3 +++ promotional/itch/cover1_bright.png | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 promotional/itch/cover1.png create mode 100644 promotional/itch/cover1_bright.png diff --git a/promotional/itch/cover1.png b/promotional/itch/cover1.png new file mode 100644 index 0000000..4f0b98e --- /dev/null +++ b/promotional/itch/cover1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28033605eac94ad4742adcedf7da3a20bac5af1a7dae2abff780b6d3da017a7d +size 426997 diff --git a/promotional/itch/cover1_bright.png b/promotional/itch/cover1_bright.png new file mode 100644 index 0000000..6d20a0b --- /dev/null +++ b/promotional/itch/cover1_bright.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c86bb1184e31e3e836abf576838868016f02322dfa1838f6670d3693bd37f5f7 +size 539504 From 78682be732dd8df79c826e4b5373b4c646b10863 Mon Sep 17 00:00:00 2001 From: Alan O'Cull Date: Mon, 15 Apr 2024 13:23:17 -0400 Subject: [PATCH 5/6] WIP automate animation export --- .gitignore | 3 +++ .vscode/extensions.json | 8 +++++++ .vscode/settings.json | 19 +++++++++++++++ README.md | 2 ++ animations/infantry/anims-alan.blend | 4 ++-- docs/automation.md | 15 ++++++++++++ pipeline/batch.py | 16 +++++++++++++ pipeline/export_all_anims.cmd | 1 + pipeline/export_anims.py | 35 ++++++++++++++++++++++++++++ 9 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 docs/automation.md create mode 100644 pipeline/batch.py create mode 100644 pipeline/export_all_anims.cmd diff --git a/.gitignore b/.gitignore index 87a2326..84c2670 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ exports/ # Ignore Krita and Blender backups *.*~ + +# Ignore development files +pipeline/blender_autocomplete/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..aefbd80 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "jacqueslucke.blender-development", + "blenderfreetimeprojects.blender-python-code-templates", + "ms-python.vscode-pylance", + "ms-python.python" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c540aca --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "python.autoComplete.extraPaths": [ + "pipeline/blender_autocomplete/3.6" + ], + "python.linting.pylintArgs": [ + "--init-hook", + "import sys; sys.path.append('pipeline/blender_autocomplete/3.6')" + ], + "python.analysis.extraPaths": [ + "pipeline/blender_autocomplete/3.6" + ], + "blender.addon.moduleName": "BoneJuice", + "blender.addon.loadDirectory": "pipeline", + "blender.addon.reloadOnSave": true, + "blender.addon.sourceDirectory": "pipeline", + "python.analysis.diagnosticSeverityOverrides": { + "reportInvalidTypeForm": "none" + } +} \ No newline at end of file diff --git a/README.md b/README.md index 13820c9..42fec2f 100644 --- a/README.md +++ b/README.md @@ -63,5 +63,7 @@ If you need results from an automated process, see the `pipeline` directory. Eac For animations, please include the `pipeline/export_anims.py` script in your Blender file. This allows one-click exporting of FBX animations (may be fully automated with a script later). +See [automation docs](docs/automation.md) + ## Questions If there are any questions or feedback on these guidelines and conventions, please poke Alan with a sharp, pointy stick. diff --git a/animations/infantry/anims-alan.blend b/animations/infantry/anims-alan.blend index 4ad97d2..772b49a 100644 --- a/animations/infantry/anims-alan.blend +++ b/animations/infantry/anims-alan.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e2bfcbb68a409261c659b674e630f91f624708f997d10c6065a6c0d5e45ef34b -size 3414388 +oid sha256:0c2f61a1922d2dff5eda8c6515f549fbbcace13867b6a391a57163e9b838fe75 +size 3520104 diff --git a/docs/automation.md b/docs/automation.md new file mode 100644 index 0000000..6cea5b0 --- /dev/null +++ b/docs/automation.md @@ -0,0 +1,15 @@ +# Automation + +## Setup +- Add Blender 3.6 to your PATH so it can be run from command-line (putting `blender` in cmd should open Blender 3.6) +- Ensure Python is installed on your machine +- Install Blender as a Python module (you might have to do this as administrator): `pip install bpy==3.6.0` + +## Editing + +- Ensure you have Visual Studio Code installed +- Open this directory in VS Code and install the recommended plugins +- Open terminal, `cd` into `pipeline`, and run the following command: `$ git clone https://github.com/Korchy/blender_autocomplete.git` + +## Resources +- [Blender as a Python Module](https://pypi.org/project/bpy/) diff --git a/pipeline/batch.py b/pipeline/batch.py new file mode 100644 index 0000000..3bd6063 --- /dev/null +++ b/pipeline/batch.py @@ -0,0 +1,16 @@ +import bpy +from bpy.app.handlers import persistent +import shutil + +blender_bin = shutil.which("blender") +if blender_bin: + print("Found:", blender_bin) + bpy.app.binary_path = blender_bin +else: + print("Unable to find blender!") + +@persistent +def load_handler(dummy): + print("Load Handler", bpy.data.filepath) + +bpy.app.handlers.load_post(load_handler) diff --git a/pipeline/export_all_anims.cmd b/pipeline/export_all_anims.cmd new file mode 100644 index 0000000..27bea95 --- /dev/null +++ b/pipeline/export_all_anims.cmd @@ -0,0 +1 @@ +blender ..\animations\infantry\anims-alan.blend --background --python export_anims.py \ No newline at end of file diff --git a/pipeline/export_anims.py b/pipeline/export_anims.py index 48eba69..07488d0 100644 --- a/pipeline/export_anims.py +++ b/pipeline/export_anims.py @@ -1,4 +1,39 @@ import bpy +from bpy.types import Collection, LayerCollection, Object, Armature + +# Enter object mode +bpy.ops.object.mode_set(mode='OBJECT') + +# FIRST, toggle collections +collections_exportable = [ + "insurrectionist", "infantry", "rigging", "geometry", "grapple", "baton", "helmet", "gun", "jetpack" +] +def toggle_collection(coll: LayerCollection): + # Iterate over all child LayerCollections + for child in coll.children.values(): + c: LayerCollection = child + + # Force include/exclude character-related collections so they're included/excluded from export + c.exclude = not (c.name in collections_exportable) + if c.name == "insurrectionist" or c.name == "infantry": + bpy.context.view_layer.active_layer_collection = c +toggle_collection(bpy.context.view_layer.layer_collection) + +# Find rig to make it active +armatureObj: Object = None +for objBase in bpy.context.scene.objects: + # print(objBase) + obj: Object = objBase + # print(obj.data) + if obj.type == 'ARMATURE': + print("FOUND AN ARMATURE") + armatureObj = obj + obj.select_set(True) +bpy.context.active_object +print(bpy.context.active_object) +#bpy.context.active_object.animation_data.nla_tracks + +exit() # Get export directory path: str = bpy.data.filepath.replace('\\Shelby', '').replace('\\Tommy', '') From 7ecd958e33c7444dd333c2d3b6333b6c26833f2e Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 15 Apr 2024 17:45:59 -0400 Subject: [PATCH 6/6] Exporter script is fully automated --- docs/automation.md | 8 ++--- pipeline/batch.py | 16 --------- pipeline/export_all_anims.cmd | 4 ++- pipeline/export_anims.py | 63 ++++++++++++++++++----------------- 4 files changed, 39 insertions(+), 52 deletions(-) delete mode 100644 pipeline/batch.py diff --git a/docs/automation.md b/docs/automation.md index 6cea5b0..43a0005 100644 --- a/docs/automation.md +++ b/docs/automation.md @@ -1,15 +1,15 @@ # Automation ## Setup -- Add Blender 3.6 to your PATH so it can be run from command-line (putting `blender` in cmd should open Blender 3.6) -- Ensure Python is installed on your machine -- Install Blender as a Python module (you might have to do this as administrator): `pip install bpy==3.6.0` +- Ensure you have Blender 3.6 installed (hopefully at the location: `C:\Program Files\Blender Foundation\Blender 3.6`) +- Run the script located at `pipeline/export_all_anims.cmd` ## Editing - +- Ensure Python is installed on your machine - Ensure you have Visual Studio Code installed - Open this directory in VS Code and install the recommended plugins - Open terminal, `cd` into `pipeline`, and run the following command: `$ git clone https://github.com/Korchy/blender_autocomplete.git` +- Your workspace is now set up! ## Resources - [Blender as a Python Module](https://pypi.org/project/bpy/) diff --git a/pipeline/batch.py b/pipeline/batch.py deleted file mode 100644 index 3bd6063..0000000 --- a/pipeline/batch.py +++ /dev/null @@ -1,16 +0,0 @@ -import bpy -from bpy.app.handlers import persistent -import shutil - -blender_bin = shutil.which("blender") -if blender_bin: - print("Found:", blender_bin) - bpy.app.binary_path = blender_bin -else: - print("Unable to find blender!") - -@persistent -def load_handler(dummy): - print("Load Handler", bpy.data.filepath) - -bpy.app.handlers.load_post(load_handler) diff --git a/pipeline/export_all_anims.cmd b/pipeline/export_all_anims.cmd index 27bea95..2c0df3e 100644 --- a/pipeline/export_all_anims.cmd +++ b/pipeline/export_all_anims.cmd @@ -1 +1,3 @@ -blender ..\animations\infantry\anims-alan.blend --background --python export_anims.py \ No newline at end of file +set PATH=%PATH%;"C:\Program Files\Blender Foundation\Blender 3.6" +blender ..\animations\infantry\anims-alan.blend --background --python export_anims.py +blender ..\animations\insurrectionist\anims-alan.blend --background --python export_anims.py diff --git a/pipeline/export_anims.py b/pipeline/export_anims.py index 07488d0..b9905a2 100644 --- a/pipeline/export_anims.py +++ b/pipeline/export_anims.py @@ -1,5 +1,5 @@ import bpy -from bpy.types import Collection, LayerCollection, Object, Armature +from bpy.types import LayerCollection, Object, NlaTrack # Enter object mode bpy.ops.object.mode_set(mode='OBJECT') @@ -19,21 +19,40 @@ def toggle_collection(coll: LayerCollection): bpy.context.view_layer.active_layer_collection = c toggle_collection(bpy.context.view_layer.layer_collection) -# Find rig to make it active -armatureObj: Object = None +# Find rig to make it active, and select all objects for objBase in bpy.context.scene.objects: - # print(objBase) obj: Object = objBase - # print(obj.data) if obj.type == 'ARMATURE': - print("FOUND AN ARMATURE") - armatureObj = obj - obj.select_set(True) -bpy.context.active_object -print(bpy.context.active_object) -#bpy.context.active_object.animation_data.nla_tracks + bpy.context.view_layer.objects.active = obj + if obj.visible_get(): + obj.select_set(True) -exit() + +# EXTREMELY UGLY HACK TO EXIT TWEAK MODE +# see: https://blender.stackexchange.com/questions/316547/how-to-override-context-area-using-script-when-running-blender-using-command-lin +# and https://blender.stackexchange.com/questions/6101/poll-failed-context-incorrect-example-bpy-ops-view3d-background-image-add +def get_view_nla(): # Get any window + for window_manager in bpy.data.window_managers: + for window in window_manager.windows: + for area in window.screen.areas: + area.type = 'NLA_EDITOR' + for region in area.regions: + if region.type == 'WINDOW': + return dict(window=window, workspace=window.workspace, screen=window.screen, area=area, region=region) + raise Exception('NLA context not found.') + +# Forcibly override context to a window so we can access NLA editor +with bpy.context.temp_override(**get_view_nla()): + if bpy.context.scene.is_nla_tweakmode: + bpy.ops.nla.tweakmode_exit() # Exit tweakmode + + +# Go through all NLA tracks, unstar them and mute them +bpy.context.active_object.animation_data.nla_tracks.active = None # Make track inactive +for trackBase in bpy.context.active_object.animation_data.nla_tracks: + track: NlaTrack = trackBase + track.mute = True # Mute all tracks + track.is_solo = False # Disable solo view for all tracks # Get export directory path: str = bpy.data.filepath.replace('\\Shelby', '').replace('\\Tommy', '') @@ -109,22 +128,4 @@ 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 +# exit()