- if(cmesh_push_attrib(mesh, CMESH_ATTR_COLOR, &vptr->r) == -1) {
- fprintf(stderr, "load_mesh: failed to resize color array\n");
- goto err;
+ if(found_color) {
+ if(cmesh_push_attrib(mesh, CMESH_ATTR_COLOR, &vptr->r) == -1) {
+ fprintf(stderr, "load_mesh: failed to resize color array\n");
+ goto err;
+ }
+ }
+ if(fv.nidx >= 0) {
+ float nx = narr[fv.nidx].x;
+ float ny = narr[fv.nidx].y;
+ float nz = narr[fv.nidx].z;
+ if(cmesh_push_attrib3f(mesh, CMESH_ATTR_NORMAL, nx, ny, nz) == -1) {
+ fprintf(stderr, "load_mesh: failed to resize normal array\n");
+ goto err;
+ }