2024-03-04 12:13:32 +00:00
|
|
|
import os
|
2024-03-04 12:00:36 +00:00
|
|
|
import bpy
|
2024-03-04 12:13:32 +00:00
|
|
|
import subprocess
|
2024-03-04 12:00:36 +00:00
|
|
|
|
2024-03-04 13:15:30 +00:00
|
|
|
def test_generate_example_gltf_files():
|
2024-03-04 12:00:36 +00:00
|
|
|
auto_export_operator = bpy.ops.export_scenes.auto_gltf
|
|
|
|
stored_settings = bpy.data.texts[".gltf_auto_export_settings"]
|
2024-03-04 13:15:30 +00:00
|
|
|
print("export settings", stored_settings.as_string())
|
|
|
|
auto_export_operator(
|
|
|
|
direct_mode = True,
|
|
|
|
export_change_detection=False
|
|
|
|
)
|
2024-03-04 12:13:32 +00:00
|
|
|
|
2024-03-04 13:15:30 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
examples = [
|
2024-03-04 18:54:20 +00:00
|
|
|
'../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',"""
|
2024-03-04 13:15:30 +00:00
|
|
|
]
|
2024-03-04 12:13:32 +00:00
|
|
|
|
2024-03-04 13:15:30 +00:00
|
|
|
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 = []
|
2024-03-04 12:13:32 +00:00
|
|
|
|
2024-03-04 13:15:30 +00:00
|
|
|
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))
|
2024-03-04 12:13:32 +00:00
|
|
|
|
2024-03-04 13:15:30 +00:00
|
|
|
|
|
|
|
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)
|