read .OBJ file, second step

This commit is contained in:
tonton th 2020-06-05 01:05:01 +02:00
parent 5a6e98d034
commit 0b5dd38b58
4 changed files with 43 additions and 3 deletions

1
.gitignore vendored
View File

@ -8,4 +8,5 @@ dummy-file
tools/covid-19.obj
tools/read_obj
tools/xyz

View File

@ -10,16 +10,51 @@
#include "bubulles.h"
extern int verbosity;
/* --------------------------------------------------------------------- */
#define LINE_SZ 666
int try_to_read_an_OBJ_file(char *fname, int notused)
{
FILE *fpin;
char line[LINE_SZ+1], *cptr;
float x, y, z;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d)\n", fname, notused);
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
#endif
if (NULL==(fpin=fopen(fname, "r"))) {
perror(fname);
exit(1);
}
while(cptr=fgets(line, LINE_SZ, fpin)) {
if (verbosity>1) fputs(line, stderr);
cptr = strtok(line, " ");
if (strcmp(cptr, "v")) continue;
cptr = strtok(NULL, " ");
foo = sscanf(cptr, "%f", &x);
cptr = strtok(NULL, " ");
foo = sscanf(cptr, "%f", &y);
cptr = strtok(NULL, " ");
foo = sscanf(cptr, "%f", &z);
fprintf(stdout, "%16g %16g %16g\n", x, y, z);
}
fclose(fpin);
return -7800;
}

View File

@ -2,4 +2,4 @@
BBFUNCS = ../libbubulles.a
read_obj: read_obj.c Makefile ${BBFUNCS}
gcc -Wall $< ${BBFUNCS} -o $@
gcc -Wall -DDEBUG_LEVEL=1 $< ${BBFUNCS} -o $@

View File

@ -6,6 +6,9 @@
#include <stdlib.h>
#include "../bubulles.h"
int try_to_read_an_OBJ_file(char *fname, int notused);
int verbosity;
int main(int argc, char *argv[])
{
int foo;
@ -15,8 +18,9 @@ if (2 != argc) {
exit(0);
}
verbosity = 0;
// foo = try_to_read_an_OBJ_file(argv[1], 0);
foo = try_to_read_an_OBJ_file(argv[1], 0);