File tree Expand file tree Collapse file tree 4 files changed +78
-3
lines changed
Expand file tree Collapse file tree 4 files changed +78
-3
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ def parse_vt(self):
183183
184184 # Since list() also consumes StopIteration we need to sanity check the line
185185 # to make sure the parser advances
186- if self .values [0 ] == "vt" :
186+ if self .values and self . values [0 ] == "vt" :
187187 self .next_line ()
188188
189189 def consume_texture_coordinates (self ):
@@ -396,8 +396,8 @@ def emit_vertex(vertex):
396396 idx = v_index ,
397397 pos = self .wavefront .vertices [v_index ][0 :3 ] if has_colors else self .wavefront .vertices [v_index ],
398398 color = self .wavefront .vertices [v_index ][3 :] if has_colors else (),
399- uv = self .tex_coords [t_index ] if has_vt else (),
400- normal = self .normals [n_index ] if has_vn else ()
399+ uv = self .tex_coords [t_index ] if has_vt and t_index < len ( self . tex_coords ) else (),
400+ normal = self .normals [n_index ] if has_vn and n_index < len ( self . normals ) else ()
401401 )
402402
403403 yield from emit_vertex (vcurrent )
Original file line number Diff line number Diff line change 1+ # Comment
2+ mtllib simple.mtl
3+ o Simple
4+
5+ v 0.01 0.02 0.03
6+ v 0.04 0.05 0.06
7+ v 0.07 0.08 0.09
8+ v 0.11 0.12 0.13
9+
10+ vt 10 11
11+ vt 12 13
12+ vt 14 15
13+ vt 16 17
14+
15+ vn 20 21 22
16+
17+ usemtl Material.simple
18+ f 2 /3 /1 1 /2 /1 3 /1 /1
19+ o SimpleB
20+
21+ v 1.0 0.0 1.0
22+ v -1.0 0.0 1.0
23+ v 1.0 0.0 -1.0
24+ v -1.0 0.0 -1.0
25+
26+ vt 0.0 1.0
27+ vt 0.0 0.0
28+ vt 1.0 0.0
29+ vt 1.0 1.0
30+
31+ vn 0.0 1.0 -0.0
32+
33+ usemtl Material2.simple
34+
35+ f 6 /7 /2 5 /6 /2 7 /5 /2
Original file line number Diff line number Diff line change 1+ # Comment
2+ mtllib simple.mtl
3+ o Simple
4+ v 0.01 0.02 0.03
5+ v 0.04 0.05 0.06
6+ v 0.07 0.08 0.09
7+ v 0.11 0.12 0.13
8+ vt 10 11
9+ vt 12 13
10+ vt 14 15
11+ vt 16 17
12+ vn 20 21 22
13+ usemtl Material.simple
14+ f 2 /3 /1 1 /2 /1 3 /1 /1
15+ o SimpleB
16+ v 1.0 0.0 1.0
17+ v -1.0 0.0 1.0
18+ v 1.0 0.0 -1.0
19+ v -1.0 0.0 -1.0
20+ vt 0.0 1.0
21+ vt 0.0 0.0
22+ vt 1.0 0.0
23+ vt 1.0 1.0
24+ vn 0.0 1.0 -0.0
25+ usemtl Material2.simple
26+ f 6 /7 /0 5 /6 /2 7 /5 /0
Original file line number Diff line number Diff line change @@ -70,3 +70,17 @@ def setUp(self):
7070 self .mesh_names = [None ]
7171 self .material_names = ["default0" ]
7272 self .meshes = pywavefront .Wavefront (prepend_dir ('simple_no_object_no_mtl.obj' ))
73+
74+ class TestZeroFaceNormaIndex (TestWavefront ):
75+ def setUp (self ):
76+ # reset the obj file to new file with no mtl line
77+ self .mesh_names = ['Simple' , 'SimpleB' ]
78+ self .material_names = ['Material.simple' , 'Material2.simple' ]
79+ self .meshes = pywavefront .Wavefront (prepend_dir ('simple_zero_indices.obj' ))
80+
81+ class TestExtraSpace (TestWavefront ):
82+ def setUp (self ):
83+ # reset the obj file to new file with no mtl line
84+ self .mesh_names = ['Simple' , 'SimpleB' ]
85+ self .material_names = ['Material.simple' , 'Material2.simple' ]
86+ self .meshes = pywavefront .Wavefront (prepend_dir ('simple_extra_empty_lines.obj' ))
You can’t perform that action at this time.
0 commit comments