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

+10 -4
View File
@@ -5,21 +5,27 @@ import subprocess
from .paths import PROJECT, executable, slug
def export(filename, name="Character", collection="Character", blender=None):
def export(filename, name="Character", collection="Character", blender=None, skeletal=False):
source = Path(filename).resolve()
if not source.is_file() or source.suffix.lower() != ".blend":
raise FileNotFoundError(f"Brak pliku .blend: {source}")
destination = PROJECT / "build" / slug(name) / (name + ".glb")
destination = PROJECT / "build" / slug(name) / (name + (".fbx" if skeletal else ".glb"))
destination.parent.mkdir(parents=True, exist_ok=True)
command = [executable("blender", blender), "--background", str(source),
"--python-exit-code", "1", "--python", str(PROJECT / "tools" / "blender_export.py"),
"--", "--output", str(destination), "--collection", collection]
if skeletal:
command.append("--skeletal")
result = subprocess.run(command, capture_output=True, text=True, timeout=180)
if result.returncode or not destination.is_file():
raise RuntimeError("Eksport Blendera nie powiodl sie:\n" + (result.stdout + result.stderr)[-6000:])
return destination
def import_character(filename, name="Character", collection="Character", blender=None):
from .assets import import_model
def import_character(filename, name="Character", collection="Character", blender=None, reimport=True):
from .assets import import_model, _existing_model
if not reimport:
mesh = _existing_model(name)
if mesh is not None:
return mesh
return import_model(export(filename, name, collection, blender), name)