Enable the geo list script to dump all the data for one object

master
Senpai 6 days ago
parent fe2b5b8622
commit ffa082b743

@ -6,11 +6,17 @@ from geo import Geo
show_triangles = False show_triangles = False
show_scales = False show_scales = False
do_dump = False
def listGeo(fn, fh): def listGeo(fn, fh):
geo = Geo() geo = Geo()
geo.loadFromFile(fh) geo.loadFromFile(fh)
for m in geo.models: for m in geo.models:
if do_dump and m.name.decode("utf-8") != dump_name:
continue
if do_dump:
m.dump()
return
s = "%s : %s" % (geo.header_modelheader_name.decode("utf-8"), m.name.decode("utf-8")) s = "%s : %s" % (geo.header_modelheader_name.decode("utf-8"), m.name.decode("utf-8"))
if show_triangles: if show_triangles:
s += " : %d" % (m.tris and len(m.tris) or 0, ) s += " : %d" % (m.tris and len(m.tris) or 0, )
@ -21,11 +27,14 @@ def listGeo(fn, fh):
def parseOption(opt): def parseOption(opt):
global show_triangles global show_triangles
global show_scales global show_scales
global do_dump
for c in opt[1:]: for c in opt[1:]:
if c == "t": if c == "t":
show_triangles = True show_triangles = True
elif c == "s": elif c == "s":
show_scales = True show_scales = True
elif c == "d":
do_dump = True
if len(sys.argv) <= 1: if len(sys.argv) <= 1:
@ -34,10 +43,15 @@ if len(sys.argv) <= 1:
print("Options:") print("Options:")
print(" -t Display triangle count.") print(" -t Display triangle count.")
print(" -s Display model scale.") print(" -s Display model scale.")
print(" -d <object name> Dump model.")
exit() exit()
dump_name = ""
for i in range(1, len(sys.argv)): for i in range(1, len(sys.argv)):
if do_dump and not dump_name:
dump_name = sys.argv[i]
continue
if sys.argv[i].startswith("-"): if sys.argv[i].startswith("-"):
parseOption(sys.argv[i]) parseOption(sys.argv[i])
continue continue

Loading…
Cancel
Save