advanced example

This commit is contained in:
Vysyr committed 2026-10-31 20:16:32 +01:00
1 parent 8c0a639fba
commit 6fe57915e8
99 files changed
+1329 -56

No files matched your search

+22 -1
View File
@@ -1,4 +1,4 @@
"""Executed by Blender, never by Unreal. Export an evaluated, joined static mesh."""
"""Executed by Blender: static GLB or skinned FBX with the active animation."""
import argparse
from pathlib import Path
import sys
@@ -10,6 +10,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("--output", required=True)
parser.add_argument("--collection", default="Character")
parser.add_argument("--skeletal", action="store_true")
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:])
collection = bpy.data.collections.get(args.collection)
if collection is None:
@@ -18,6 +19,26 @@ def main():
if not meshes:
raise RuntimeError("Kolekcja Character nie zawiera siatek.")
bpy.ops.object.select_all(action="DESELECT")
if args.skeletal:
armatures = {modifier.object for obj in meshes for modifier in obj.modifiers
if modifier.type == "ARMATURE" and modifier.object is not None}
if len(armatures) != 1:
raise RuntimeError("Eksport szkieletowy wymaga jednego Armature przypisanego do siatek.")
armature = next(iter(armatures))
for obj in [*meshes, armature]:
obj.hide_set(False)
obj.select_set(True)
bpy.context.view_layer.objects.active = armature
output = Path(args.output).resolve()
output.parent.mkdir(parents=True, exist_ok=True)
bpy.ops.export_scene.fbx(
filepath=str(output), use_selection=True, object_types={"MESH", "ARMATURE"},
add_leaf_bones=False, use_armature_deform_only=False, bake_anim=True,
bake_anim_use_all_actions=False, bake_anim_use_nla_strips=False,
bake_anim_force_startend_keying=True, bake_anim_simplify_factor=0.0,
axis_forward="-Y", axis_up="Z", path_mode="COPY", embed_textures=True)
print("WORKSHOP_EXPORTED=" + str(output))
return
depsgraph = bpy.context.evaluated_depsgraph_get()
copies = []
for obj in meshes: