试图修复3D网格法线 [英] Trying to fix 3D mesh normals
问题描述
我有三角形集合,它定义了我的3D形状的网格表面,
我想修正每个三角形的正常指向形状。
我是尝试以下(伪):
1.定义第一个三角形的法线方向是正确的方向
2.使用网格类似这样的DFS:
3. triangle = first triangle
4. foreach neighbours in triangle.getNeighbours
5.如果邻居和三角形之间的角度更大然后180做neighbor.flip()
6. triangle = neighbor
7.如果邻居已经选择了然后继续到下一个邻居
8.继续递归到4,
但算法中的第5步不起作用,因为不知道角度是否大于180,因为我需要知道女巫方向(顺时针还是逆时针) 。
你能帮我理解如何修正这个算法吗?
有n o需要计算邻居之间的角度。如果三角形 ABC
是面向的( A-> B-> C
),并且边缘 AB
是三角形 ABD
,它必须在边 B->> A-> D
。
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?
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
.
这篇关于试图修复3D网格法线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!