ref: 9651298a00411bcf60b1191676ce647756f149f4
parent: a256a597ea623ff8972fe332e7c9f352e9f36c20
author: gek <6974902+gordonfreeman424@users.noreply.github.com>
date: Sun Jul 24 19:21:05 EDT 2022
gitap from gek@Katherine.
--- a/include-demo/tobjparse.h
+++ b/include-demo/tobjparse.h
@@ -141,8 +141,6 @@
objraw retval = initobjraw();
if(f){
char line[2048];line[2047]=0;
- //int read = 0;
-
#define TOBJ_PUSH(type, vec, n, val){vec = realloc(vec, sizeof(type) * (n+1)); vec[n++] = val;}
while(fgets(line, 2047, f)){
vec3 val = {0};
@@ -152,70 +150,49 @@
if(line[0] == 'v' && line[1] == ' ' && (strlen(line) > 4)){
TOBJ_PUSH(vec3, retval.positions, retval.npos, val);
char* t = line+2;
- //sb_last(retval.positions).d[0] = atof(t);
retval.positions[retval.npos-1].d[0] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.positions).d[1] = atof(t);
retval.positions[retval.npos-1].d[1] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.positions).d[2] = atof(t);
retval.positions[retval.npos-1].d[2] = atof(t);
}
if(line[0] == 'v' && line[1] == 't' && (strlen(line) > 4)){
- //read = sscanf(line,"vt %f %f",&val.d[0],&val.d[1]);
- //sb_push(retval.texcoords, val);
TOBJ_PUSH(vec3, retval.texcoords, retval.ntexcoords, val);
char* t = line+3;
- //sb_last(retval.texcoords).d[0] = atof(t);
retval.texcoords[retval.ntexcoords-1].d[0] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.texcoords).d[1] = -atof(t);
retval.texcoords[retval.ntexcoords-1].d[1] = -atof(t);
-
}
if(line[0] == 'v' && line[1] == 'c' && (strlen(line) > 4)){
- //read=sscanf(line,"vc %f %f %f",&val.d[0],&val.d[1],&val.d[2]);
- //sb_push(retval.colors, val);
TOBJ_PUSH(vec3, retval.colors, retval.ncolors, val);
char* t = line+3;
- //sb_last(retval.colors).d[0] = atof(t);
retval.colors[retval.ncolors-1].d[0] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.colors).d[1] = atof(t);
retval.colors[retval.ncolors-1].d[1] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.colors).d[2] = atof(t);
retval.colors[retval.ncolors-1].d[2] = atof(t);
- //printf("\nvc Read: %d",read);
-
}
if(line[0] == 'v' && line[1] =='n' && (strlen(line) > 4)){
- //read=sscanf(line,"vn %f %f %f",&val.d[0],&val.d[1],&val.d[2]);
- //printf("\nn Read: %d",read);
- //sb_push(retval.normals, val);
TOBJ_PUSH(vec3, retval.normals, retval.nnorm, val);
char* t = line+3;
- //sb_last(retval.normals).d[0] = atof(t);
retval.normals[retval.nnorm-1].d[0] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.normals).d[1] = atof(t);
retval.normals[retval.nnorm-1].d[1] = atof(t);
while(!isspace(*t) && *t != '\0')t++;
if(*t == '\0')continue;
t++;
- //sb_last(retval.normals).d[2] = atof(t);
retval.normals[retval.nnorm-1].d[2] = atof(t);
}
if(line[0] == 'f' && (strlen(line) > 4)){