Trying to fix 3D mesh normals

有些话、适合烂在心里 提交于 2019-12-11 04:07:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!