Skip to content

How to compute vertex normals?

Sk. Mohammadul Haque edited this page Apr 4, 2019 · 4 revisions

Open a mesh file, compute the vertex normals and save it in another mesh file.

#include <meshlib.h>

int main(int argc, char* argv[])
{
    MESH m;
    if(argc<3)
    {
        printf("input and output mesh filenames not given\n");
    }
    else
    {
        m = mesh_load_file(argv[1]);
        mesh_calc_vertex_normals(m);
        mesh_write_file(m, argv[2]);
        mesh_free_mesh(m);
    }
    return 0;
}