6 int main(int argc, char **argv)
11 for(i=1; i<argc; i++) {
12 if(!(cm = cmesh_alloc())) {
13 perror("failed to allocate mesh");
16 if(cmesh_load(cm, argv[i]) == -1) {
17 fprintf(stderr, "failed to load: %s\n", argv[i]);
28 int dump(struct cmesh *cm)
30 int i, nverts, nidx, voffs;
31 const float *varr, *narr;
32 const unsigned int *iarr;
34 varr = cmesh_attrib_ro(cm, CMESH_ATTR_VERTEX);
35 narr = cmesh_attrib_ro(cm, CMESH_ATTR_NORMAL);
36 iarr = cmesh_index_ro(cm);
37 nverts = cmesh_attrib_count(cm, CMESH_ATTR_VERTEX);
38 nidx = cmesh_index_count(cm);
40 printf("static struct xvertex mesh[] = {\n");
41 for(i=0; i<nidx; i++) {
43 printf("\t{%d, %d, %d,", (int)(varr[voffs] * 65536.0f),
44 (int)(varr[voffs + 1] * 65536.0f), (int)(varr[voffs + 2] * 65536.0f));
45 printf("\t%d, %d, %d,", (int)(narr[voffs] * 65536.0f),
46 (int)(narr[voffs + 1] * 65536.0f), (int)(narr[voffs + 2] * 65536.0f));
47 printf("\t0xff}%c\n", i < nidx - 1 ? ',' : '\n');