I am having problems with my .obj file parser. Namely, the number of normals listed in the file is not equal to, nor is it a divisible by the number of vertices. The file looks like
# This file uses centimeters as units for non-parametric coordinates.
mtllib random.mtl
g default
v -3.130898 -2.031424 -4.913666
v -7.193745 -2.031424 -0.850819
v -3.130898 -2.031424 3.212028
v 0.931949 -2.031424 -0.850819
v -3.130898 2.031424 -0.850819
vt 0.500000 0.000000
vt 0.250000 0.250000
vt 0.500000 0.500000
vt 0.750000 0.250000
vt 0.250000 0.500000
vt 0.375000 0.500000
vt 0.500000 0.500000
vt 0.625000 0.500000
vt 0.750000 0.500000
vt 0.500000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn -0.577350 0.577350 -0.577350
vn -0.577350 0.577350 -0.577350
vn -0.577350 0.577350 -0.577350
vn -0.577350 0.577350 0.577350
vn -0.577350 0.577350 0.577350
vn -0.577350 0.577350 0.577350
vn 0.577350 0.577350 0.577350
vn 0.577350 0.577350 0.577350
vn 0.577350 0.577350 0.577350
vn 0.577350 0.577350 -0.577350
vn 0.577350 0.577350 -0.577350
vn 0.577350 0.577350 -0.577350
s off
g pPyramid1
usemtl initialShadingGroup
f 1/1/1 4/4/2 3/3/3 2/2/4
f 1/5/5 2/6/6 5/10/7
f 2/6/8 3/7/9 5/10/10
f 3/7/11 4/8/12 5/10/13
f 4/8/14 1/9/15 5/10/16
for a basic pyramid and
# This file uses centimeters as units for non-parametric coordinates.
mtllib 4sided.mtl
g default
v -7.497060 -0.000000 1.763534
v 5.051444 -0.000000 1.763534
v -7.497060 6.349456 1.763534
v 5.051444 6.349456 1.763534
v -7.497060 6.349456 -4.496893
v 5.051444 6.349456 -4.496893
v -7.497060 -0.000000 -4.496893
v 5.051444 -0.000000 -4.496893
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
s off
g pCube1
usemtl initialShadingGroup
f 1/1/1 2/2/2 4/4/3 3/3/4
f 3/3/5 4/4/6 6/6/7 5/5/8
f 5/5/9 6/6/10 8/8/11 7/7/12
f 7/7/13 8/8/14 2/10/15 1/9/16
f 2/2/17 8/11/18 6/12/19 4/4/20
f 7/13/21 1/1/22 3/3/23 5/14/24
for a basic block.
Note how the vertices have a number of normals equal to how many edges/faces connect to them, and yet all the normals are the same for each vertex. I cannot think of any simple way of reading these normals in. Unity wants one normal per vertex and that information is there, but once I read the first normal for that vertex how can i calculate how many to skip in order to get to the next one? Knowing how many edges connect to a vertex requires complex processing of the face information which I would rather not get into. While we are on the subject why does the file need so many identical normals listed anyway?