des bubulles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

importobj.c 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. LIBBUBULLES
  3. some functions for importing bubulles from dot-OBJ files.
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "bubulles.h"
  9. extern int verbosity;
  10. /* --------------------------------------------------------------------- */
  11. #define LINE_SZ 666
  12. int try_to_read_an_OBJ_file(char *fname, int notused)
  13. {
  14. FILE *fpin;
  15. char line[LINE_SZ+1], *cptr;
  16. float x, y, z;
  17. int foo;
  18. #if DEBUG_LEVEL
  19. fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
  20. #endif
  21. if (NULL==(fpin=fopen(fname, "r"))) {
  22. perror(fname);
  23. exit(1);
  24. }
  25. while(cptr=fgets(line, LINE_SZ, fpin)) {
  26. if (verbosity>1) fputs(line, stderr);
  27. cptr = strtok(line, " ");
  28. if (strcmp(cptr, "v")) continue;
  29. cptr = strtok(NULL, " ");
  30. foo = sscanf(cptr, "%f", &x);
  31. cptr = strtok(NULL, " ");
  32. foo = sscanf(cptr, "%f", &y);
  33. cptr = strtok(NULL, " ");
  34. foo = sscanf(cptr, "%f", &z);
  35. fprintf(stdout, "%16g %16g %16g\n", x, y, z);
  36. }
  37. fclose(fpin);
  38. return -7800;
  39. }
  40. /* --------------------------------------------------------------------- */