#include "stdio.h" #include "stdlib.h" #include "math.h" /* Crappy code to decode a sparce BMF file WARNING: minimal checking performed, left as an exercise to the reader to clean this up and support strip mesh types. */ typedef struct { float r,g,b,a; } RGBA; typedef struct { float u,v; float i,j,k; float x,y,z; } VERTEX; typedef struct { unsigned short int p0,p1,p2; } TRILIST; int main(int argc,char **argv) { int i,j; unsigned short nmat,mtype,namelength,nvert=0,ntri=0; FILE *fptr; char fname[256]; RGBA ambient,diffuse,specular; VERTEX *vlist; TRILIST *trilist; /* Should be 32 */ fprintf(stderr,"Size of float: %d\n",sizeof(float)); if ((fptr = fopen(argv[1],"r")) == NULL) { fprintf(stderr,"Open failed\n"); exit(-1); } /* Read the number of materials */ fread(&nmat,sizeof(unsigned short int),1,fptr); fprintf(stderr,"Number of materials: %d\n",nmat); /* Read the surface type */ fread(&mtype,sizeof(unsigned short int),1,fptr); fprintf(stderr,"Mesh type: %d\n",mtype); for (i=0;i