62 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
| 	          LIBBUBULLES
 | |
| 
 | |
| 	some functions for importing bubulles from dot-OBJ files.
 | |
| */
 | |
| 
 | |
| #include  <stdio.h>
 | |
| #include  <stdlib.h>
 | |
| #include  <string.h>
 | |
| 
 | |
| #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", __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;
 | |
| }
 | |
| 
 | |
| /* --------------------------------------------------------------------- */
 |