Reputation: 596
I want to be able to load OBJ files, including the vertex normal. But I quickly encountered a problem where Blender gives me 1 normal per face, and I don't understand how I can link that to my vertices.
Here's the obj file:
# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
o Cube
v 1.000000 -1.000000 -0.555273
v 1.000000 -1.000000 1.444727
v -1.000000 -1.000000 1.444726
v -1.000000 -1.000000 -0.555274
v 1.000000 1.000000 -0.555273
v 0.999999 1.000000 1.444727
v -1.000000 1.000000 1.444726
v -1.000000 1.000000 -0.555273
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
s off
f 1//1 3//1 4//1
f 8//2 6//2 5//2
f 5//3 2//3 1//3
f 6//4 3//4 2//4
f 3//5 8//5 4//5
f 1//6 8//6 5//6
f 1//1 2//1 3//1
f 8//2 7//2 6//2
f 5//3 6//3 2//3
f 6//4 7//4 3//4
f 3//5 7//5 8//5
f 1//6 4//6 8//6
And the parameters The paramters to export to OBJ
Si Have a cube with 6 faces, 8 vertices, and 12 triangles and 6 vertex normal. How do I make the link between vertex and face. I thought it would be more straightforward with one VN per vertex. And in the examples I saw online it was.
But here I need to figure out how to make the link between the two, so I guess I'll have to duplicate the vertices two since for each face the normal will be different.
EDIT: Solved, I misunderstood the way a polygon was written Each couple, is a couple of vertex pos/vertex normal
Upvotes: 1
Views: 2010
Reputation: 596
Solved, I misunderstood the way a polygon was written Each couple, is a couple of vertex pos//vertex normal.
To build my model, I need to make new vertices when the same vertex has different normals to be able to send it to openGL properly.
Because in openGL one vertex has one normal, but not in a obj file. So it is up to me to adapt the OBJ file to my data model.
Upvotes: 1