if(memcmp(line, "newmtl", 6) == 0) {
if(mtl) {
+ conv_mtl(mtl, &om, path_prefix);
mtl->next = scn->mtllist;
scn->mtllist = mtl;
}
- if((mtl = calloc(1, sizeof *mtl))) {
- if((line = cleanline(line + 6))) {
- mtl->name = strdup(line);
- }
+ mtl = calloc(1, sizeof *mtl);
+
+ memset(&om, 0, sizeof om);
+
+ if((line = cleanline(line + 6))) {
+ om.name = strdup(line);
}
+
} else if(memcmp(line, "Kd", 2) == 0) {
sscanf(line + 3, "%f %f %f", &om.kd.x, &om.kd.y, &om.kd.z);
} else if(memcmp(line, "Ks", 2) == 0) {
om.map_alpha = strdup(line);
}
}
- conv_mtl(mtl, &om, path_prefix);
}
if(mtl) {
+ conv_mtl(mtl, &om, path_prefix);
mtl->next = scn->mtllist;
scn->mtllist = mtl;
}
int len, prefix_len, maxlen = 0;
memset(mm, 0, sizeof *mm);
- mm->name = strdup(om->name);
+ mm->name = om->name;
mm->color = om->kd;
mm->spec = om->ks;
mm->shininess = om->shin;