ulfben icon

normalize

ulfben | PRO | 02/26/21 10:57:45 PM UTC | 0 ⭐ | 2130 👁️ | Never ⏰ | []
C++ |

690 B

|

None

|

0 👍

/

0 👎

void Mesh_normalize( Mesh *myself )
{
    Vert     *vert = myself->vert;
    Triangle *face = myself->face;
 
    for( int i=0; i<myself->mNumVerts; i++ ) vert[i].normal = vec3(0.0f);
 
    for( int i=0; i<myself->mNumFaces; i++ )
    {
        const int ia = face[i].v[0];
        const int ib = face[i].v[1];
        const int ic = face[i].v[2];
 
        const vec3 e1 = vert[ia].pos - vert[ib].pos;
        const vec3 e2 = vert[ic].pos - vert[ib].pos;
        const vec3 no = cross( e1, e2 );
 
        vert[ia].normal += no;
        vert[ib].normal += no;
        vert[ic].normal += no;
    }
 
    for( i=0; i<myself->mNumVerts; i++ ) verts[i].normal = normalize( verts[i].normal );
}

Comments

  • Yuizcko icon
    05/18/26 12:57:18 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400