From c95eead100251c90773124075b5e4dd12f22f1c3 Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Mon, 4 Mar 2024 14:15:30 +0100 Subject: [PATCH] feat(tools): (re) generating gltf files for examples by script works ! * hack-ish, reuses our pytest boilerplate, but good enough for now --- tools/internal_gen.py | 8 --- tools/internal_generate_example_gltf_files.py | 72 +++++++++---------- 2 files changed, 34 insertions(+), 46 deletions(-) delete mode 100644 tools/internal_gen.py diff --git a/tools/internal_gen.py b/tools/internal_gen.py deleted file mode 100644 index 98a9c3c..0000000 --- a/tools/internal_gen.py +++ /dev/null @@ -1,8 +0,0 @@ -import bpy - -def test_fake(): - auto_export_operator = bpy.ops.export_scenes.auto_gltf - stored_settings = bpy.data.texts[".gltf_auto_export_settings"] - print("OHHHHHHHHHHHHHHHHHHHHHHHHHHHHH") - print("export settings", stored_settings.as_string()) - #auto_export_operator(direct_mode = True) \ No newline at end of file diff --git a/tools/internal_generate_example_gltf_files.py b/tools/internal_generate_example_gltf_files.py index f05f8e6..058f8f8 100644 --- a/tools/internal_generate_example_gltf_files.py +++ b/tools/internal_generate_example_gltf_files.py @@ -2,51 +2,47 @@ import os import bpy import subprocess -def generate_example_gltf_files(example_path): +def test_generate_example_gltf_files(): auto_export_operator = bpy.ops.export_scenes.auto_gltf stored_settings = bpy.data.texts[".gltf_auto_export_settings"] - print("export settings", stored_settings) - """auto_export_operator( - direct_mode=True, - export_output_folder="./models", - export_scene_settings=True, - export_blueprints=True, - export_legacy_mode=False, - export_animations=True - )""" - # blender-template - #clear && /home/ckaos/.local/bin/pytest --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender tests + print("export settings", stored_settings.as_string()) + auto_export_operator( + direct_mode = True, + export_change_detection=False + ) - -examples = [ +if __name__ == "__main__": + """ '../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', -] + """ + examples = [ -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 = [] + '../examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles', + ] - 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", 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", file)) + 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 = [] - - print("blend files", blend_files) - for blend_file in blend_files: - fake_test_path = os.path.abspath("./internal_gen.py") - command = "pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender --blender-template "+blend_file + " "+fake_test_path - return_code = subprocess.call(command.split(" "), cwd=example_path) - #generate_example_gltf_files(example_path) \ No newline at end of file + 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", 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", file)) + + + print("blend files", blend_files) + for blend_file in blend_files: + fake_test_path = os.path.abspath("./internal_generate_example_gltf_files.py") + command = "pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender --blender-template "+blend_file + " "+fake_test_path + return_code = subprocess.call(command.split(" "), cwd=example_path)