A little cleaner

This commit is contained in:
Thomas FORGIONE 2017-01-17 18:03:00 +01:00
parent c0ced36370
commit 5ee5d5c3f9
No known key found for this signature in database
GPG Key ID: 2A210FFC062E00C3
1 changed files with 29 additions and 11 deletions

View File

@ -294,22 +294,40 @@ class PLYLittleEndianContentParser:
elif self.current_element.name == 'face': elif self.current_element.name == 'face':
vertex_indices = []
tex_coords = []
material = None
for (i, property) in enumerate(self.current_element.properties):
if property[0] == 'vertex_indices':
vertex_indices.append(property_values[i][0])
vertex_indices.append(property_values[i][1])
vertex_indices.append(property_values[i][2])
elif property[0] == 'texcoord':
# Create texture coords # Create texture coords
for i in range(0,6,2): for j in range(0,6,2):
tex_coord = TexCoord(*property_values[1][i:i+2]) tex_coord = TexCoord(*property_values[i][j:j+2])
tex_coords.append(tex_coord)
elif property[0] == 'texnumber':
material = self.parent.materials[property_values[i]]
for tex_coord in tex_coords:
self.parent.add_tex_coord(tex_coord) self.parent.add_tex_coord(tex_coord)
face = Face(\ face = Face(*list(map(lambda x: FaceVertex(x), vertex_indices)))
FaceVertex(property_values[0][0], len(self.parent.tex_coords)-3), \
FaceVertex(property_values[0][1], len(self.parent.tex_coords)-2), \
FaceVertex(property_values[0][2], len(self.parent.tex_coords)-1))
face.material = self.parent.materials[property_values[2]] counter = 3
for face_vertex in [face.a, face.b, face.c]:
face_vertex.tex_coord = len(self.parent.tex_coords) - counter
counter -= 1
face.material = material
self.parent.add_face(face) self.parent.add_face(face)
pass
self.counter += 1 self.counter += 1
if self.counter == self.current_element.number: if self.counter == self.current_element.number: