问题
I have triangle collection that define mesh surface of my 3D shape, I would like to fix normal of each triangle to point outshape.
I was trying the following (pseudo):
1. define that first triangle normal direction is right direction
2. go over the mesh using kind of DFS like this:
3. triangle = first triangle
4. foreach neigbour in triangle.getNeighbours
5. if angle between neighbor and triangle greater then 180 do neighbor.flip()
6. triangle = neighbor
7. if neighbor already picked then continue to next neighbor
8. continue recursively to 4.
But step 5 in algorithm does not work because cant know if the angle is greater then 180, because i need to know in witch direction (clockwise or counter clockwise).
Could you please help me to understand how to fix the algorithm?
回答1:
There is no need to calculate angle between neighbours. If triangle ABC
is oriented (A->B->C
), and if neighbour on edge AB
is triangle ABD
, than it has to have opposite orientation on edge AB
. That means, neigbouring triangle has to be orientated B->A->D
.
来源:https://stackoverflow.com/questions/7216001/trying-to-fix-3d-mesh-normals