From 42cc294f62f295d57987873008c466a6201984e6 Mon Sep 17 00:00:00 2001 From: Hipstercat Date: Mon, 1 Feb 2021 11:50:55 +0100 Subject: [PATCH] more checks --- obj2gbs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/obj2gbs.py b/obj2gbs.py index 808ffb9..e33764a 100644 --- a/obj2gbs.py +++ b/obj2gbs.py @@ -4,6 +4,7 @@ from lib.packet import Packet from lib.fileutils import * from lib.game import Vec3, VecRGB, cross import argparse +import sys GBS_VERSION = 0xaa0100be GBSFlagNormals = 0x0001 @@ -379,8 +380,18 @@ class GbsData: num_faces = sum([len(o.faces) for o in objects]) print("%s vertices, %s uvs, %s normals, %s objects, %s materials, %s faces" % (len(vertices), len(uvs), len(normals), len(objects), len(materials), num_faces)) - # assert len(objects) >= len(materials) - assert len(vertices) < 0xffff + + try: + assert(len(vertices) < 32000) + except AssertionError: + print("Your model has %s vertices. Giants only supports a maximum of 32k vertices" % len(vertices)) + sys.exit(1) + + try: + assert(len(uv_ind) < 0xffff) + except AssertionError: + print("Your model has %s UV. Giants only supports a maximum of 65k UV per model" % len(uv_ind)) + sys.exit(1) len_vertices = len(vertices) len_normals = len(normals)