Reputation: 963
I'm dynamically creating a 3D model and writing an .obj file. I'm having a problem with flipping the visible side of faces.
I've made a simple example:
v 0.0 0.0 0.0
v 0.0 1.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
vn 0.0 0.0 -1.0
f 1//1 4//1 3//1
f 1//1 2//1 4//1
The above is a square divided into two triangles. The vn
line is the face normal (the vector that is perpendicular to the face). I've read online that to flip the face, you can negate the normal vector. However if I multiply the normal vector by -1 and try the following...
v 0.0 0.0 0.0
v 0.0 1.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
vn 0.0 0.0 1.0
f 1//1 4//1 3//1
f 1//1 2//1 4//1
It doesn't actually flip the visible side of the face when I import it into Unity. The lighting changes a little bit, but the same side is still visible and the other side is still invisible.
When I orbit to the opposite side:
Upvotes: 0
Views: 736
Reputation: 4889
The normal only influences the lighting effect. To flip a face, you need to inverse the index order of the triangle like below.
f 3//1 4//1 1//1
f 4//1 2//1 1//1
Upvotes: 1