29 |
|
* It is not necessary for the normal vectors to have unit length. |
30 |
|
*/ |
31 |
|
|
32 |
< |
#include "standard.h" |
32 |
> |
#include <stdlib.h> |
33 |
> |
#include <stdio.h> |
34 |
|
|
35 |
+ |
#include "rtmath.h" |
36 |
+ |
|
37 |
|
#include "tmesh.h" |
38 |
|
|
39 |
|
#define VOIDID "void" /* this is defined in object.h */ |
55 |
|
VERTEX *vlist = NULL; /* our vertex list */ |
56 |
|
int nverts = 0; /* number of vertices in our list */ |
57 |
|
|
58 |
< |
#define novert(i) ((i)<0|(i)>=nverts || !(vlist[i].flags&V_DEFINED)) |
58 |
> |
#define novert(i) (((i)<0)|((i)>=nverts) || !(vlist[i].flags&V_DEFINED)) |
59 |
|
|
60 |
|
#define CHUNKSIZ 128 /* vertex allocation chunk size */ |
61 |
|
|
65 |
|
char *defpat = ""; /* default (starting) picture name */ |
66 |
|
char *defobj = "T"; /* default (starting) object name */ |
67 |
|
|
68 |
+ |
void convert(char *fname, FILE *fp); |
69 |
+ |
void triangle(char *pn,char *mod,char *obj, VERTEX *v1,VERTEX *v2,VERTEX *v3); |
70 |
+ |
VERTEX *vnew(int id, double x, double y, double z); |
71 |
+ |
void syntax(char *fn, FILE *fp, char *er); |
72 |
|
|
73 |
< |
main(argc, argv) /* read in T-mesh files and convert */ |
74 |
< |
int argc; |
75 |
< |
char *argv[]; |
73 |
> |
|
74 |
> |
int |
75 |
> |
main( /* read in T-mesh files and convert */ |
76 |
> |
int argc, |
77 |
> |
char *argv[] |
78 |
> |
) |
79 |
|
{ |
80 |
|
FILE *fp; |
81 |
|
int i; |
93 |
|
break; |
94 |
|
default: |
95 |
|
fprintf(stderr, |
96 |
< |
"Usage: %s [-o obj][-m mat][-p pic] [file ..]\n", |
96 |
> |
"Usage: %s [-o obj][-m mat][-p hdr] [file ..]\n", |
97 |
|
argv[0]); |
98 |
|
exit(1); |
99 |
|
} |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
< |
convert(fname, fp) /* convert a T-mesh */ |
116 |
< |
char *fname; |
117 |
< |
FILE *fp; |
115 |
> |
void |
116 |
> |
convert( /* convert a T-mesh */ |
117 |
> |
char *fname, |
118 |
> |
FILE *fp |
119 |
> |
) |
120 |
|
{ |
121 |
|
char typ[4]; |
122 |
|
int id[3]; |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
< |
triangle(pn, mod, obj, v1, v2, v3) /* put out a triangle */ |
211 |
< |
char *pn, *mod, *obj; |
212 |
< |
register VERTEX *v1, *v2, *v3; |
210 |
> |
void |
211 |
> |
triangle( /* put out a triangle */ |
212 |
> |
char *pn, |
213 |
> |
char *mod, |
214 |
> |
char *obj, |
215 |
> |
register VERTEX *v1, |
216 |
> |
register VERTEX *v2, |
217 |
> |
register VERTEX *v3 |
218 |
> |
) |
219 |
|
{ |
220 |
|
static char vfmt[] = "%18.12g %18.12g %18.12g\n"; |
221 |
|
static int ntri = 0; |
276 |
|
|
277 |
|
|
278 |
|
VERTEX * |
279 |
< |
vnew(id, x, y, z) /* create a new vertex */ |
280 |
< |
register int id; |
281 |
< |
double x, y, z; |
279 |
> |
vnew( /* create a new vertex */ |
280 |
> |
register int id, |
281 |
> |
double x, |
282 |
> |
double y, |
283 |
> |
double z |
284 |
> |
) |
285 |
|
{ |
286 |
|
register int i; |
287 |
|
|
311 |
|
} |
312 |
|
|
313 |
|
|
314 |
< |
syntax(fn, fp, er) /* report syntax error and exit */ |
315 |
< |
char *fn; |
316 |
< |
register FILE *fp; |
317 |
< |
char *er; |
314 |
> |
void |
315 |
> |
syntax( /* report syntax error and exit */ |
316 |
> |
char *fn, |
317 |
> |
register FILE *fp, |
318 |
> |
char *er |
319 |
> |
) |
320 |
|
{ |
321 |
|
extern long ftell(); |
322 |
|
register long cpos; |