Skip to content

Commit

Permalink
Merge pull request #38 from rdeits/fix-obj-face-normal
Browse files Browse the repository at this point in the history
fix obj vertex//normal face format
  • Loading branch information
SimonDanisch committed Jan 23, 2018
2 parents e145c9f + 164594a commit 0179203
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/io/obj.jl
Expand Up @@ -34,10 +34,10 @@ function load{MT <: AbstractMesh}(io::Stream{format"OBJ"}, MeshType::Type{MT} =
error("Unknown UVW coordinate: $lines")
end
elseif "f" == command #mesh always has faces
if any(x->contains(x, "/"), lines)
fs = process_face_uv_or_normal(lines)
elseif any(x->contains(x, "//"), lines)
if any(x->contains(x, "//"), lines)
fs = process_face_normal(lines)
elseif any(x->contains(x, "/"), lines)
fs = process_face_uv_or_normal(lines)
else
push!(f, triangulated_faces(Tf, lines)...)
continue
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Expand Up @@ -122,6 +122,10 @@ const tf = joinpath(dirname(@__FILE__), "testfiles")
@test length(faces(msh)) == 4
@test length(vertices(msh)) == 6

msh = load(joinpath(tf, "test_face_normal.obj"))
@test length(faces(msh)) == 1
@test length(vertices(msh)) == 3

end
@testset "2DM" begin
msh = load(joinpath(tf, "test.2dm"))
Expand Down
8 changes: 8 additions & 0 deletions test/testfiles/test_face_normal.obj
@@ -0,0 +1,8 @@
v 0.000000 0.000000 0.000000
v 0.062805 0.591207 0.902102
v 0.058382 0.577691 0.904429
vn 0.913400 0.104000 0.393400
vn 0.807900 0.442800 0.388700
vn 0.894300 0.447400 0.000000
s 1
f 1//1 2//2 3//3

0 comments on commit 0179203

Please sign in to comment.