From cbefa340bfd2a6b0c6a1f1c794b3b99d56604d97 Mon Sep 17 00:00:00 2001 From: TigerKat Date: Wed, 24 Jul 2019 10:38:07 +0930 Subject: [PATCH] Added a -t option to geo_list.py for displaying the triangle count of a model. --- geo_list.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/geo_list.py b/geo_list.py index c895f71..b3c3be5 100644 --- a/geo_list.py +++ b/geo_list.py @@ -4,21 +4,36 @@ import sys import re from geo import Geo +show_triangles = False + def listGeo(fn, fh): geo = Geo() geo.loadFromFile(fh) for m in geo.models: - print("%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: + s += " : %d" % (m.tris and len(m.tris) or 0, ) + print(s) +def parseOption(opt): + global show_triangles + for c in opt[1:]: + if c == "t": + show_triangles = True if len(sys.argv) <= 1: print("Usage:") - print(" %s " % (sys.argv[0], )) + print(" %s [] " % (sys.argv[0], )) + print("Options:") + print(" -t Display triangle count.") exit() for i in range(1, len(sys.argv)): + if sys.argv[i].startswith("-"): + parseOption(sys.argv[i]) + continue try: fn = sys.argv[i] fh = open(fn, "rb")