forked from stuntrally/stuntrally3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathogre-mesh.py
executable file
·108 lines (86 loc) · 3 KB
/
ogre-mesh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/python3
#!/usr/bin/env python3
import sys
import os
# script to convert .mesh files
# from v1 SR 2.7 to v2 SR 3.0 with lods
# setup dirs -- change to yours to use -----
work_dir = '/home/ch/_sr/Ogre/ogre-next/build/Release/bin/'
tool = './OgreMeshTool'
data = '/home/ch/_sr/_sr3/data/'
recursive = False
#start_dir = os.getcwd()
#recursive = True
# start_dir = data + 'trees2'
# args = ' -v2 -e -t -ts 4 -O puqs -l 4 -d 200 -p 20 ' # objs
# args = ' -v2 -e -t -ts 4 -O puqs -l 6 -d 200 -p 15 ' # trees, rocks
# configs for Media subdirs
#------------------------------
# ---- new
start_dir = data + 'objects2convert/'
# ---- presets ----
# jungle tree 30k?
args = ' -v2 -e -t -ts 4 -O puqs -l 6 -d 100 -p 15 ' # 5 lods lowest
# args = ' -v2 -e -t -ts 4 -O puqs ' # no lods + highest quality, no drop
#args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 200 -p 8 ' # 3 lods high quality, low drop
#args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 200 -p 10 ' # 3 lods medium
# args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 200 -p 12 ' # 3 lods low
# args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 200 -p 15 ' # 3 lods lowest quality, quick drop
# rocks/ hex*
#start_dir = data + 'rockshex/'
#args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 400 -p 12 ' # 3 lods
# objects0/ 0 A.D. buildings
#start_dir = data + 'objects0/'
#args = ' -v2 -e -t -ts 4 -O puqs ' # no lods +
# args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 600 -p 5 ' # 3 lods bad-
# objects2/ satelite, hq
#start_dir = data + 'objects2/'
#args = ' -v2 -e -t -ts 4 -O puqs -l 3 -d 600 -p 15 ' # 4 lods far
# objectsC/ alien,city,skyscraper
#start_dir = data + 'objectsC/'
#args = ' -v2 -e -t -ts 4 -O puqs ' # no lods +
# args = ' -v2 -e -t -ts 4 -O puqs -l 2 -d 600 -p 10 ' # 3 lods far bad-
#------------------------------
cnt = 0
err = 0
#new_ext = '+.mesh'
os.chdir(work_dir)
# Process 1 file ext
#------------------------------------------------------------------------------------------
def process_file_ext(dir, fname):
global cnt
global err
fpath = os.path.join(dir, fname)
if not os.path.isfile(fpath):
return
fspl = os.path.splitext(fname)
fne = fspl[0] # fname no ext
ext = str.lower(fspl[1][1:])
#size = os.path.getsize(fpath)/1000 # KiB
#print(fname+' '+ext+' '+str(size))
if ext == 'mesh':
cnt += 1
#new_fpath = os.path.join(dir, fne + new_ext)
print('------- ' + str(cnt) + ' --- ' + fname)
#cmd = tool + ' -v2 -l 4 -d 200 -p 20 ' + fname # old
cmd = tool + args + dir +'/'+ fname # new opt
print(cmd)
ret = os.system(cmd)
if ret != 0:
err += 1
#exit(0)
# Main loop
#------------------------------------------------------------------------------------------
if not recursive:
files = os.listdir(start_dir)
for fname in files:
process_file_ext(start_dir, fname)
else:
for dir, subdirs, files in os.walk(start_dir):
if dir.find('/.') != -1: # skip hidden
continue
for fname in files:
process_file_ext(dir, fname)
# stats
print('---- End')
print('All: ' + str(cnt) + ' errors: ' + str(err))