60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
/*
|
|
LIBBUBULLES IMPORT_OBJ
|
|
some functions for importing bubulles from dot-OBJ files.
|
|
|
|
https://git.tetalab.org/tTh/libbubulle/src/branch/master/tools/
|
|
http://fegemo.github.io/cefet-cg/attachments/obj-spec.pdf
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include "../bubulles.h"
|
|
#include "../edges.h"
|
|
|
|
#include "objtrucs.h"
|
|
|
|
extern int verbosity;
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
/* EXPERIMENTAL GRUIK-CODE !!! */
|
|
int x_write_vertedges(char *filename, BBList *bblist, EdgeList *edges)
|
|
{
|
|
FILE *fp;
|
|
int idx, edg[2];
|
|
double coo[3];
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__, filename,
|
|
bblist, edges);
|
|
|
|
if (NULL==(fp=fopen(filename, "w"))) {
|
|
perror(filename);
|
|
return -4;
|
|
}
|
|
|
|
print_bublist_desc(bblist, 0);
|
|
fwrite("VERTICES", 8, 1, fp);
|
|
for (idx=0; idx<bblist->fidx; idx++) {
|
|
fprintf(stderr, "vertice %d\n", idx);
|
|
coo[0] = bblist->bbs[idx].p.x;
|
|
coo[1] = bblist->bbs[idx].p.y;
|
|
coo[2] = bblist->bbs[idx].p.z;
|
|
fwrite(coo, sizeof(coo), 1, fp);
|
|
}
|
|
|
|
print_edgelist_desc(edges, 0);
|
|
fwrite("EDGES ", 8, 1, fp);
|
|
for (idx=0; idx<edges->fidx; idx++) {
|
|
edg[0] = edges->edges[idx].A;
|
|
edg[1] = edges->edges[idx].B;
|
|
fwrite(edg, sizeof(edg), 1, fp);
|
|
}
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|