25 |
|
int xfa; /* start of xf arguments */ |
26 |
|
|
27 |
|
XF tot; /* total transformation */ |
28 |
< |
int reverse; /* boolean true if scene inverted */ |
28 |
> |
int reverse; /* boolean true if scene mirrored */ |
29 |
|
|
30 |
+ |
int invert = 0; /* boolean true to invert surfaces */ |
31 |
+ |
|
32 |
|
int expand = 0; /* boolean true to expand commands */ |
33 |
|
|
34 |
|
char *newmod = NULL; /* new modifier for surfaces */ |
41 |
|
|
42 |
|
FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ |
43 |
|
|
44 |
+ |
short tinvers[NUMOTYPE]; /* inverse types for surfaces */ |
45 |
+ |
|
46 |
|
extern char *malloc(), *fgetword(); |
47 |
|
|
48 |
|
#define progname (xav[0]) |
80 |
|
break; |
81 |
|
expand = 1; |
82 |
|
continue; |
83 |
+ |
case 'I': |
84 |
+ |
if (argv[a][2]) |
85 |
+ |
break; |
86 |
+ |
invert = 1; |
87 |
+ |
continue; |
88 |
|
} |
89 |
|
break; |
90 |
|
} |
96 |
|
|
97 |
|
if (reverse = tot.sca < 0.0) |
98 |
|
tot.sca = -tot.sca; |
99 |
+ |
if (invert) |
100 |
+ |
reverse = !reverse; |
101 |
|
|
102 |
|
if (a < argc && argv[a][0] == '-') { |
103 |
|
fprintf(stderr, "%s: command line error at '%s'\n", |
236 |
|
char *fname; |
237 |
|
FILE *fin; |
238 |
|
{ |
239 |
+ |
extern char *strcpy(); |
240 |
|
char typ[16], nam[MAXSTR]; |
241 |
|
int fn; |
242 |
|
/* modifier and type */ |
248 |
|
progname, fname, typ); |
249 |
|
exit(1); |
250 |
|
} |
251 |
< |
printf("\n%s %s ", newmod!=NULL && issurface(fn) ? newmod : nam, typ); |
251 |
> |
if (issurface(fn)) |
252 |
> |
printf("\n%s %s ", newmod != NULL ? newmod : nam, |
253 |
> |
invert ? ofun[tinvers[fn]].funame : typ); |
254 |
> |
else |
255 |
> |
printf("\n%s %s ", nam, typ); |
256 |
|
/* object name */ |
257 |
|
fgetword(nam, sizeof(nam), fin); |
258 |
|
if (idprefix != NULL && issurface(fn)) |
304 |
|
FILE *fin; |
305 |
|
{ |
306 |
|
register int i; |
307 |
+ |
int resetarr = 0; |
308 |
|
FUNARGS fa; |
309 |
|
|
310 |
|
if (readfargs(&fa, fin) != 1) |
311 |
|
return(-1); |
312 |
|
/* string arguments */ |
313 |
< |
printf("%d", fa.nsargs + xac-xfa); |
313 |
> |
if (xac > xfa && strcmp(xav[xfa], "-i")) |
314 |
> |
resetarr = 2; |
315 |
> |
printf("%d", fa.nsargs + resetarr + xac-xfa); |
316 |
|
for (i = 0; i < fa.nsargs; i++) |
317 |
|
printf(" %s", fa.sarg[i]); |
318 |
+ |
if (resetarr) |
319 |
+ |
printf(" -i 1"); |
320 |
|
for (i = xfa; i < xac; i++) /* add xf arguments */ |
321 |
|
printf(" %s", xav[i]); |
322 |
|
printf("\n"); |
386 |
|
m_spot(fin) /* transform arguments for spotlight */ |
387 |
|
FILE *fin; |
388 |
|
{ |
389 |
< |
double v[3]; |
389 |
> |
FVECT v; |
390 |
|
FUNARGS fa; |
391 |
|
|
392 |
|
if (readfargs(&fa, fin) != 1) |
454 |
|
FILE *fin; |
455 |
|
{ |
456 |
|
int i; |
457 |
< |
double v[3]; |
457 |
> |
FVECT v; |
458 |
|
FUNARGS fa; |
459 |
|
|
460 |
|
if (readfargs(&fa, fin) != 1) |
492 |
|
o_source(fin) /* transform source arguments */ |
493 |
|
FILE *fin; |
494 |
|
{ |
495 |
< |
double dv[3]; |
495 |
> |
FVECT dv; |
496 |
|
FUNARGS fa; |
497 |
|
|
498 |
|
if (readfargs(&fa, fin) != 1) |
513 |
|
o_sphere(fin) /* transform sphere arguments */ |
514 |
|
FILE *fin; |
515 |
|
{ |
516 |
< |
double cent[3], rad; |
516 |
> |
FVECT cent; |
517 |
> |
double rad; |
518 |
|
FUNARGS fa; |
519 |
|
|
520 |
|
if (readfargs(&fa, fin) != 1) |
537 |
|
o_face(fin) /* transform face arguments */ |
538 |
|
FILE *fin; |
539 |
|
{ |
540 |
< |
double p[3]; |
540 |
> |
FVECT p; |
541 |
|
register int i; |
542 |
|
FUNARGS fa; |
543 |
|
|
563 |
|
o_cone(fin) /* transform cone and cup arguments */ |
564 |
|
FILE *fin; |
565 |
|
{ |
566 |
< |
double p0[3], p1[3], r0, r1; |
566 |
> |
FVECT p0, p1; |
567 |
> |
double r0, r1; |
568 |
|
FUNARGS fa; |
569 |
|
|
570 |
|
if (readfargs(&fa, fin) != 1) |
590 |
|
o_cylinder(fin) /* transform cylinder and tube arguments */ |
591 |
|
FILE *fin; |
592 |
|
{ |
593 |
< |
double p0[3], p1[3], rad; |
593 |
> |
FVECT p0, p1; |
594 |
> |
double rad; |
595 |
|
FUNARGS fa; |
596 |
|
|
597 |
|
if (readfargs(&fa, fin) != 1) |
615 |
|
o_ring(fin) /* transform ring arguments */ |
616 |
|
FILE *fin; |
617 |
|
{ |
618 |
< |
double p0[3], pd[3], r0, r1; |
618 |
> |
FVECT p0, pd; |
619 |
> |
double r0, r1; |
620 |
|
FUNARGS fa; |
621 |
|
|
622 |
|
if (readfargs(&fa, fin) != 1) |
628 |
|
|
629 |
|
multp3(p0, fa.farg, tot.xfm); |
630 |
|
multv3(pd, fa.farg+3, tot.xfm); |
631 |
+ |
if (invert) { |
632 |
+ |
pd[0] = -pd[0]; |
633 |
+ |
pd[1] = -pd[1]; |
634 |
+ |
pd[2] = -pd[2]; |
635 |
+ |
} |
636 |
|
r0 = fa.farg[6] * tot.sca; |
637 |
|
r1 = fa.farg[7] * tot.sca; |
638 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
689 |
|
ofun[PAT_BTEXT].funp = |
690 |
|
ofun[MIX_TEXT].funp = text; |
691 |
|
ofun[ALIAS].funp = alias; |
692 |
+ |
/* surface inverses */ |
693 |
+ |
tinvers[OBJ_SOURCE] = OBJ_SOURCE; |
694 |
+ |
tinvers[OBJ_CONE] = OBJ_CUP; |
695 |
+ |
tinvers[OBJ_CUP] = OBJ_CONE; |
696 |
+ |
tinvers[OBJ_SPHERE] = OBJ_BUBBLE; |
697 |
+ |
tinvers[OBJ_BUBBLE] = OBJ_SPHERE; |
698 |
+ |
tinvers[OBJ_RING] = OBJ_RING; |
699 |
+ |
tinvers[OBJ_CYLINDER] = OBJ_TUBE; |
700 |
+ |
tinvers[OBJ_TUBE] = OBJ_CYLINDER; |
701 |
+ |
tinvers[OBJ_INSTANCE] = OBJ_INSTANCE; /* oh, well */ |
702 |
|
} |