1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* Replace markers in Radiance scene description with objects or instances. |
7 |
|
* Created: 17 Feb 1991 Greg Ward |
8 |
|
*/ |
9 |
|
|
10 |
– |
#include <stdio.h> |
10 |
|
#include <stdlib.h> |
11 |
|
#include <ctype.h> |
12 |
|
#include <math.h> |
13 |
+ |
#include <stdio.h> |
14 |
|
|
15 |
+ |
#include "platform.h" |
16 |
+ |
#include "rtio.h" |
17 |
+ |
#include "rtprocess.h" |
18 |
|
#include "fvect.h" |
19 |
|
|
20 |
|
#ifdef M_PI |
46 |
|
|
47 |
|
char *progname; |
48 |
|
|
49 |
+ |
static void convert(char *name, FILE *fin); |
50 |
+ |
static void cvcomm(char *fname, FILE *fin); |
51 |
+ |
static void cvobject(char *fname, FILE *fin); |
52 |
+ |
static void replace(char *fname, struct mrkr *m, char *mark, FILE *fin); |
53 |
+ |
static int edgecmp(const void *e1, const void *e2); |
54 |
+ |
static int buildxf(char *xf, double markscale, FILE *fin); |
55 |
+ |
static int addrot(char *xf, FVECT xp, FVECT yp, FVECT zp); |
56 |
|
|
57 |
< |
main(argc, argv) |
58 |
< |
int argc; |
59 |
< |
char *argv[]; |
57 |
> |
|
58 |
> |
int |
59 |
> |
main( |
60 |
> |
int argc, |
61 |
> |
char *argv[] |
62 |
> |
) |
63 |
|
{ |
64 |
|
FILE *fp; |
65 |
|
int i, j; |
119 |
|
convert(argv[i], fp); |
120 |
|
fclose(fp); |
121 |
|
} |
122 |
< |
exit(0); |
122 |
> |
return 0; |
123 |
|
userr: |
124 |
|
fprintf(stderr, |
125 |
|
"Usage: %s [-e][-s size][-m modout] {-x objfile|-i octree} modname .. [file ..]\n", |
126 |
|
progname); |
127 |
< |
exit(1); |
127 |
> |
return 1; |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
< |
convert(name, fin) /* replace marks in a stream */ |
132 |
< |
char *name; |
133 |
< |
register FILE *fin; |
131 |
> |
void |
132 |
> |
convert( /* replace marks in a stream */ |
133 |
> |
char *name, |
134 |
> |
register FILE *fin |
135 |
> |
) |
136 |
|
{ |
137 |
|
register int c; |
138 |
|
|
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
< |
cvcomm(fname, fin) /* convert a command */ |
161 |
< |
char *fname; |
162 |
< |
FILE *fin; |
160 |
> |
void |
161 |
> |
cvcomm( /* convert a command */ |
162 |
> |
char *fname, |
163 |
> |
FILE *fin |
164 |
> |
) |
165 |
|
{ |
166 |
< |
FILE *pin, *popen(); |
166 |
> |
FILE *pin; |
167 |
|
char buf[512], *fgetline(); |
168 |
|
|
169 |
|
fgetline(buf, sizeof(buf), fin); |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
< |
cvobject(fname, fin) /* convert an object */ |
185 |
< |
char *fname; |
186 |
< |
FILE *fin; |
184 |
> |
void |
185 |
> |
cvobject( /* convert an object */ |
186 |
> |
char *fname, |
187 |
> |
FILE *fin |
188 |
> |
) |
189 |
|
{ |
190 |
+ |
extern char *fgetword(); |
191 |
|
char buf[128], typ[16], nam[128]; |
192 |
|
int i, n; |
193 |
|
register int j; |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
< |
replace(fname, m, mark, fin) /* replace marker */ |
232 |
< |
char *fname; |
233 |
< |
register struct mrkr *m; |
234 |
< |
char *mark; |
235 |
< |
FILE *fin; |
231 |
> |
void |
232 |
> |
replace( /* replace marker */ |
233 |
> |
char *fname, |
234 |
> |
register struct mrkr *m, |
235 |
> |
char *mark, |
236 |
> |
FILE *fin |
237 |
> |
) |
238 |
|
{ |
239 |
|
int n; |
240 |
|
char buf[256]; |
241 |
|
|
242 |
|
buf[0] = '\0'; /* bug fix thanks to schorsch */ |
243 |
|
if (m->doxform) { |
244 |
< |
sprintf(buf, "xform -e -n %s", mark); |
244 |
> |
sprintf(buf, "xform -n %s", mark); |
245 |
|
if (m->modout != NULL) |
246 |
|
sprintf(buf+strlen(buf), " -m %s", m->modout); |
247 |
|
if (buildxf(buf+strlen(buf), m->mscale, fin) < 0) |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
< |
edgecmp(e1, e2) /* compare two edges, descending order */ |
271 |
< |
EDGE *e1, *e2; |
270 |
> |
int |
271 |
> |
edgecmp( /* compare two edges, descending order */ |
272 |
> |
const void *e1, |
273 |
> |
const void *e2 |
274 |
> |
) |
275 |
|
{ |
276 |
< |
if (e1->len2 > e2->len2) |
276 |
> |
if (((EDGE*)e1)->len2 > ((EDGE*)e2)->len2) |
277 |
|
return(-1); |
278 |
< |
if (e1->len2 < e2->len2) |
278 |
> |
if (((EDGE*)e1)->len2 < ((EDGE*)e2)->len2) |
279 |
|
return(1); |
280 |
|
return(0); |
281 |
|
} |
282 |
|
|
283 |
|
|
284 |
|
int |
285 |
< |
buildxf(xf, markscale, fin) /* build transform for marker */ |
286 |
< |
register char *xf; |
287 |
< |
double markscale; |
288 |
< |
FILE *fin; |
285 |
> |
buildxf( /* build transform for marker */ |
286 |
> |
register char *xf, |
287 |
> |
double markscale, |
288 |
> |
FILE *fin |
289 |
> |
) |
290 |
|
{ |
291 |
|
static FVECT vlist[MAXVERT]; |
292 |
|
static EDGE elist[MAXVERT]; |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
< |
addrot(xf, xp, yp, zp) /* compute rotation (x,y,z) => (xp,yp,zp) */ |
368 |
< |
register char *xf; |
369 |
< |
FVECT xp, yp, zp; |
367 |
> |
int |
368 |
> |
addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ |
369 |
> |
register char *xf, |
370 |
> |
FVECT xp, |
371 |
> |
FVECT yp, |
372 |
> |
FVECT zp |
373 |
> |
) |
374 |
|
{ |
375 |
|
int n; |
376 |
|
double theta; |