Face normals and vertex normals are flipped

I’m doing a generative geometry setting vertex position and vertex normals.
It works correctly, as you see when I open the generated mesh with mesh lab and the light is correctly calculated, if the selected view is the vertex view.

When I select the faces view, the normals are flipped, they are pointing inside the tube

As this tube is an instance of of3DPrimitive, i can use drawNormals to debug them.
But in both cases, when drawing the normals per vertex:

tube.drawNormals(2, false);

Or when drawing the normals per face

tube.drawNormals(2, true);

The normals are always pointing out in the right direction, from inside the tube to outside, it is just in meshlab that they look wrong in the “faces” view.

I think it is a problem in my code because I’ve downloaded a couple of meshes and I’ve opened them in meshlab, and they look good
Is there something that I’m not taking into consideration?

Hi Davide! Do you have a minimal code example that shows this behavior?

Hello Abe, it is an addon, this is a simple example with a “save mesh” option.


The mesh looks correct in OF but wrong in mesh lab.

This is the method that generate the cylinder mesh

This is the part where I’m adding the vertices in the mesh, as you see I’m adding the normals as supposed


and this is working, just face normals are wrong.

could this be left hand vs right hand coordinate system issue?

https://www.evl.uic.edu/ralph/508S98/coordinates.html

yes this is probably related to the winding of the polygons, usually you should create the faces in counter clockwise order

Ok, I will have a look in this direction and let you know. Thanks!

I can confirm, i was adding the indexes in the mesh in clockwise order, thank you guys for the support :wink: