How to correct winding of triangles to counter-clockwise direction of a 3D Mesh model?

前端 未结 2 1008
无人及你
无人及你 2021-01-03 06:21

First of all let me clear .. I am not asking about 2D mesh, to determine the winding order of 2D mesh its very easy with normal-z direction.

Second is, I am not ask

2条回答
  •  北海茫月
    2021-01-03 06:46

    Does your mesh include edge adjacency information? i.e. each triangle T contains three vertices A,B,C and three edges AB, BC and CA, where AB is a link to the triangle T1 which shares common vertices A,B and includes a new vertex D. Something like

    struct Vertex 
    {
     double x,y,z;
    };
    
    struct Triangle
    {
       int vertices[3],edges[3];
    };
    
    
    struct TriangleMesh
    {
       Vertex Vertices[];
       Triangle Triangles[];
    };
    

    If this is the case, for any triangle T = {{VA,VB,VC},{TAB,TBC,TCA}} with neighbour TE = &TAB at edge AB, A and B must appear in the reverse order for T and TE to have the same winding. e.g. TAB = {{VB,VA,VD},{TBA,TAD,TDA}} where TBA = &T. This can be used to give all the triangles the same winding.

提交回复
热议问题