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:
parent
d0f49c851a
commit
c95eead100
|
@ -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)
|
|
|
@ -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 file.endswith(".blend"):
|
|
||||||
print("file found !", file)
|
|
||||||
blend_files.append(os.path.join("art", file))
|
|
||||||
|
|
||||||
|
if os.path.exists(assets_path):
|
||||||
print("blend files", blend_files)
|
for file in os.listdir(assets_path):
|
||||||
for blend_file in blend_files:
|
if file.endswith(".blend"):
|
||||||
fake_test_path = os.path.abspath("./internal_gen.py")
|
print("file found !", file)
|
||||||
command = "pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender --blender-template "+blend_file + " "+fake_test_path
|
blend_files.append(os.path.join("assets", file))
|
||||||
return_code = subprocess.call(command.split(" "), cwd=example_path)
|
if os.path.exists(art_path):
|
||||||
#generate_example_gltf_files(example_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)
|
||||||
|
|
Loading…
Reference in New Issue