0

I am trying to understand how to manually generate objects.

I have a mesh, part of which I delete and create a new geometry in its place. I have information about the normals of deleted vertices. On the basis of which I have to build new faces (in a different size and quantity) looking in the same direction.

But I don’t understand how to choose the correct winding. It sounds easy when the lessons talk about CCW winding in screen space. But what if I have a bunch of almost chaotic points in the model space? How then to determine this CCW, which axis is used for this? I suggest that the nearest old normals might help. But what is the cheapest method to determine the correct order?

genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

2

It turned out to be easier than I thought. It is necessary to find the cross product of the first two vectors from the vertices of a triangle, then find the dot of the resulting vector and the normal vector, if the result is negative, then during generation it is necessary to change the order of vertices.

  • 1
    that will work 99% of the time but if your new mesh part is too concave then it would break. What is usually done is having point inside your mesh and instead of dot product with original normal you dot product with vector created by `face_vertex - inside_point`. see [Determing the direction of face normals consistently?](https://stackoverflow.com/a/57440487/2521214) – Spektre May 28 '20 at 07:20