OpenGL treats the vertex as one long vector
(position, normal, texcoord[0]β¦texcoord[n], attrib[0]β¦attrib[n])
and these long vectors are indexed. Your question falls into the same category as using shared vertices with multiple normals. And the canonical answer is that these peaks are not actually separated, because in the long run they are not identical.
So, you need to iterate over the array of face indices and build the βlongβ vertices by adding them to the (new) list with uniquenes constraint; a (hash map) from the top -> index serves this task. Something like that
next_uniq_index = 0 for f in faces: for i in f.indices: vpos = vertices[i.vertex] norm = normals[i.normal] texc = texcoords[i.texcoord] vert = tuple(vpos, norm, texc) key if uniq_vertices.has_key(key): uniq_faces_indices.append(uniq_vertices[key].index) else: uniq_vertices[key] = {vertex = key, index = next_uniq_index} next_uniq_index = next_uniq_index + 1
datenwolf
source share