Faces front and back

I’m writing an exporter based on the skp2xml sample.
I got all meshes working but are having problems with the materials.
It seems that SUFaceGetFrontMaterial (and back) can’t be trusted in all cases. Meaning that not all triangles will have the correct material on it’s front and back side. Sometimes they are the other way around.
I treat all triangles as FRONT when they follow the winding order set in the vertex indices.

My guess is that this has something to do with mirrored mesh. I’ve tried comparing the face normal with a normal I calculate myself from the triangle but they are all the same.
I could check the transform for a -1 scale in any axis, but I really don’t understand how I could use that knowledge to tell the face front side. Sure if the face normal was 1 in that axis, I could just reverse the order but an arbitrary normal?

EDIT.
I have realized the problem is much simpler, it’s the face orientation that is inconsistent. Some faces are drawn backwards (that’s why I see the backside material). I use SUMeshHelperGetVertexIndices, is that a more reliable way?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.