Skip to content

Commit

Permalink
Merge pull request #6 from Jedipedia/patch-2
Browse files Browse the repository at this point in the history
Add second & third UV layer if it exists
  • Loading branch information
StarLight-Oliver authored Dec 27, 2022
2 parents 8368c80 + d93eb4e commit 895b5dc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions io_scene_gr2/ops/import_gr2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 895b5dc

Please sign in to comment.