@@ -146,10 +146,26 @@ end
146
146
@test test_face_indices (msh)
147
147
148
148
msh = load (joinpath (tf, " cube.obj" )) # quads
149
+ @test msh isa MetaMesh
149
150
@test length (faces (msh)) == 12
150
151
@test length (coordinates (msh)) == 8
151
152
@test test_face_indices (msh)
152
153
154
+ @testset " OBJ meta and mtl data" begin
155
+ @test msh[:material_names ] == [" Material" ]
156
+ @test msh[:shading ] == BitVector ([0 ])
157
+ @test msh[:object ] == [" Cube" ]
158
+ @test length (msh[:materials ]) == 1
159
+ @test length (msh[:materials ][" Material" ]) == 7
160
+ @test msh[:materials ][" Material" ][" refractive index" ] === 1f0
161
+ @test msh[:materials ][" Material" ][" illumination model" ] === 2
162
+ @test msh[:materials ][" Material" ][" alpha" ] === 1f0
163
+ @test msh[:materials ][" Material" ][" diffuse" ] === Vec3f (0.64 , 0.64 , 0.64 )
164
+ @test msh[:materials ][" Material" ][" specular" ] === Vec3f (0.5 , 0.5 , 0.5 )
165
+ @test msh[:materials ][" Material" ][" shininess" ] === 96.07843f0
166
+ @test msh[:materials ][" Material" ][" ambient" ] === Vec3f (0.0 , 0.0 , 0.0 )
167
+ end
168
+
153
169
msh = load (joinpath (tf, " cube_uv.obj" ))
154
170
@test typeof (msh. uv) == Vector{Vec{2 ,Float32}}
155
171
@test length (msh. uv) == 8
166
182
msh = load (joinpath (tf, " test_face_normal.obj" ))
167
183
@test length (faces (msh)) == 1
168
184
@test length (coordinates (msh)) == 3
185
+ @test length (normals (msh)) == 3
169
186
@test test_face_indices (msh)
187
+ @test normals (msh) isa FaceView
188
+
189
+ # test correctness of reordered vertices
190
+ msh2 = expand_faceviews (Mesh (msh))
191
+ @test ! (normals (msh2) isa FaceView)
192
+ @test length (faces (msh2)) == 1
193
+ @test coordinates (coordinates (msh2)[faces (msh2)[1 ]]) == (Vec3f (0 ), Vec3f (0.062805 , 0.591207 , 0.902102 ), Vec3f (0.058382 , 0.577691 , 0.904429 ))
194
+ @test normals (msh2)[faces (msh2)[1 ]] == (Vec3f (0.9134 , 0.104 , 0.3934 ), Vec3f (0.8079 , 0.4428 , 0.3887 ), Vec3f (0.8943 , 0.4474 , 0.0 ))
195
+
196
+ # test that save works with FaceViews
197
+ mktempdir () do tmpdir
198
+ save (joinpath (tmpdir, " test.obj" ), msh)
199
+ msh1 = load (joinpath (tmpdir, " test.obj" ))
200
+ msh3 = expand_faceviews (Mesh (msh1)) # should be unnecessary atm
201
+ @test length (faces (msh2)) == length (faces (msh3))
202
+ for (f1, f2) in zip (faces (msh2), faces (msh3))
203
+ @test coordinates (msh2)[f1] == coordinates (msh3)[f2]
204
+ @test normals (msh2)[f1] == normals (msh3)[f2]
205
+ end
206
+ end
170
207
end
171
208
@testset " 2DM" begin
172
209
msh = load (joinpath (tf, " test.2dm" ))
0 commit comments