| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
+ |
#include "platform.h" |
| 10 |
|
#include "standard.h" |
| 11 |
|
#include "cvmesh.h" |
| 12 |
|
#include "otypes.h" |
| 32 |
|
int argc; |
| 33 |
|
char *argv[]; |
| 34 |
|
{ |
| 35 |
< |
int i; |
| 35 |
> |
int nmatf = 0; |
| 36 |
> |
char *matinp[32]; |
| 37 |
> |
int i, j; |
| 38 |
|
|
| 39 |
|
progname = argv[0]; |
| 40 |
|
ofun[OBJ_FACE].funp = o_face; |
| 47 |
|
case 'r': /* resolution limit */ |
| 48 |
|
resolu = atoi(argv[++i]); |
| 49 |
|
break; |
| 50 |
+ |
case 'a': /* material file */ |
| 51 |
+ |
matinp[nmatf++] = argv[++i]; |
| 52 |
+ |
break; |
| 53 |
|
case 'w': /* supress warnings */ |
| 54 |
|
nowarn = 1; |
| 55 |
|
break; |
| 60 |
|
} |
| 61 |
|
/* initialize mesh */ |
| 62 |
|
cvinit(i==argc-2 ? argv[i+1] : "<stdout>"); |
| 63 |
< |
|
| 64 |
< |
if (i == argc) /* read .OBJ file into triangles */ |
| 63 |
> |
/* load material input */ |
| 64 |
> |
for (j = 0; j < nmatf; j++) |
| 65 |
> |
readobj(matinp[j]); |
| 66 |
> |
/* read .OBJ file into triangles */ |
| 67 |
> |
if (i == argc) |
| 68 |
|
wfreadobj(NULL); |
| 69 |
|
else |
| 70 |
|
wfreadobj(argv[i]); |
| 74 |
|
if (i == argc-2) /* open output file */ |
| 75 |
|
if (freopen(argv[i+1], "w", stdout) == NULL) |
| 76 |
|
error(SYSTEM, "cannot open output file"); |
| 77 |
< |
#ifdef MSDOS |
| 69 |
< |
setmode(fileno(stdout), O_BINARY); |
| 70 |
< |
#endif |
| 77 |
> |
SET_FILE_BINARY(stdout); |
| 78 |
|
newheader("RADIANCE", stdout); /* new binary file header */ |
| 79 |
|
printargs(i<argc ? i+1 : argc, argv, stdout); |
| 80 |
|
fputformat(MESHFMT, stdout); |
| 83 |
|
mincusize = ourmesh->mcube.cusize / resolu - FTINY; |
| 84 |
|
|
| 85 |
|
for (i = 0; i < nobjects; i++) /* add triangles to octree */ |
| 86 |
< |
addface(&ourmesh->mcube, i); |
| 86 |
> |
if (objptr(i)->otype == OBJ_FACE) |
| 87 |
> |
addface(&ourmesh->mcube, i); |
| 88 |
|
|
| 89 |
|
/* optimize octree */ |
| 90 |
|
ourmesh->mcube.cutree = combine(ourmesh->mcube.cutree); |
| 96 |
|
|
| 97 |
|
writemesh(ourmesh, stdout); /* write mesh to output */ |
| 98 |
|
|
| 99 |
< |
printmeshstats(ourmesh, stderr); |
| 99 |
> |
/* printmeshstats(ourmesh, stderr); */ |
| 100 |
|
|
| 101 |
|
quit(0); |
| 102 |
|
} |