annotate scripts/blender_gltf_converter.py @ 871:1f1e959a5fa3

fix: error on bad uniform-attribute ordering
author Sam <sam@basx.dev>
date Mon, 08 Jan 2024 19:18:01 +0700
parents 8f0c82acb922
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
850
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
1 import os
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
2 import sys
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
3
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
4 import bpy
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
5
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
6
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
7 def runner():
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
8 script_args = sys.argv[sys.argv.index("--") + 1 :]
851
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
9 for i in range(0, len(script_args), 2):
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
10 inputfile = script_args[i]
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
11 outputfile = script_args[i + 1]
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
12 if not os.path.exists(inputfile):
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
13 print(f"Input file '{inputfile}' does not exists")
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
14 quit(1)
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
15 if not outputfile.endswith(".glb"):
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
16 print(f"Output file '{outputfile}' is not a *.glb file")
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
17 quit(1)
850
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
18
851
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
19 bpy.ops.wm.open_mainfile(filepath=inputfile)
8f0c82acb922 did: finish importing system
Sam <sam@basx.dev>
parents: 850
diff changeset
20 bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True)
850
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
21
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
22
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
23 if __name__ == "__main__":
013ed7a37709 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
24 runner()