/* * poly-sipp.c: * * [1999/07/21] OSHIRO Naoki. * * $Log:$ */ /* compile: cc -o poly-sipp poly-sipp.c -lsipp -lm */ static char rcsid[]="$Id:$"; #include #include #include #include #include extern char *optarg; int strncmp_cnt(char *str1, char *str2, int *n) { *n=strlen(str1); return strncmp(str1, str2, *n); } int main(int argc,char **argv) { FILE *fp; Surface *surface; Object *object; int size=100; int push_p; int n, nn; int x, y, z; float xf, yf, zf; char str[512]; int mode; int sample; int init_point; float xmin, xmax; float ymin, ymax; float zmin, zmax; float xc, yc, zc; int backface=TRUE; float red, grn, blu; float opred, opgrn, opblu; float ambient, specular, shiny; float op3; if (argc!=2) { fprintf(stderr, "poly-sipp polydata_file < command_str\n"); exit(1); } /**************************************************************/ /* sipp init */ sipp_init(); /* polygon data reading */ fp=fopen(argv[1], "r"); init_point=1; push_p=1; while (!feof(fp)) { if (fgets(str, 512, fp)==NULL) break; if (sscanf(str, "%f %f %f", &xf, &yf, &zf)<3) { if (push_p==0) polygon_push(); push_p=1; } else { vertex_push(xf, yf, zf); if (init_point==1) { xmin=xmax=xf; ymin=ymax=yf; zmin=zmax=zf; init_point=0; } else { if (xmin>xf) xmin=xf; if (xmaxyf) ymin=yf; if (ymaxzf) zmin=zf; if (zmax