File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import argparse
2+ import subprocess
3+ import os
4+ import shutil
5+ from pathlib import Path
6+
7+ def convert_command (terrainconverter_path , input_file , output_file ):
8+ command = [
9+ terrainconverter_path ,
10+ "--input" , input_file ,
11+ "--output" , output_file ,
12+ "--verbosity" , "info" ]
13+ try :
14+ subprocess .run (command , check = False )
15+ except subprocess .CalledProcessError as e :
16+ print ("ERROR" )
17+ pass
18+
19+ def main ():
20+ parser = argparse .ArgumentParser (description = "Recursively convert all .tile files in a folder structure to .glb files" )
21+ parser .add_argument ("--terrainconverter" , required = True , help = "Path to the terrainconverter executable" )
22+ parser .add_argument ("--dir" , required = True , help = "The root folder containing the .tile files" )
23+ parser .add_argument ("--suffix" , help = "A suffix that will get inserted like so: <filename><suffix>.glb to the output files" )
24+
25+ args = parser .parse_args ()
26+
27+ terrainconverter_path = args .terrainconverter
28+ tiles_root_path = args .dir
29+ suffix = args .suffix
30+
31+ pathlist = Path (tiles_root_path ).glob ('**/*.tile' )
32+ for path in pathlist :
33+ in_file = path
34+ out_file = path .with_stem (f"{ path .stem } { suffix if suffix else '' } " ).with_suffix (".glb" )
35+
36+ exists = os .path .exists (out_file )
37+
38+ print (f"{ in_file } >>> { out_file } { ' SKIP' if exists else '' } " )
39+
40+ if not exists :
41+ convert_command (terrainconverter_path , in_file , out_file )
42+
43+
44+ if __name__ == "__main__" :
45+ main ()
You can’t perform that action at this time.
0 commit comments