chore(tools): more work on auto gltf generation for examples

This commit is contained in:
kaosat.dev 2024-03-04 13:13:32 +01:00
parent 6c8593f82d
commit 3c4bc26830
2 changed files with 39 additions and 3 deletions

View File

@ -94,11 +94,11 @@ def test_export_complex(setup_data):
assert os.path.exists(os.path.join(models_path, "library", "Blueprint7_hierarchy.glb")) == True assert os.path.exists(os.path.join(models_path, "library", "Blueprint7_hierarchy.glb")) == True
# now run bevy # now run bevy
bla = "cargo run --features bevy/dynamic_linking" command = "cargo run --features bevy/dynamic_linking"
# assert getattr(propertyGroup, 'a') == 0.5714026093482971 # assert getattr(propertyGroup, 'a') == 0.5714026093482971
FNULL = open(os.devnull, 'w') #use this if you want to suppress output to stdout from the subprocess FNULL = open(os.devnull, 'w') #use this if you want to suppress output to stdout from the subprocess
filename = "my_file.dat" filename = "my_file.dat"
args = bla args = command
#subprocess.call(args, stdout=FNULL, stderr=FNULL, shell=False, cwd=bevy_run_exec_path) #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) return_code = subprocess.call(["cargo", "run", "--features", "bevy/dynamic_linking"], cwd=root_path)
print("RETURN CODE OF BEVY APP", return_code) print("RETURN CODE OF BEVY APP", return_code)

View File

@ -1,4 +1,6 @@
import os
import bpy import bpy
import subprocess
def generate_example_gltf_files(example_path): def generate_example_gltf_files(example_path):
auto_export_operator = bpy.ops.export_scenes.auto_gltf 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_legacy_mode=False,
export_animations=True 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 #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)