0

I am facing some strange problem with a simple obj-file I created. The obj-file contains 8 vertices which represent the corners of a cuboid-like shape. For each of the vertices I calculate a vertex normal (which I need for rendering). The object contains 12 triangle faces which are defined by the references to the vertices and normals. The order of the vertices to define a face seems to make a difference to the normal orientation of faces. E.g. the faces "f 2//2 1//1 3//3" and "f 1//1 2//2 3//3" might not have the same normal orientation. Can anyone tell me, how the vertices to define a triangular face should be ordered? I have not found information about this (only that vertices are ordered counter-clockwise by default, though Im not sure what "counter-clockwise" actually means in a 3D point cloud). I'm attaching a screenshot (used CloudCompare), which shows the obj with incorrect (top) and correct (bottom) face orientations. rendered output.

The .obj file code I've added below. Note: the second obj only differs in the face vertex order.

Any help is very much appreciated. Thank you!

Incorrect face orientation:

v 142.275 -164.684 -222.937
v 144.341 -156.611 -189.123
v 144.475 -189.798 -192.755
v 142.505 -195.249 -224.626
v 330.045 -162.613 -234.9
v 332.11 -154.539 -201.085
v 332.245 -187.727 -204.718
v 330.274 -193.177 -236.589

vn -0.988559636 0.113057396 -0.09983923
vn -0.949405612 0.193458398 0.247392061
vn -0.965486533 -0.148224101 0.214162018
vn -0.972490893 -0.202126966 -0.11578494
vn 0.965175897 0.134606199 -0.224313751
vn 0.96863934 0.214622417 0.125200028
vn 0.98787863 -0.126679515 0.089711275
vn 0.954142849 -0.180867505 -0.238533788

f 1//1 2//2 3//3
f 1//1 3//3 4//4
f 5//5 6//5 7//7
f 5//5 7//7 8//8
f 1//1 2//2 6//6
f 1//1 5//5 6//6
f 1//1 4//4 8//8
f 1//1 5//5 8//8
f 3//3 6//6 7//7 
f 2//2 3//3 6//6
f 3//3 8//8 7//7
f 3//3 4//4 8//8

Correct face orientation

v 142.275 -164.684 -222.937
v 144.341 -156.611 -189.123
v 144.475 -189.798 -192.755
v 142.505 -195.249 -224.626
v 330.045 -162.613 -234.9
v 332.11 -154.539 -201.085
v 332.245 -187.727 -204.718
v 330.274 -193.177 -236.589

vn -0.988559636 0.113057396 -0.09983923
vn -0.949405612 0.193458398 0.247392061
vn -0.965486533 -0.148224101 0.214162018
vn -0.972490893 -0.202126966 -0.11578494
vn 0.965175897 0.134606199 -0.224313751
vn 0.96863934 0.214622417 0.125200028
vn 0.98787863 -0.126679515 0.089711275
vn 0.954142849 -0.180867505 -0.238533788

f 2//2 1//1 3//3
f 3//3 1//1 4//4
f 5//5 6//6 7//7
f 5//5 7//7 8//8
f 1//1 2//2 6//6
f 5//5 1//1 6//6
f 4//4 1//1 8//8
f 1//1 5//5 8//8
f 6//6 3//3 7//7
f 2//2 3//3 6//6
f 3//3 8//8 7//7
f 3//3 4//4 8//8
Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
Concode
  • 1
  • 2
  • due to sequence changing, the direction of triangle amy become invisible from one direction, try from another direction.. rotate 180 degree, then zoom too much, and see through the object.. you should be able to find your answer now.. – Maifee Ul Asad Oct 07 '20 at 10:46
  • Thank you for trying to help me. Yes, I'm aware that the triangles are not visible from the current direction due to wrong orientation. I couldnt figure out yet the method to determine the correct order of the face vertices to write similar obj files correctly... – Concode Oct 12 '20 at 11:32
  • please try to add your code here, cause sof solves programming related question.. if you put your code here, let me know.. i'll try debugging... – Maifee Ul Asad Oct 12 '20 at 12:21

0 Answers0