| 1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1991 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 |
|
|
| 19 |
+ |
#include "otypes.h" |
| 20 |
|
|
| 20 |
– |
typedef struct { |
| 21 |
– |
char *funame; /* function name */ |
| 22 |
– |
int (*funp)(); /* pointer to function */ |
| 23 |
– |
} FUN; |
| 24 |
– |
|
| 21 |
|
int xac; /* global xform argument count */ |
| 22 |
|
char **xav; /* global xform argument pointer */ |
| 23 |
|
int xfa; /* start of xf arguments */ |
| 24 |
|
|
| 25 |
< |
double totxform[4][4]; /* total transformation matrix */ |
| 30 |
< |
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 */ |
| 29 |
|
|
| 30 |
+ |
char *newmod = NULL; /* new modifier for surfaces */ |
| 31 |
+ |
|
| 32 |
|
char *idprefix = NULL; /* prefix for object identifiers */ |
| 33 |
|
|
| 34 |
< |
extern int o_source(); |
| 38 |
< |
extern int o_sphere(); |
| 39 |
< |
extern int o_face(); |
| 40 |
< |
extern int o_cone(); |
| 41 |
< |
extern int o_cylinder(); |
| 42 |
< |
extern int o_ring(); |
| 43 |
< |
extern int m_glow(); |
| 44 |
< |
extern int m_spot(); |
| 45 |
< |
extern int m_dielectric(); |
| 46 |
< |
extern int m_interface(); |
| 47 |
< |
extern int text(); |
| 48 |
< |
extern int alias(); |
| 49 |
< |
extern int passargs(); |
| 50 |
< |
extern int addxform(); |
| 34 |
> |
#define ALIAS NUMOTYPE /* put alias at end of array */ |
| 35 |
|
|
| 36 |
< |
FUN ofun[] = { |
| 53 |
< |
{ "source", o_source }, |
| 54 |
< |
{ "sphere", o_sphere }, |
| 55 |
< |
{ "bubble", o_sphere }, |
| 56 |
< |
{ "polygon", o_face }, |
| 57 |
< |
{ "cone", o_cone }, |
| 58 |
< |
{ "cup", o_cone }, |
| 59 |
< |
{ "cylinder", o_cylinder }, |
| 60 |
< |
{ "tube", o_cylinder }, |
| 61 |
< |
{ "ring", o_ring }, |
| 62 |
< |
{ "instance", addxform }, |
| 63 |
< |
{ "alias", alias }, |
| 64 |
< |
{ "antimatter", passargs }, |
| 65 |
< |
{ "glow", m_glow }, |
| 66 |
< |
{ "spotlight", m_spot }, |
| 67 |
< |
{ "dielectric", m_dielectric }, |
| 68 |
< |
{ "interface", m_interface }, |
| 69 |
< |
{ "colortext", text }, |
| 70 |
< |
{ "brighttext", text }, |
| 71 |
< |
{ "texfunc", addxform }, |
| 72 |
< |
{ "texdata", addxform }, |
| 73 |
< |
{ "colorfunc", addxform }, |
| 74 |
< |
{ "brightfunc", addxform }, |
| 75 |
< |
{ "colorpict", addxform }, |
| 76 |
< |
{ "colordata", addxform }, |
| 77 |
< |
{ "brightdata", addxform }, |
| 78 |
< |
{ "mixfunc", addxform }, |
| 79 |
< |
{ "mixdata", addxform }, |
| 80 |
< |
{ "mixtext", text }, |
| 81 |
< |
{ "light", passargs }, |
| 82 |
< |
{ "illum", passargs }, |
| 83 |
< |
{ "plastic", passargs }, |
| 84 |
< |
{ "metal", passargs }, |
| 85 |
< |
{ "trans", passargs }, |
| 86 |
< |
{ "glass", passargs }, |
| 87 |
< |
{ 0 } /* terminator */ |
| 88 |
< |
}; |
| 36 |
> |
#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ |
| 37 |
|
|
| 38 |
< |
#define issurface(t) ((t)<=9) |
| 38 |
> |
FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ |
| 39 |
|
|
| 40 |
|
typedef struct { |
| 41 |
|
short nsargs; /* # of string arguments */ |
| 46 |
|
double *farg; /* float arguments */ |
| 47 |
|
} FUNARGS; |
| 48 |
|
|
| 49 |
< |
#define MAXSTR 512 /* maximum string length */ |
| 49 |
> |
#define MAXSTR 128 /* maximum string length */ |
| 50 |
|
|
| 51 |
|
FUNARGS *getfargs(); |
| 52 |
|
char *malloc(); |
| 61 |
|
FILE *fopen(); |
| 62 |
|
FILE *fp; |
| 63 |
|
int a; |
| 64 |
+ |
/* check for array */ |
| 65 |
+ |
for (a = 1; a < argc; a++) |
| 66 |
+ |
if (!strcmp(argv[a], "-a")) |
| 67 |
+ |
return(doarray(argc, argv, a)); |
| 68 |
|
|
| 69 |
< |
xav = argv; |
| 69 |
> |
initotypes(); |
| 70 |
|
|
| 71 |
|
for (a = 1; a < argc; a++) { |
| 72 |
|
if (argv[a][0] == '-') |
| 73 |
|
switch (argv[a][1]) { |
| 74 |
+ |
case 'm': |
| 75 |
+ |
if (argv[a][2] || a+1 >= argc) |
| 76 |
+ |
break; |
| 77 |
+ |
newmod = argv[++a]; |
| 78 |
+ |
continue; |
| 79 |
|
case 'n': |
| 80 |
+ |
if (argv[a][2] || a+1 >= argc) |
| 81 |
+ |
break; |
| 82 |
|
idprefix = argv[++a]; |
| 83 |
|
continue; |
| 84 |
|
case 'e': |
| 85 |
+ |
if (argv[a][2]) |
| 86 |
+ |
break; |
| 87 |
|
expand = 1; |
| 88 |
|
continue; |
| 89 |
|
} |
| 90 |
|
break; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
+ |
xav = argv; |
| 94 |
|
xfa = a; |
| 95 |
|
|
| 96 |
< |
totscale = 1.0; |
| 135 |
< |
setident4(totxform); |
| 96 |
> |
a += xf(&tot, argc-a, argv+a); |
| 97 |
|
|
| 98 |
< |
a += xf(totxform, &totscale, argc-a, argv+a); |
| 98 |
> |
if (reverse = tot.sca < 0.0) |
| 99 |
> |
tot.sca = -tot.sca; |
| 100 |
|
|
| 101 |
< |
if (reverse = totscale < 0.0) |
| 102 |
< |
totscale = -totscale; |
| 101 |
> |
if (a < argc && argv[a][0] == '-') { |
| 102 |
> |
fprintf(stderr, "%s: command line error at '%s'\n", |
| 103 |
> |
argv[0], argv[a]); |
| 104 |
> |
exit(1); |
| 105 |
> |
} |
| 106 |
|
|
| 107 |
|
xac = a; |
| 108 |
< |
|
| 109 |
< |
putchar('#'); /* simple header */ |
| 108 |
> |
/* simple header */ |
| 109 |
> |
putchar('#'); |
| 110 |
|
for (a = 0; a < xac; a++) |
| 111 |
|
printf(" %s", xav[a]); |
| 112 |
|
putchar('\n'); |
| 113 |
< |
|
| 114 |
< |
if (a == argc) |
| 113 |
> |
/* transform input */ |
| 114 |
> |
if (xac == argc) |
| 115 |
|
xform("standard input", stdin); |
| 116 |
|
else |
| 117 |
< |
for ( ; a < argc; a++) { |
| 117 |
> |
for (a = xac; a < argc; a++) { |
| 118 |
|
if ((fp = fopen(argv[a], "r")) == NULL) { |
| 119 |
|
fprintf(stderr, "%s: cannot open \"%s\"\n", |
| 120 |
|
progname, argv[a]); |
| 124 |
|
fclose(fp); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
< |
exit(0); |
| 127 |
> |
return(0); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
|
| 131 |
< |
xform(name, fin) /* transform stream by totxform */ |
| 131 |
> |
doarray(ac, av, ai) /* make array */ |
| 132 |
> |
char **av; |
| 133 |
> |
int ac, ai; |
| 134 |
> |
{ |
| 135 |
> |
char *newav[256], **avp; |
| 136 |
> |
char newid[128], repts[32]; |
| 137 |
> |
char *oldid = NULL; |
| 138 |
> |
int i, err; |
| 139 |
> |
|
| 140 |
> |
avp = newav+2; |
| 141 |
> |
avp[0] = av[0]; |
| 142 |
> |
for (i = 1; i < ac; i++) |
| 143 |
> |
if (!strcmp(av[i-1], "-n")) { |
| 144 |
> |
oldid = av[i]; |
| 145 |
> |
avp[i] = newid; |
| 146 |
> |
} else |
| 147 |
> |
avp[i] = av[i]; |
| 148 |
> |
avp[ai] = "-i"; |
| 149 |
> |
avp[ai+1] = repts; |
| 150 |
> |
avp[i] = NULL; |
| 151 |
> |
if (oldid == NULL) { |
| 152 |
> |
newav[0] = av[0]; |
| 153 |
> |
newav[1] = "-n"; |
| 154 |
> |
newav[2] = newid; |
| 155 |
> |
avp = newav; |
| 156 |
> |
ac += 2; |
| 157 |
> |
} |
| 158 |
> |
err = 0; |
| 159 |
> |
for (i = 0; i < atoi(av[ai+1]); i++) { |
| 160 |
> |
if (oldid == NULL) |
| 161 |
> |
sprintf(newid, "a%d", i); |
| 162 |
> |
else |
| 163 |
> |
sprintf(newid, "%s.%d", oldid, i); |
| 164 |
> |
sprintf(repts, "%d", i); |
| 165 |
> |
err |= main(ac, avp); |
| 166 |
> |
} |
| 167 |
> |
return(err); |
| 168 |
> |
} |
| 169 |
> |
|
| 170 |
> |
|
| 171 |
> |
xform(name, fin) /* transform stream by tot.xfm */ |
| 172 |
|
char *name; |
| 173 |
|
register FILE *fin; |
| 174 |
|
{ |
| 186 |
|
} while (c != '\n'); |
| 187 |
|
} else if (c == '!') { /* command */ |
| 188 |
|
ungetc(c, fin); |
| 189 |
< |
if (expand) |
| 185 |
< |
xfcomm(name, fin); |
| 186 |
< |
else { |
| 187 |
< |
putchar('\n'); |
| 188 |
< |
while ((c = getc(fin)) != EOF && c != '\n') |
| 189 |
< |
putchar(c); |
| 190 |
< |
printf(" |"); |
| 191 |
< |
for (c = 0; c < xac; c++) |
| 192 |
< |
printf(" %s", xav[c]); |
| 193 |
< |
putchar('\n'); |
| 194 |
< |
} |
| 189 |
> |
xfcomm(name, fin); |
| 190 |
|
} else { /* object */ |
| 191 |
|
ungetc(c, fin); |
| 192 |
|
xfobject(name, fin); |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 198 |
< |
xfcomm(fname, fin) /* expand a command */ |
| 198 |
> |
xfcomm(fname, fin) /* transform a command */ |
| 199 |
|
FILE *fin; |
| 200 |
|
{ |
| 201 |
|
FILE *popen(); |
| 202 |
< |
char *fgets(); |
| 202 |
> |
char *fgetline(); |
| 203 |
|
FILE *pin; |
| 204 |
|
char buf[512]; |
| 205 |
+ |
int i; |
| 206 |
|
|
| 207 |
< |
fgets(buf, sizeof(buf), fin); |
| 208 |
< |
if (buf[strlen(buf)-1] == '\n') |
| 209 |
< |
buf[strlen(buf)-1] = '\0'; |
| 210 |
< |
if ((pin = popen(buf+1, "r")) == NULL) { |
| 211 |
< |
fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n", |
| 212 |
< |
progname, fname, buf); |
| 213 |
< |
exit(1); |
| 207 |
> |
fgetline(buf, sizeof(buf), fin); |
| 208 |
> |
if (expand) { |
| 209 |
> |
if (xac > 2) { |
| 210 |
> |
if ((pin = popen(buf+1, "r")) == NULL) { |
| 211 |
> |
fprintf(stderr, |
| 212 |
> |
"%s: (%s): cannot execute \"%s\"\n", |
| 213 |
> |
progname, fname, buf); |
| 214 |
> |
exit(1); |
| 215 |
> |
} |
| 216 |
> |
xform(buf, pin); |
| 217 |
> |
pclose(pin); |
| 218 |
> |
} else { |
| 219 |
> |
fflush(stdout); |
| 220 |
> |
system(buf+1); |
| 221 |
> |
} |
| 222 |
> |
} else { |
| 223 |
> |
printf("\n%s", buf); |
| 224 |
> |
if (xac > 1) { |
| 225 |
> |
printf(" | %s -e", xav[0]); |
| 226 |
> |
for (i = 1; i < xac; i++) |
| 227 |
> |
printf(" %s", xav[i]); |
| 228 |
> |
} |
| 229 |
> |
putchar('\n'); |
| 230 |
|
} |
| 219 |
– |
xform(buf, pin); |
| 220 |
– |
pclose(pin); |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
|
| 235 |
|
char *fname; |
| 236 |
|
FILE *fin; |
| 237 |
|
{ |
| 238 |
< |
char stmp[MAXSTR]; |
| 238 |
> |
char typ[16], nam[MAXSTR]; |
| 239 |
|
int fn; |
| 240 |
< |
|
| 241 |
< |
fscanf(fin, "%s", stmp); /* modifier */ |
| 242 |
< |
printf("\n%s ", stmp); |
| 233 |
< |
fscanf(fin, "%s", stmp); /* object type */ |
| 234 |
< |
if ((fn = otype(stmp)) < 0) { |
| 240 |
> |
/* modifier and type */ |
| 241 |
> |
fscanf(fin, "%s %s", nam, typ); |
| 242 |
> |
if ((fn = otype(typ)) < 0) { |
| 243 |
|
fprintf(stderr, "%s: (%s): unknown object type \"%s\"\n", |
| 244 |
< |
progname, fname, stmp); |
| 244 |
> |
progname, fname, typ); |
| 245 |
|
exit(1); |
| 246 |
|
} |
| 247 |
< |
printf("%s ", stmp); |
| 248 |
< |
fscanf(fin, "%s", stmp); /* object name */ |
| 247 |
> |
printf("\n%s %s ", newmod!=NULL && issurface(fn) ? newmod : nam, typ); |
| 248 |
> |
/* object name */ |
| 249 |
> |
fscanf(fin, "%s", nam); |
| 250 |
|
if (idprefix != NULL && issurface(fn)) |
| 251 |
< |
printf("%s.%s\n", idprefix, stmp); |
| 251 |
> |
printf("%s.%s\n", idprefix, nam); |
| 252 |
|
else |
| 253 |
< |
printf("%s\n", stmp); |
| 254 |
< |
/* transform arguments */ |
| 253 |
> |
printf("%s\n", nam); |
| 254 |
> |
/* transform arguments */ |
| 255 |
|
if ((*ofun[fn].funp)(fin) < 0) { |
| 256 |
|
fprintf(stderr, "%s: (%s): bad %s \"%s\"\n", |
| 257 |
< |
progname, fname, ofun[fn].funame, stmp); |
| 257 |
> |
progname, fname, ofun[fn].funame, nam); |
| 258 |
|
exit(1); |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
|
| 263 |
< |
passargs(fin) /* pass on arguments unchanged */ |
| 263 |
> |
o_default(fin) /* pass on arguments unchanged */ |
| 264 |
|
FILE *fin; |
| 265 |
|
{ |
| 266 |
|
register int i; |
| 324 |
|
{ |
| 325 |
|
register int i; |
| 326 |
|
|
| 327 |
< |
for (i = 0; ofun[i].funame != NULL; i++) |
| 327 |
> |
for (i = 0; i < NUMTYPES; i++) |
| 328 |
|
if (!strcmp(ofun[i].funame, ofname)) |
| 329 |
|
return(i); |
| 330 |
|
|
| 335 |
|
alias(fin) /* transfer alias */ |
| 336 |
|
FILE *fin; |
| 337 |
|
{ |
| 338 |
< |
char alias[MAXSTR]; |
| 338 |
> |
char aliasnm[MAXSTR]; |
| 339 |
|
|
| 340 |
< |
if (fscanf(fin, "%s", alias) != 1) |
| 340 |
> |
if (fscanf(fin, "%s", aliasnm) != 1) |
| 341 |
|
return(-1); |
| 342 |
< |
printf("\t%s\n", alias); |
| 342 |
> |
printf("\t%s\n", aliasnm); |
| 343 |
|
return(0); |
| 344 |
|
} |
| 345 |
|
|
| 356 |
|
printf("0\n0\n4"); |
| 357 |
|
printf(" %18.12g %18.12g %18.12g", |
| 358 |
|
fa->farg[0], fa->farg[1], fa->farg[2]); |
| 359 |
< |
printf(" %18.12g\n", fa->farg[3] * totscale); |
| 359 |
> |
printf(" %18.12g\n", fa->farg[3] * tot.sca); |
| 360 |
|
freefargs(fa); |
| 361 |
|
return(0); |
| 362 |
|
} |
| 375 |
|
printf("0\n0\n7"); |
| 376 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
| 377 |
|
fa->farg[0], fa->farg[1], fa->farg[2], fa->farg[3]); |
| 378 |
< |
multv3(v, fa->farg+4, totxform); |
| 378 |
> |
multv3(v, fa->farg+4, tot.xfm); |
| 379 |
|
printf("\t%18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
| 380 |
|
freefargs(fa); |
| 381 |
|
return(0); |
| 394 |
|
return(-1); |
| 395 |
|
printf("0\n0\n5"); |
| 396 |
|
printf(" %18.12g %18.12g %18.12g", |
| 397 |
< |
pow(fa->farg[0], 1.0/totscale), |
| 398 |
< |
pow(fa->farg[1], 1.0/totscale), |
| 399 |
< |
pow(fa->farg[2], 1.0/totscale)); |
| 397 |
> |
pow(fa->farg[0], 1.0/tot.sca), |
| 398 |
> |
pow(fa->farg[1], 1.0/tot.sca), |
| 399 |
> |
pow(fa->farg[2], 1.0/tot.sca)); |
| 400 |
|
printf(" %18.12g %18.12g\n", fa->farg[3], fa->farg[4]); |
| 401 |
|
freefargs(fa); |
| 402 |
|
return(0); |
| 415 |
|
return(-1); |
| 416 |
|
printf("0\n0\n8\n"); |
| 417 |
|
printf("%18.12g %18.12g %18.12g", |
| 418 |
< |
pow(fa->farg[0], 1.0/totscale), |
| 419 |
< |
pow(fa->farg[1], 1.0/totscale), |
| 420 |
< |
pow(fa->farg[2], 1.0/totscale)); |
| 418 |
> |
pow(fa->farg[0], 1.0/tot.sca), |
| 419 |
> |
pow(fa->farg[1], 1.0/tot.sca), |
| 420 |
> |
pow(fa->farg[2], 1.0/tot.sca)); |
| 421 |
|
printf(" %18.12g\n", fa->farg[3]); |
| 422 |
|
printf("%18.12g %18.12g %18.12g", |
| 423 |
< |
pow(fa->farg[4], 1.0/totscale), |
| 424 |
< |
pow(fa->farg[5], 1.0/totscale), |
| 425 |
< |
pow(fa->farg[6], 1.0/totscale)); |
| 423 |
> |
pow(fa->farg[4], 1.0/tot.sca), |
| 424 |
> |
pow(fa->farg[5], 1.0/tot.sca), |
| 425 |
> |
pow(fa->farg[6], 1.0/tot.sca)); |
| 426 |
|
printf(" %18.12g\n", fa->farg[7]); |
| 427 |
|
freefargs(fa); |
| 428 |
|
return(0); |
| 447 |
|
printf(" %s", fa->sarg[i]); |
| 448 |
|
printf("\n0\n%d\n", fa->nfargs); |
| 449 |
|
/* anchor point */ |
| 450 |
< |
multp3(v, fa->farg, totxform); |
| 450 |
> |
multp3(v, fa->farg, tot.xfm); |
| 451 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
| 452 |
|
/* right vector */ |
| 453 |
< |
multv3(v, fa->farg+3, totxform); |
| 453 |
> |
multv3(v, fa->farg+3, tot.xfm); |
| 454 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
| 455 |
|
/* down vector */ |
| 456 |
< |
multv3(v, fa->farg+6, totxform); |
| 456 |
> |
multv3(v, fa->farg+6, tot.xfm); |
| 457 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
| 458 |
|
/* forground and background */ |
| 459 |
|
if (fa->nfargs == 11) |
| 480 |
|
if (fa->nsargs != 0 || fa->niargs != 0 || fa->nfargs != 4) |
| 481 |
|
return(-1); |
| 482 |
|
/* transform direction vector */ |
| 483 |
< |
multv3(dv, fa->farg, totxform); |
| 483 |
> |
multv3(dv, fa->farg, tot.xfm); |
| 484 |
|
/* output */ |
| 485 |
|
printf("0\n0\n4"); |
| 486 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
| 501 |
|
if (fa->nsargs != 0 || fa->niargs != 0 || fa->nfargs != 4) |
| 502 |
|
return(-1); |
| 503 |
|
|
| 504 |
< |
multp3(cent, fa->farg, totxform); /* transform center */ |
| 504 |
> |
multp3(cent, fa->farg, tot.xfm); /* transform center */ |
| 505 |
|
|
| 506 |
< |
rad = fa->farg[3] * totscale; /* scale radius */ |
| 506 |
> |
rad = fa->farg[3] * tot.sca; /* scale radius */ |
| 507 |
|
|
| 508 |
|
printf("0\n0\n4"); |
| 509 |
|
printf(" %18.12g %18.12g %18.12g %18.12g\n", |
| 529 |
|
|
| 530 |
|
for (i = 0; i < fa->nfargs; i += 3) { |
| 531 |
|
if (reverse) |
| 532 |
< |
multp3(p, fa->farg+(fa->nfargs-i-3), totxform); |
| 532 |
> |
multp3(p, fa->farg+(fa->nfargs-i-3), tot.xfm); |
| 533 |
|
else |
| 534 |
< |
multp3(p, fa->farg+i, totxform); |
| 534 |
> |
multp3(p, fa->farg+i, tot.xfm); |
| 535 |
|
printf(" %18.12g %18.12g %18.12g\n", p[0], p[1], p[2]); |
| 536 |
|
} |
| 537 |
|
freefargs(fa); |
| 552 |
|
|
| 553 |
|
printf("0\n0\n8\n"); |
| 554 |
|
|
| 555 |
< |
multp3(p0, fa->farg, totxform); |
| 556 |
< |
multp3(p1, fa->farg+3, totxform); |
| 557 |
< |
r0 = fa->farg[6] * totscale; |
| 558 |
< |
r1 = fa->farg[7] * totscale; |
| 555 |
> |
multp3(p0, fa->farg, tot.xfm); |
| 556 |
> |
multp3(p1, fa->farg+3, tot.xfm); |
| 557 |
> |
r0 = fa->farg[6] * tot.sca; |
| 558 |
> |
r1 = fa->farg[7] * tot.sca; |
| 559 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
| 560 |
|
printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]); |
| 561 |
|
printf(" %18.12g %18.12g\n", r0, r1); |
| 578 |
|
|
| 579 |
|
printf("0\n0\n7\n"); |
| 580 |
|
|
| 581 |
< |
multp3(p0, fa->farg, totxform); |
| 582 |
< |
multp3(p1, fa->farg+3, totxform); |
| 583 |
< |
rad = fa->farg[6] * totscale; |
| 581 |
> |
multp3(p0, fa->farg, tot.xfm); |
| 582 |
> |
multp3(p1, fa->farg+3, tot.xfm); |
| 583 |
> |
rad = fa->farg[6] * tot.sca; |
| 584 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
| 585 |
|
printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]); |
| 586 |
|
printf(" %18.12g\n", rad); |
| 602 |
|
|
| 603 |
|
printf("0\n0\n8\n"); |
| 604 |
|
|
| 605 |
< |
multp3(p0, fa->farg, totxform); |
| 606 |
< |
multv3(pd, fa->farg+3, totxform); |
| 607 |
< |
r0 = fa->farg[6] * totscale; |
| 608 |
< |
r1 = fa->farg[7] * totscale; |
| 605 |
> |
multp3(p0, fa->farg, tot.xfm); |
| 606 |
> |
multv3(pd, fa->farg+3, tot.xfm); |
| 607 |
> |
r0 = fa->farg[6] * tot.sca; |
| 608 |
> |
r1 = fa->farg[7] * tot.sca; |
| 609 |
|
printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]); |
| 610 |
|
printf(" %18.12g %18.12g %18.12g\n", pd[0], pd[1], pd[2]); |
| 611 |
|
printf(" %18.12g %18.12g\n", r0, r1); |
| 684 |
|
if (fa->nfargs) |
| 685 |
|
free(fa->farg); |
| 686 |
|
free(fa); |
| 687 |
+ |
} |
| 688 |
+ |
|
| 689 |
+ |
|
| 690 |
+ |
initotypes() /* initialize ofun[] array */ |
| 691 |
+ |
{ |
| 692 |
+ |
extern int o_source(); |
| 693 |
+ |
extern int o_sphere(); |
| 694 |
+ |
extern int o_face(); |
| 695 |
+ |
extern int o_cone(); |
| 696 |
+ |
extern int o_cylinder(); |
| 697 |
+ |
extern int o_ring(); |
| 698 |
+ |
extern int m_glow(); |
| 699 |
+ |
extern int m_spot(); |
| 700 |
+ |
extern int m_dielectric(); |
| 701 |
+ |
extern int m_interface(); |
| 702 |
+ |
extern int text(); |
| 703 |
+ |
extern int alias(); |
| 704 |
+ |
extern int passargs(); |
| 705 |
+ |
extern int addxform(); |
| 706 |
+ |
register int i; |
| 707 |
+ |
|
| 708 |
+ |
if (ofun[OBJ_SOURCE].funp == o_source) |
| 709 |
+ |
return; /* done already */ |
| 710 |
+ |
/* alias is additional */ |
| 711 |
+ |
ofun[ALIAS].funame = ALIASID; |
| 712 |
+ |
ofun[ALIAS].flags = 0; |
| 713 |
+ |
/* functions get new transform */ |
| 714 |
+ |
for (i = 0; i < NUMTYPES; i++) |
| 715 |
+ |
if (hasfunc(i)) |
| 716 |
+ |
ofun[i].funp = addxform; |
| 717 |
+ |
/* special cases */ |
| 718 |
+ |
ofun[OBJ_SOURCE].funp = o_source; |
| 719 |
+ |
ofun[OBJ_SPHERE].funp = |
| 720 |
+ |
ofun[OBJ_BUBBLE].funp = o_sphere; |
| 721 |
+ |
ofun[OBJ_FACE].funp = o_face; |
| 722 |
+ |
ofun[OBJ_CONE].funp = |
| 723 |
+ |
ofun[OBJ_CUP].funp = o_cone; |
| 724 |
+ |
ofun[OBJ_CYLINDER].funp = |
| 725 |
+ |
ofun[OBJ_TUBE].funp = o_cylinder; |
| 726 |
+ |
ofun[OBJ_RING].funp = o_ring; |
| 727 |
+ |
ofun[OBJ_INSTANCE].funp = addxform; |
| 728 |
+ |
ofun[MAT_GLOW].funp = m_glow; |
| 729 |
+ |
ofun[MAT_SPOT].funp = m_spot; |
| 730 |
+ |
ofun[MAT_DIELECTRIC].funp = m_dielectric; |
| 731 |
+ |
ofun[MAT_INTERFACE].funp = m_interface; |
| 732 |
+ |
ofun[PAT_CTEXT].funp = |
| 733 |
+ |
ofun[PAT_BTEXT].funp = |
| 734 |
+ |
ofun[MIX_TEXT].funp = text; |
| 735 |
+ |
ofun[ALIAS].funp = alias; |
| 736 |
|
} |