point-cloud-utils
point-cloud-utils copied to clipboard
Incorrect vertex normals when loading obj file
I'm trying to load a very simple obj file:
o Plane
v 0.000000 0.000000 0.000000
v 0.353553 0.353553 0.000000
v 0.353553 -0.353553 0.000000
vn -0.0000 -0.0000 1.0000
vt 0.500000 0.250000
vt 0.500000 0.500000
vt 0.250000 0.500000
s 0
f 2/1/1 1/2/1 3/3/1
When I load the vertex normals using the function load_mesh_vn, I get normals that look like:
[[0 0 1]
[0 0 0]
[0 0 0]]
when I would expect something like this instead:
[[0 0 1]
[0 0 1]
[0 0 1]]
With a slightly more complex obj file:
o Plane
v 0.000000 0.000000 0.000000
v 0.353553 0.353553 0.000000
v 0.353553 -0.353553 0.000000
v 0.000000 -0.707107 -0.000000
v -0.000000 0.707107 0.000000
vn -0.0000 -0.0000 1.0000
vt 0.500000 0.500000
vt 0.250000 0.750000
vt 0.250000 0.500000
vt 0.500000 0.250000
vt 0.750000 0.250000
s 0
f 1/1/1 4/2/1 3/3/1
f 2/4/1 1/1/1 3/3/1
f 5/5/1 1/1/1 2/4/1
I've noticed that sometimes I'll get a nan in the normal matrix,
[[-0.00000000e+00 -0.00000000e+00 1.00000000e+00]
[ 0.00000000e+00 4.48415509e-44 0.00000000e+00]
[ 8.53390765e-43 0.00000000e+00 2.80259693e-45]
[ 0.00000000e+00 -1.03065395e+09 4.02691140e-41]
[ 7.60905066e-43 0.00000000e+00 nan]]