2020-06-05 09:17:17 +11:00
|
|
|
/*
|
|
|
|
LIBBUBULLES
|
|
|
|
|
|
|
|
some functions for importing bubulles from dot-OBJ files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "bubulles.h"
|
|
|
|
|
2020-06-05 10:05:01 +11:00
|
|
|
extern int verbosity;
|
|
|
|
|
2020-06-05 09:17:17 +11:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2020-06-05 10:05:01 +11:00
|
|
|
#define LINE_SZ 666
|
|
|
|
|
2020-06-05 09:17:17 +11:00
|
|
|
int try_to_read_an_OBJ_file(char *fname, int notused)
|
|
|
|
{
|
|
|
|
FILE *fpin;
|
2020-06-05 10:05:01 +11:00
|
|
|
char line[LINE_SZ+1], *cptr;
|
|
|
|
float x, y, z;
|
|
|
|
int foo;
|
2020-06-05 09:17:17 +11:00
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
2020-06-05 10:05:01 +11:00
|
|
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
2020-06-05 09:17:17 +11:00
|
|
|
#endif
|
|
|
|
|
2020-06-05 10:05:01 +11:00
|
|
|
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);
|
|
|
|
|
2020-06-05 09:17:17 +11:00
|
|
|
return -7800;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|