Mercurial > games > semicongine
annotate tools/blender_gltf_converter.py @ 1449:9f3306b2ba14 default tip
add: export blender collections as gltf hierarchies
author | sam <sam@basx.dev> |
---|---|
date | Wed, 12 Mar 2025 00:09:26 +0700 |
parents | 34ae5835bfa8 |
children |
rev | line source |
---|---|
389 | 1 import os |
2 import sys | |
3 | |
4 import bpy | |
5 | |
6 | |
7 def runner(): | |
8 script_args = sys.argv[sys.argv.index("--") + 1 :] | |
390 | 9 for i in range(0, len(script_args), 2): |
10 inputfile = script_args[i] | |
11 outputfile = script_args[i + 1] | |
12 if not os.path.exists(inputfile): | |
13 print(f"Input file '{inputfile}' does not exists") | |
14 quit(1) | |
15 if not outputfile.endswith(".glb"): | |
16 print(f"Output file '{outputfile}' is not a *.glb file") | |
17 quit(1) | |
389 | 18 |
390 | 19 bpy.ops.wm.open_mainfile(filepath=inputfile) |
1342 | 20 bpy.ops.export_scene.gltf( |
21 filepath=outputfile[:-4], | |
22 export_apply=True, | |
23 export_yup=True, | |
24 check_existing=False, | |
25 export_image_format="AUTO", | |
26 export_format="GLB", | |
27 export_materials="EXPORT", | |
1449
9f3306b2ba14
add: export blender collections as gltf hierarchies
sam <sam@basx.dev>
parents:
1342
diff
changeset
|
28 export_extras=True, |
9f3306b2ba14
add: export blender collections as gltf hierarchies
sam <sam@basx.dev>
parents:
1342
diff
changeset
|
29 export_hierarchy_full_collections=True, |
1342 | 30 ) |
389 | 31 |
32 | |
33 if __name__ == "__main__": | |
34 runner() |