From 641db2198b572aa268012370c1ac8c4b3e62db60 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Fri, 22 Feb 2019 18:45:36 +0100 Subject: glTF importer: fix vertex color when using specific indices tab --- io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py index 4439a05c..b4263e34 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py @@ -169,7 +169,16 @@ class BlenderMesh(): if vertex_color is None: vertex_color = obj.data.vertex_colors.new(name="COLOR_0") - color_data = BinaryData.get_data_from_accessor(gltf, prim.attributes['COLOR_0']) + original_color_data = BinaryData.get_data_from_accessor(gltf, prim.attributes['COLOR_0']) + + tmp_indices = {} + tmp_idx = 0 + color_data = [] + for i in prim.tmp_indices: + if i[0] not in tmp_indices.keys(): + tmp_indices[i[0]] = tmp_idx + tmp_idx += 1 + color_data.append(original_color_data[i[0]]) for poly in mesh.polygons: for loop_idx in range(poly.loop_start, poly.loop_start + poly.loop_total): -- cgit v1.2.3