I am trying to understand how to create my own TriMeshes. For testing purposes I am creating one that consists of just a few connected triangles. And for some reason, neither the NormalsGenerator, nor my own custom algorithm produce desirable results. Let's suppose I have a vertex which is part of three triangles, which are nearly planar lying on the xy surface (that is, their other vertices have varying, but near 0 z-values). Basically like the center of a circle.
Yet, when I apply NormalsGenerator on it, some triangles will have their normals of the vertex in the center point up- and some downwards. Okay, I thought, and I wrote my own normalsGenerator, which simply averages the normals of the vertex based on all the triangles around that vertex. But the same happens. Perhaps I am getting it all wrong with how the normals are stored in relation to vertices?
I assume that if a vertex A is stored at ith position in the vertex buffer, that I also have to store it's normal at the ith position in the normals buffer. Is that wrong? Do I somehow have to relate to the indexbuffer?
Or is the order of the vertices of the triangles (in the indicesbuffer) somehow relevant?