From 3c4bc26830aa30626ad561f347024af0069f23ce Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Mon, 4 Mar 2024 13:13:32 +0100 Subject: [PATCH] chore(tools): more work on auto gltf generation for examples --- .../tests/test_bevy_integration.py | 4 +- tools/internal_generate_example_gltf_files.py | 38 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/tools/gltf_auto_export/tests/test_bevy_integration.py b/tools/gltf_auto_export/tests/test_bevy_integration.py index 70ba140..afd5255 100644 --- a/tools/gltf_auto_export/tests/test_bevy_integration.py +++ b/tools/gltf_auto_export/tests/test_bevy_integration.py @@ -94,11 +94,11 @@ def test_export_complex(setup_data): assert os.path.exists(os.path.join(models_path, "library", "Blueprint7_hierarchy.glb")) == True # now run bevy - bla = "cargo run --features bevy/dynamic_linking" + command = "cargo run --features bevy/dynamic_linking" # assert getattr(propertyGroup, 'a') == 0.5714026093482971 FNULL = open(os.devnull, 'w') #use this if you want to suppress output to stdout from the subprocess filename = "my_file.dat" - args = bla + args = command #subprocess.call(args, stdout=FNULL, stderr=FNULL, shell=False, cwd=bevy_run_exec_path) return_code = subprocess.call(["cargo", "run", "--features", "bevy/dynamic_linking"], cwd=root_path) print("RETURN CODE OF BEVY APP", return_code) diff --git a/tools/internal_generate_example_gltf_files.py b/tools/internal_generate_example_gltf_files.py index 13e70e2..9a2ef36 100644 --- a/tools/internal_generate_example_gltf_files.py +++ b/tools/internal_generate_example_gltf_files.py @@ -1,4 +1,6 @@ +import os import bpy +import subprocess def generate_example_gltf_files(example_path): auto_export_operator = bpy.ops.export_scenes.auto_gltf @@ -12,4 +14,38 @@ def generate_example_gltf_files(example_path): export_legacy_mode=False, export_animations=True )""" - #clear && /home/ckaos/.local/bin/pytest --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender tests \ No newline at end of file + # blender-template + #clear && /home/ckaos/.local/bin/pytest --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender tests + + +examples = [ + '../examples/bevy_gltf_blueprints/basic', + '../examples/bevy_gltf_blueprints/animation', + '../examples/bevy_gltf_blueprints/basic_xpbd_physics', + '../examples/bevy_gltf_blueprints/materials', + '../examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles', +] + +for example_path in examples: + print("generating gltf files for ", example_path) + assets_path = os.path.join(example_path, "assets") + art_path = os.path.join(example_path, "art") + blend_files = [] + + if os.path.exists(assets_path): + for file in os.listdir(assets_path): + if file.endswith(".blend"): + print("file found !", file) + blend_files.append(os.path.join(assets_path, file)) + if os.path.exists(art_path): + for file in os.listdir(art_path): + if file.endswith(".blend"): + print("file found !", file) + blend_files.append(os.path.join(art_path, file)) + + + print("blend files", blend_files) + for blend_file in blend_files: + command = "/home/ckaos/.local/bin/pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender --blender-template "+blend_file + return_code = subprocess.call(command.split(" "), cwd=example_path) + #generate_example_gltf_files(example_path) \ No newline at end of file