1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1990 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
12 |
|
* 11/6/86 Finally added error checking! |
13 |
|
*/ |
14 |
|
|
15 |
< |
#include <stdio.h> |
15 |
> |
#include "standard.h" |
16 |
|
|
17 |
|
#include <ctype.h> |
18 |
|
|
22 |
|
char **xav; /* global xform argument pointer */ |
23 |
|
int xfa; /* start of xf arguments */ |
24 |
|
|
25 |
< |
double totxform[4][4]; /* total transformation matrix */ |
26 |
< |
double totscale; /* total scale factor */ |
25 |
> |
XF tot; /* total transformation */ |
26 |
|
int reverse; /* boolean true if scene inverted */ |
27 |
|
|
28 |
|
int expand = 0; /* boolean true to expand commands */ |
86 |
|
xav = argv; |
87 |
|
xfa = a; |
88 |
|
|
89 |
< |
totscale = 1.0; |
91 |
< |
setident4(totxform); |
89 |
> |
a += xf(&tot, argc-a, argv+a); |
90 |
|
|
91 |
< |
a += xf(totxform, &totscale, argc-a, argv+a); |
91 |
> |
if (reverse = tot.sca < 0.0) |
92 |
> |
tot.sca = -tot.sca; |
93 |
|
|
95 |
– |
if (reverse = totscale < 0.0) |
96 |
– |
totscale = -totscale; |
97 |
– |
|
94 |
|
if (a < argc && argv[a][0] == '-') { |
95 |
|
fprintf(stderr, "%s: command line error at '%s'\n", |
96 |
|
argv[0], argv[a]); |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
< |
xform(name, fin) /* transform stream by totxform */ |
164 |
> |
xform(name, fin) /* transform stream by tot.xfm */ |
165 |
|
char *name; |
166 |
|
register FILE *fin; |
167 |
|
{ |
329 |
|
alias(fin) /* transfer alias */ |
330 |
|
FILE *fin; |
331 |
|
{ |
332 |
< |
char alias[MAXSTR]; |
332 |
> |
char aliasnm[MAXSTR]; |
333 |
|
|
334 |
< |
if (fscanf(fin, "%s", alias) != 1) |
334 |
> |
if (fscanf(fin, "%s", aliasnm) != 1) |
335 |
|
return(-1); |
336 |
< |
printf("\t%s\n", alias); |
336 |
> |
printf("\t%s\n", aliasnm); |
337 |
|
return(0); |
338 |
|
} |
339 |
|
|
350 |
|
printf("0\n0\n4"); |
351 |
|
printf(" %18.12g %18.12g %18.12g", |
352 |
|
fa->farg[0], fa->farg[1], fa->farg[2]); |
353 |
< |
printf(" %18.12g\n", fa->farg[3] * totscale); |
353 |
> |
printf(" %18.12g\n", fa->farg[3] * tot.sca); |
354 |
|
freefargs(fa); |
355 |
|
return(0); |
356 |
|
} |
369 |
|
printf("0\n0\n7"); |
370 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
371 |
|
fa->farg[0], fa->farg[1], fa->farg[2], fa->farg[3]); |
372 |
< |
multv3(v, fa->farg+4, totxform); |
372 |
> |
multv3(v, fa->farg+4, tot.xfm); |
373 |
|
printf("\t%18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
374 |
|
freefargs(fa); |
375 |
|
return(0); |
388 |
|
return(-1); |
389 |
|
printf("0\n0\n5"); |
390 |
|
printf(" %18.12g %18.12g %18.12g", |
391 |
< |
pow(fa->farg[0], 1.0/totscale), |
392 |
< |
pow(fa->farg[1], 1.0/totscale), |
393 |
< |
pow(fa->farg[2], 1.0/totscale)); |
391 |
> |
pow(fa->farg[0], 1.0/tot.sca), |
392 |
> |
pow(fa->farg[1], 1.0/tot.sca), |
393 |
> |
pow(fa->farg[2], 1.0/tot.sca)); |
394 |
|
printf(" %18.12g %18.12g\n", fa->farg[3], fa->farg[4]); |
395 |
|
freefargs(fa); |
396 |
|
return(0); |
409 |
|
return(-1); |
410 |
|
printf("0\n0\n8\n"); |
411 |
|
printf("%18.12g %18.12g %18.12g", |
412 |
< |
pow(fa->farg[0], 1.0/totscale), |
413 |
< |
pow(fa->farg[1], 1.0/totscale), |
414 |
< |
pow(fa->farg[2], 1.0/totscale)); |
412 |
> |
pow(fa->farg[0], 1.0/tot.sca), |
413 |
> |
pow(fa->farg[1], 1.0/tot.sca), |
414 |
> |
pow(fa->farg[2], 1.0/tot.sca)); |
415 |
|
printf(" %18.12g\n", fa->farg[3]); |
416 |
|
printf("%18.12g %18.12g %18.12g", |
417 |
< |
pow(fa->farg[4], 1.0/totscale), |
418 |
< |
pow(fa->farg[5], 1.0/totscale), |
419 |
< |
pow(fa->farg[6], 1.0/totscale)); |
417 |
> |
pow(fa->farg[4], 1.0/tot.sca), |
418 |
> |
pow(fa->farg[5], 1.0/tot.sca), |
419 |
> |
pow(fa->farg[6], 1.0/tot.sca)); |
420 |
|
printf(" %18.12g\n", fa->farg[7]); |
421 |
|
freefargs(fa); |
422 |
|
return(0); |
441 |
|
printf(" %s", fa->sarg[i]); |
442 |
|
printf("\n0\n%d\n", fa->nfargs); |
443 |
|
/* anchor point */ |
444 |
< |
multp3(v, fa->farg, totxform); |
444 |
> |
multp3(v, fa->farg, tot.xfm); |
445 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
446 |
|
/* right vector */ |
447 |
< |
multv3(v, fa->farg+3, totxform); |
447 |
> |
multv3(v, fa->farg+3, tot.xfm); |
448 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
449 |
|
/* down vector */ |
450 |
< |
multv3(v, fa->farg+6, totxform); |
450 |
> |
multv3(v, fa->farg+6, tot.xfm); |
451 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
452 |
|
/* forground and background */ |
453 |
|
if (fa->nfargs == 11) |
474 |
|
if (fa->nsargs != 0 || fa->niargs != 0 || fa->nfargs != 4) |
475 |
|
return(-1); |
476 |
|
/* transform direction vector */ |
477 |
< |
multv3(dv, fa->farg, totxform); |
477 |
> |
multv3(dv, fa->farg, tot.xfm); |
478 |
|
/* output */ |
479 |
|
printf("0\n0\n4"); |
480 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
495 |
|
if (fa->nsargs != 0 || fa->niargs != 0 || fa->nfargs != 4) |
496 |
|
return(-1); |
497 |
|
|
498 |
< |
multp3(cent, fa->farg, totxform); /* transform center */ |
498 |
> |
multp3(cent, fa->farg, tot.xfm); /* transform center */ |
499 |
|
|
500 |
< |
rad = fa->farg[3] * totscale; /* scale radius */ |
500 |
> |
rad = fa->farg[3] * tot.sca; /* scale radius */ |
501 |
|
|
502 |
|
printf("0\n0\n4"); |
503 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
523 |
|
|
524 |
|
for (i = 0; i < fa->nfargs; i += 3) { |
525 |
|
if (reverse) |
526 |
< |
multp3(p, fa->farg+(fa->nfargs-i-3), totxform); |
526 |
> |
multp3(p, fa->farg+(fa->nfargs-i-3), tot.xfm); |
527 |
|
else |
528 |
< |
multp3(p, fa->farg+i, totxform); |
528 |
> |
multp3(p, fa->farg+i, tot.xfm); |
529 |
|
printf(" %18.12g %18.12g %18.12g\n", p[0], p[1], p[2]); |
530 |
|
} |
531 |
|
freefargs(fa); |
546 |
|
|
547 |
|
printf("0\n0\n8\n"); |
548 |
|
|
549 |
< |
multp3(p0, fa->farg, totxform); |
550 |
< |
multp3(p1, fa->farg+3, totxform); |
551 |
< |
r0 = fa->farg[6] * totscale; |
552 |
< |
r1 = fa->farg[7] * totscale; |
549 |
> |
multp3(p0, fa->farg, tot.xfm); |
550 |
> |
multp3(p1, fa->farg+3, tot.xfm); |
551 |
> |
r0 = fa->farg[6] * tot.sca; |
552 |
> |
r1 = fa->farg[7] * tot.sca; |
553 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
554 |
|
printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]); |
555 |
|
printf(" %18.12g %18.12g\n", r0, r1); |
572 |
|
|
573 |
|
printf("0\n0\n7\n"); |
574 |
|
|
575 |
< |
multp3(p0, fa->farg, totxform); |
576 |
< |
multp3(p1, fa->farg+3, totxform); |
577 |
< |
rad = fa->farg[6] * totscale; |
575 |
> |
multp3(p0, fa->farg, tot.xfm); |
576 |
> |
multp3(p1, fa->farg+3, tot.xfm); |
577 |
> |
rad = fa->farg[6] * tot.sca; |
578 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
579 |
|
printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]); |
580 |
|
printf(" %18.12g\n", rad); |
596 |
|
|
597 |
|
printf("0\n0\n8\n"); |
598 |
|
|
599 |
< |
multp3(p0, fa->farg, totxform); |
600 |
< |
multv3(pd, fa->farg+3, totxform); |
601 |
< |
r0 = fa->farg[6] * totscale; |
602 |
< |
r1 = fa->farg[7] * totscale; |
599 |
> |
multp3(p0, fa->farg, tot.xfm); |
600 |
> |
multv3(pd, fa->farg+3, tot.xfm); |
601 |
> |
r0 = fa->farg[6] * tot.sca; |
602 |
> |
r1 = fa->farg[7] * tot.sca; |
603 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
604 |
|
printf(" %18.12g %18.12g %18.12g\n", pd[0], pd[1], pd[2]); |
605 |
|
printf(" %18.12g %18.12g\n", r0, r1); |