Create an .obj parser capable of reading different formats
Closed this issue · 3 comments
A reference to the point, face and normal vector should be passed to the class/method. The parser should populate the vector with the data extracted from the obj file.
Can you share all formats?
Some of them are very simple, like this one:
# cubo.obj
# cubo representado por triangulos centrado na origem
# Linhas que iniciam com # sao comentarios
# Autor: Marcelo Walter
# Lista de vertices
v -0.5 0.5 0.5
v -0.5 -0.5 0.5
v 0.5 -0.5 0.5
v 0.5 0.5 0.5
v -0.5 0.5 -0.5
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
# Lista de faces
f 1 2 3
f 8 7 6
f 4 3 7
f 5 1 4
f 5 6 2
f 2 6 7
f 1 3 4
f 8 6 5
f 4 7 8
f 5 4 8
f 5 2 1
f 2 7 3
# fim do
v %f %f %f where %f represents a vertex coordinate
f %d %d %d where %d represents a index in the vertices array
There are normal definitions too, marked by an "vn" in the first part of the string.
Some of them are more complex, having structures like
f %d/%d/%d %d/%d/%d %d/%d/%d where the first %d represents the vertex index, the second %d represents the texture coordinate (not needed atm) and the third %d represents the normal index
More information about the structure can be found in http://rodrigo-silveira.com/opengl-tutorial-parsing-obj-file-blender/
Our Normal class has 3 axis attributes but a Normal (vn) input has only two