feat(tools): (re) generating gltf files for examples by script works !

* hack-ish, reuses our pytest boilerplate, but good enough for now
This commit is contained in:
kaosat.dev 2024-03-04 14:15:30 +01:00
parent d0f49c851a
commit c95eead100
2 changed files with 34 additions and 46 deletions

View File

@ -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)

View File

@ -2,51 +2,47 @@ import os
import bpy import bpy
import subprocess import subprocess
def generate_example_gltf_files(example_path): def test_generate_example_gltf_files():
auto_export_operator = bpy.ops.export_scenes.auto_gltf auto_export_operator = bpy.ops.export_scenes.auto_gltf
stored_settings = bpy.data.texts[".gltf_auto_export_settings"] stored_settings = bpy.data.texts[".gltf_auto_export_settings"]
print("export settings", stored_settings) print("export settings", stored_settings.as_string())
"""auto_export_operator( auto_export_operator(
direct_mode=True, direct_mode = True,
export_output_folder="./models", export_change_detection=False
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
if __name__ == "__main__":
examples = [ """
'../examples/bevy_gltf_blueprints/basic', '../examples/bevy_gltf_blueprints/basic',
'../examples/bevy_gltf_blueprints/animation', '../examples/bevy_gltf_blueprints/animation',
'../examples/bevy_gltf_blueprints/basic_xpbd_physics', '../examples/bevy_gltf_blueprints/basic_xpbd_physics',
'../examples/bevy_gltf_blueprints/materials', '../examples/bevy_gltf_blueprints/materials',
'../examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles', """
] examples = [
for example_path in examples: '../examples/bevy_gltf_blueprints/multiple_levels_multiple_blendfiles',
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 example_path in examples:
for file in os.listdir(assets_path): print("generating gltf files for ", example_path)
if file.endswith(".blend"): assets_path = os.path.join(example_path, "assets")
print("file found !", file) art_path = os.path.join(example_path, "art")
blend_files.append(os.path.join("assets", file)) blend_files = []
if os.path.exists(art_path):
for file in os.listdir(art_path): if os.path.exists(assets_path):
if file.endswith(".blend"): for file in os.listdir(assets_path):
print("file found !", file) if file.endswith(".blend"):
blend_files.append(os.path.join("art", file)) 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) print("blend files", blend_files)
for blend_file in blend_files: for blend_file in blend_files:
fake_test_path = os.path.abspath("./internal_gen.py") 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 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) return_code = subprocess.call(command.split(" "), cwd=example_path)
#generate_example_gltf_files(example_path)