def parse_f(self): # Add default material if not created if self.material is None: self.material = Material( "default{}".format(len(self.wavefront.materials)), is_default=True, has_faces=self.collect_faces ) self.wavefront.materials[self.material.name] = self.material # Support objects without `o` statement if self.mesh is None: self.mesh = Mesh(has_faces=self.collect_faces) self.wavefront.add_mesh(self.mesh) self.mesh.add_material(self.material) self.mesh.add_material(self.material) collected_faces = [] consumed_vertices = self.consume_faces(collected_faces if self.collect_faces else None) self.material.vertices += list(consumed_vertices) if self.collect_faces: self.mesh.faces += list(collected_faces) # Since list() also consumes StopIteration we need to sanity check the line # to make sure the parser advances if self.values and self.values[0] == "f": self.next_line()
def parse_f(self): # Support objects without `o` statement if self.mesh is None: self.mesh = Mesh() self.wavefront.add_mesh(self.mesh) # Add default material if not created if self.material is None: self.material = Material(is_default=True) self.wavefront.materials[self.material.name] = self.material self.mesh.add_material(self.material) self.material.vertices += list(self.consume_faces()) # Since list() also consumes StopIteration we need to sanity check the line # to make sure the parser advances if self.values[0] == "f": self.next_line()
def parse_o(self): self.mesh = Mesh(self.values[1], has_faces=self.collect_faces) self.wavefront.add_mesh(self.mesh)
def parse_o(self): self.mesh = Mesh(self.values[1]) self.wavefront.add_mesh(self.mesh)