From d93eb4eae860fdb7cc8233b06398e1baefddcfac Mon Sep 17 00:00:00 2001 From: Jedipedia <26947989+Jedipedia@users.noreply.github.com> Date: Tue, 27 Dec 2022 02:54:20 +0100 Subject: [PATCH] Add 2nd & 3rd UV layer if it exists --- io_scene_gr2/ops/import_gr2.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/io_scene_gr2/ops/import_gr2.py b/io_scene_gr2/ops/import_gr2.py index 62189fc..9576615 100644 --- a/io_scene_gr2/ops/import_gr2.py +++ b/io_scene_gr2/ops/import_gr2.py @@ -280,6 +280,10 @@ def build(gr2, filepath="", import_collision=False): # we can only set custom loop normals *after* calling it. bmesh.create_normals_split() bmesh.uv_layers.new(do_init=False) + if mesh.bit_flag2 & 64: # 0x40 + bmesh.uv_layers.new(do_init=False) + if mesh.bit_flag2 & 128: # 0x80 + bmesh.uv_layers.new(do_init=False) for j, polygon in enumerate(bmesh.polygons): loop_indices = polygon.loop_indices @@ -289,6 +293,12 @@ def build(gr2, filepath="", import_collision=False): bmesh.loops[loop_index].normal = [v.normals.x, v.normals.y, v.normals.z] bmesh.uv_layers[0].data[loop_index].uv = [v.uv_layer0.x, 1 - v.uv_layer0.y] + if mesh.bit_flag2 & 64: # 0x40 + bmesh.uv_layers[1].data[loop_index].uv = [v.uv_layer1.x, 1 - v.uv_layer1.y] + + if mesh.bit_flag2 & 128: # 0x80 + bmesh.uv_layers[2].data[loop_index].uv = [v.uv_layer2.x, 1 - v.uv_layer2.y] + polygon.material_index = material_indices[j] bmesh.validate(clean_customdata=False)