--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cmesh.h"
+
+int main(int argc, char **argv)
+{
+ int i;
+ struct cmesh *cm;
+
+ for(i=1; i<argc; i++) {
+ if(!(cm = cmesh_alloc())) {
+ perror("failed to allocate mesh");
+ return 1;
+ }
+ if(cmesh_load(cm, argv[i]) == -1) {
+ fprintf(stderr, "failed to load: %s\n", argv[i]);
+ return 1;
+ }
+
+ dump(cm);
+
+ cmesh_free(cm);
+ }
+ return 0;
+}
+
+int dump(struct cmesh *cm)
+{
+ int i, nverts, nidx, voffs;
+ const float *varr, *narr;
+ const unsigned int *iarr;
+
+ varr = cmesh_attrib_ro(cm, CMESH_ATTR_VERTEX);
+ narr = cmesh_attrib_ro(cm, CMESH_ATTR_NORMAL);
+ iarr = cmesh_index_ro(cm);
+ nverts = cmesh_attrib_count(cm, CMESH_ATTR_VERTEX);
+ nidx = cmesh_index_count(cm);
+
+ printf("static struct xvertex mesh[] = {\n");
+ for(i=0; i<nidx; i++) {
+ voffs = iarr[i] * 3;
+ printf("\t{%d, %d, %d,", (int)(varr[voffs] * 65536.0f),
+ (int)(varr[voffs + 1] * 65536.0f), (int)(varr[voffs + 2] * 65536.0f));
+ printf("\t%d, %d, %d,", (int)(narr[voffs] * 65536.0f),
+ (int)(narr[voffs + 1] * 65536.0f), (int)(narr[voffs + 2] * 65536.0f));
+ printf("\t0xff}%c\n", i < nidx - 1 ? ',' : '\n');
+ }
+ printf("};\n");
+
+ return 0;
+}