ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/xform.c
Revision: 2.6
Committed: Mon Sep 21 12:15:44 1992 UTC (31 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.5: +27 -26 lines
Log Message:
Changes for PC port

File Contents

# User Rev Content
1 greg 2.6 /* Copyright (c) 1992 Regents of the University of California */
2 greg 1.1
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * xform.c - program to transform object files.
9     * Transformations must preserve aspect ratio.
10     *
11     * 10/19/85
12     * 11/6/86 Finally added error checking!
13     */
14    
15 greg 1.12 #include "standard.h"
16 greg 1.1
17     #include <ctype.h>
18    
19 greg 1.14 #include "object.h"
20    
21 greg 1.11 #include "otypes.h"
22 greg 1.1
23     int xac; /* global xform argument count */
24     char **xav; /* global xform argument pointer */
25     int xfa; /* start of xf arguments */
26    
27 greg 1.12 XF tot; /* total transformation */
28 greg 1.16 int reverse; /* boolean true if scene mirrored */
29 greg 1.1
30 greg 1.16 int invert = 0; /* boolean true to invert surfaces */
31    
32 greg 1.1 int expand = 0; /* boolean true to expand commands */
33    
34 greg 1.13 char *newmod = NULL; /* new modifier for surfaces */
35    
36 greg 1.1 char *idprefix = NULL; /* prefix for object identifiers */
37    
38 greg 2.6 #define ALIAS NUMOTYPE /* put alias at end of array */
39 greg 1.1
40 greg 2.6 #define NUMTYPES (NUMOTYPE+1) /* total number of object types */
41 greg 1.1
42 greg 1.11 FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */
43 greg 1.1
44 greg 1.16 short tinvers[NUMOTYPE]; /* inverse types for surfaces */
45    
46 greg 1.15 extern char *malloc(), *fgetword();
47 greg 1.1
48 greg 2.6 #define progname (xav[0])
49 greg 1.1
50    
51     main(argc, argv) /* get transform options and transform file */
52     int argc;
53     char *argv[];
54     {
55     FILE *fopen();
56     FILE *fp;
57     int a;
58 greg 1.8 /* check for array */
59     for (a = 1; a < argc; a++)
60     if (!strcmp(argv[a], "-a"))
61     return(doarray(argc, argv, a));
62 greg 1.1
63 greg 1.11 initotypes();
64    
65 greg 1.1 for (a = 1; a < argc; a++) {
66     if (argv[a][0] == '-')
67     switch (argv[a][1]) {
68 greg 1.13 case 'm':
69     if (argv[a][2] || a+1 >= argc)
70     break;
71     newmod = argv[++a];
72     continue;
73 greg 1.1 case 'n':
74 greg 1.9 if (argv[a][2] || a+1 >= argc)
75     break;
76 greg 1.1 idprefix = argv[++a];
77     continue;
78     case 'e':
79 greg 1.9 if (argv[a][2])
80     break;
81 greg 1.1 expand = 1;
82     continue;
83 greg 1.16 case 'I':
84     if (argv[a][2])
85     break;
86     invert = 1;
87     continue;
88 greg 1.1 }
89     break;
90     }
91    
92 greg 1.8 xav = argv;
93 greg 1.1 xfa = a;
94    
95 greg 1.12 a += xf(&tot, argc-a, argv+a);
96 greg 1.1
97 greg 1.12 if (reverse = tot.sca < 0.0)
98     tot.sca = -tot.sca;
99 greg 1.16 if (invert)
100     reverse = !reverse;
101 greg 1.1
102 greg 1.9 if (a < argc && argv[a][0] == '-') {
103     fprintf(stderr, "%s: command line error at '%s'\n",
104     argv[0], argv[a]);
105     exit(1);
106     }
107 greg 1.10
108 greg 1.1 xac = a;
109 greg 1.10 /* simple header */
110     putchar('#');
111 greg 1.1 for (a = 0; a < xac; a++)
112     printf(" %s", xav[a]);
113     putchar('\n');
114 greg 1.10 /* transform input */
115     if (xac == argc)
116 greg 1.1 xform("standard input", stdin);
117     else
118 greg 1.10 for (a = xac; a < argc; a++) {
119 greg 1.1 if ((fp = fopen(argv[a], "r")) == NULL) {
120     fprintf(stderr, "%s: cannot open \"%s\"\n",
121     progname, argv[a]);
122     exit(1);
123     }
124     xform(argv[a], fp);
125     fclose(fp);
126     }
127    
128 greg 1.8 return(0);
129     }
130    
131    
132     doarray(ac, av, ai) /* make array */
133     char **av;
134     int ac, ai;
135     {
136     char *newav[256], **avp;
137     char newid[128], repts[32];
138     char *oldid = NULL;
139     int i, err;
140    
141     avp = newav+2;
142     avp[0] = av[0];
143     for (i = 1; i < ac; i++)
144     if (!strcmp(av[i-1], "-n")) {
145     oldid = av[i];
146     avp[i] = newid;
147     } else
148     avp[i] = av[i];
149     avp[ai] = "-i";
150     avp[ai+1] = repts;
151     avp[i] = NULL;
152     if (oldid == NULL) {
153     newav[0] = av[0];
154     newav[1] = "-n";
155     newav[2] = newid;
156     avp = newav;
157     ac += 2;
158     }
159     err = 0;
160     for (i = 0; i < atoi(av[ai+1]); i++) {
161     if (oldid == NULL)
162     sprintf(newid, "a%d", i);
163     else
164     sprintf(newid, "%s.%d", oldid, i);
165     sprintf(repts, "%d", i);
166     err |= main(ac, avp);
167     }
168     return(err);
169 greg 1.1 }
170    
171    
172 greg 1.12 xform(name, fin) /* transform stream by tot.xfm */
173 greg 1.1 char *name;
174     register FILE *fin;
175     {
176     register int c;
177    
178     while ((c = getc(fin)) != EOF) {
179     if (isspace(c)) /* blank */
180     continue;
181     if (c == '#') { /* comment */
182     putchar(c);
183     do {
184     if ((c = getc(fin)) == EOF)
185     return;
186     putchar(c);
187     } while (c != '\n');
188     } else if (c == '!') { /* command */
189     ungetc(c, fin);
190 greg 1.7 xfcomm(name, fin);
191 greg 1.1 } else { /* object */
192     ungetc(c, fin);
193     xfobject(name, fin);
194     }
195     }
196     }
197    
198    
199 greg 1.7 xfcomm(fname, fin) /* transform a command */
200 greg 2.6 char *fname;
201 greg 1.1 FILE *fin;
202     {
203     FILE *popen();
204 greg 1.7 char *fgetline();
205 greg 1.1 FILE *pin;
206     char buf[512];
207 greg 1.7 int i;
208 greg 1.1
209 greg 1.7 fgetline(buf, sizeof(buf), fin);
210     if (expand) {
211 greg 2.4 if ((pin = popen(buf+1, "r")) == NULL) {
212     fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n",
213     progname, fname, buf);
214     exit(1);
215 greg 1.7 }
216 greg 2.4 xform(buf, pin);
217     pclose(pin);
218 greg 1.7 } else {
219 greg 1.10 printf("\n%s", buf);
220     if (xac > 1) {
221     printf(" | %s -e", xav[0]);
222     for (i = 1; i < xac; i++)
223     printf(" %s", xav[i]);
224     }
225 greg 1.7 putchar('\n');
226 greg 1.1 }
227     }
228    
229    
230     xfobject(fname, fin) /* transform an object */
231     char *fname;
232     FILE *fin;
233     {
234 greg 1.16 extern char *strcpy();
235 greg 1.13 char typ[16], nam[MAXSTR];
236 greg 1.1 int fn;
237 greg 1.13 /* modifier and type */
238 greg 1.15 strcpy(typ, "EOF");
239     fgetword(nam, sizeof(nam), fin);
240     fgetword(typ, sizeof(typ), fin);
241 greg 1.13 if ((fn = otype(typ)) < 0) {
242 greg 1.1 fprintf(stderr, "%s: (%s): unknown object type \"%s\"\n",
243 greg 1.13 progname, fname, typ);
244 greg 1.1 exit(1);
245     }
246 greg 2.3 if (ismodifier(fn))
247     printf("\n%s %s ", nam, typ);
248     else
249 greg 1.16 printf("\n%s %s ", newmod != NULL ? newmod : nam,
250     invert ? ofun[tinvers[fn]].funame : typ);
251 greg 1.13 /* object name */
252 greg 1.15 fgetword(nam, sizeof(nam), fin);
253 greg 2.3 if (idprefix == NULL || ismodifier(fn))
254     printf("%s\n", nam);
255     else
256 greg 1.13 printf("%s.%s\n", idprefix, nam);
257     /* transform arguments */
258 greg 1.1 if ((*ofun[fn].funp)(fin) < 0) {
259     fprintf(stderr, "%s: (%s): bad %s \"%s\"\n",
260 greg 1.13 progname, fname, ofun[fn].funame, nam);
261 greg 1.1 exit(1);
262     }
263     }
264    
265    
266 greg 1.11 o_default(fin) /* pass on arguments unchanged */
267 greg 1.1 FILE *fin;
268     {
269     register int i;
270 greg 2.6 FUNARGS fa;
271 greg 1.1
272 greg 1.15 if (readfargs(&fa, fin) != 1)
273 greg 1.1 return(-1);
274     /* string arguments */
275 greg 1.14 printf("%d", fa.nsargs);
276     for (i = 0; i < fa.nsargs; i++)
277     printf(" %s", fa.sarg[i]);
278 greg 1.1 printf("\n");
279 greg 2.6 #ifdef IARGS
280 greg 1.1 /* integer arguments */
281 greg 1.14 printf("%d", fa.niargs);
282     for (i = 0; i < fa.niargs; i++)
283     printf(" %d", fa.iarg[i]);
284 greg 1.1 printf("\n");
285 greg 1.15 #else
286     printf("0\n");
287 greg 1.14 #endif
288 greg 1.1 /* float arguments */
289 greg 1.14 printf("%d", fa.nfargs);
290     for (i = 0; i < fa.nfargs; i++)
291     printf(" %18.12g", fa.farg[i]);
292 greg 1.1 printf("\n");
293 greg 1.14 freefargs(&fa);
294 greg 1.1 return(0);
295     }
296    
297    
298     addxform(fin) /* add xf arguments to strings */
299     FILE *fin;
300     {
301     register int i;
302 greg 2.2 int resetarr = 0;
303 greg 2.6 FUNARGS fa;
304 greg 1.1
305 greg 1.15 if (readfargs(&fa, fin) != 1)
306 greg 1.1 return(-1);
307     /* string arguments */
308 greg 2.2 if (xac > xfa && strcmp(xav[xfa], "-i"))
309     resetarr = 2;
310     printf("%d", fa.nsargs + resetarr + xac-xfa);
311 greg 1.14 for (i = 0; i < fa.nsargs; i++)
312     printf(" %s", fa.sarg[i]);
313 greg 2.2 if (resetarr)
314     printf(" -i 1");
315 greg 1.1 for (i = xfa; i < xac; i++) /* add xf arguments */
316     printf(" %s", xav[i]);
317     printf("\n");
318 greg 2.6 #ifdef IARGS
319 greg 1.1 /* integer arguments */
320 greg 1.14 printf("%d", fa.niargs);
321     for (i = 0; i < fa.niargs; i++)
322     printf(" %d", fa.iarg[i]);
323 greg 1.1 printf("\n");
324 greg 1.15 #else
325     printf("0\n");
326 greg 1.14 #endif
327 greg 1.1 /* float arguments */
328 greg 1.14 printf("%d", fa.nfargs);
329     for (i = 0; i < fa.nfargs; i++)
330     printf(" %18.12g", fa.farg[i]);
331 greg 1.1 printf("\n");
332 greg 1.14 freefargs(&fa);
333 greg 1.1 return(0);
334     }
335    
336    
337     int
338     otype(ofname) /* get object function number from its name */
339     register char *ofname;
340     {
341     register int i;
342    
343 greg 1.11 for (i = 0; i < NUMTYPES; i++)
344 greg 1.1 if (!strcmp(ofun[i].funame, ofname))
345     return(i);
346    
347     return(-1); /* not found */
348     }
349    
350    
351     alias(fin) /* transfer alias */
352     FILE *fin;
353     {
354 greg 1.12 char aliasnm[MAXSTR];
355 greg 1.1
356 greg 1.15 if (fgetword(aliasnm, MAXSTR, fin) == NULL)
357 greg 1.1 return(-1);
358 greg 1.12 printf("\t%s\n", aliasnm);
359 greg 1.5 return(0);
360     }
361    
362    
363     m_glow(fin) /* transform arguments for proximity light */
364     FILE *fin;
365     {
366 greg 2.6 FUNARGS fa;
367 greg 1.5
368 greg 1.15 if (readfargs(&fa, fin) != 1)
369 greg 1.5 return(-1);
370 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 4)
371 greg 1.5 return(-1);
372     printf("0\n0\n4");
373     printf(" %18.12g %18.12g %18.12g",
374 greg 1.14 fa.farg[0], fa.farg[1], fa.farg[2]);
375     printf(" %18.12g\n", fa.farg[3] * tot.sca);
376     freefargs(&fa);
377 greg 1.5 return(0);
378     }
379    
380    
381     m_spot(fin) /* transform arguments for spotlight */
382     FILE *fin;
383     {
384 greg 1.17 FVECT v;
385 greg 2.6 FUNARGS fa;
386 greg 1.5
387 greg 1.15 if (readfargs(&fa, fin) != 1)
388 greg 1.5 return(-1);
389 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 7)
390 greg 1.5 return(-1);
391     printf("0\n0\n7");
392     printf(" %18.12g %18.12g %18.12g %18.12g\n",
393 greg 1.14 fa.farg[0], fa.farg[1], fa.farg[2], fa.farg[3]);
394     multv3(v, fa.farg+4, tot.xfm);
395 greg 1.5 printf("\t%18.12g %18.12g %18.12g\n", v[0], v[1], v[2]);
396 greg 1.14 freefargs(&fa);
397 greg 1.1 return(0);
398     }
399    
400    
401     m_dielectric(fin) /* transform arguments for dielectric */
402     FILE *fin;
403     {
404 greg 2.6 double pow();
405     FUNARGS fa;
406 greg 1.1
407 greg 1.15 if (readfargs(&fa, fin) != 1)
408 greg 1.1 return(-1);
409 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 5)
410 greg 1.1 return(-1);
411     printf("0\n0\n5");
412     printf(" %18.12g %18.12g %18.12g",
413 greg 1.14 pow(fa.farg[0], 1.0/tot.sca),
414     pow(fa.farg[1], 1.0/tot.sca),
415     pow(fa.farg[2], 1.0/tot.sca));
416     printf(" %18.12g %18.12g\n", fa.farg[3], fa.farg[4]);
417     freefargs(&fa);
418 greg 1.1 return(0);
419     }
420    
421    
422     m_interface(fin) /* transform arguments for interface */
423     FILE *fin;
424     {
425 greg 2.6 double pow();
426     FUNARGS fa;
427 greg 1.1
428 greg 1.15 if (readfargs(&fa, fin) != 1)
429 greg 1.1 return(-1);
430 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 8)
431 greg 1.1 return(-1);
432     printf("0\n0\n8\n");
433     printf("%18.12g %18.12g %18.12g",
434 greg 1.14 pow(fa.farg[0], 1.0/tot.sca),
435     pow(fa.farg[1], 1.0/tot.sca),
436     pow(fa.farg[2], 1.0/tot.sca));
437     printf(" %18.12g\n", fa.farg[3]);
438 greg 1.1 printf("%18.12g %18.12g %18.12g",
439 greg 1.14 pow(fa.farg[4], 1.0/tot.sca),
440     pow(fa.farg[5], 1.0/tot.sca),
441     pow(fa.farg[6], 1.0/tot.sca));
442     printf(" %18.12g\n", fa.farg[7]);
443     freefargs(&fa);
444 greg 1.1 return(0);
445     }
446    
447    
448     text(fin) /* transform text arguments */
449     FILE *fin;
450     {
451     int i;
452 greg 1.17 FVECT v;
453 greg 2.6 FUNARGS fa;
454 greg 1.1
455 greg 1.15 if (readfargs(&fa, fin) != 1)
456 greg 1.1 return(-1);
457 greg 2.5 if (fa.nfargs < 9)
458 greg 1.1 return(-1);
459     /* string arguments */
460 greg 1.14 printf("%d", fa.nsargs);
461     for (i = 0; i < fa.nsargs; i++)
462     printf(" %s", fa.sarg[i]);
463     printf("\n0\n%d\n", fa.nfargs);
464 greg 1.1 /* anchor point */
465 greg 1.14 multp3(v, fa.farg, tot.xfm);
466 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]);
467     /* right vector */
468 greg 1.14 multv3(v, fa.farg+3, tot.xfm);
469 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]);
470     /* down vector */
471 greg 1.14 multv3(v, fa.farg+6, tot.xfm);
472 greg 2.5 printf(" %18.12g %18.12g %18.12g", v[0], v[1], v[2]);
473     /* remaining arguments */
474     for (i = 9; i < fa.nfargs; i++) {
475     if (i%3 == 0)
476     putchar('\n');
477     printf(" %18.12g", fa.farg[i]);
478 greg 1.1 }
479 greg 2.5 putchar('\n');
480 greg 1.14 freefargs(&fa);
481 greg 1.1 return(0);
482     }
483    
484    
485     o_source(fin) /* transform source arguments */
486     FILE *fin;
487     {
488 greg 1.17 FVECT dv;
489 greg 2.6 FUNARGS fa;
490 greg 1.1
491 greg 1.15 if (readfargs(&fa, fin) != 1)
492 greg 1.1 return(-1);
493 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 4)
494 greg 1.1 return(-1);
495     /* transform direction vector */
496 greg 1.14 multv3(dv, fa.farg, tot.xfm);
497 greg 1.1 /* output */
498     printf("0\n0\n4");
499     printf(" %18.12g %18.12g %18.12g %18.12g\n",
500 greg 1.14 dv[0], dv[1], dv[2], fa.farg[3]);
501     freefargs(&fa);
502 greg 1.1 return(0);
503     }
504    
505    
506     o_sphere(fin) /* transform sphere arguments */
507     FILE *fin;
508     {
509 greg 1.17 FVECT cent;
510 greg 2.6 double rad;
511     FUNARGS fa;
512 greg 1.1
513 greg 1.15 if (readfargs(&fa, fin) != 1)
514 greg 1.1 return(-1);
515 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 4)
516 greg 1.1 return(-1);
517    
518 greg 2.6 multp3(cent, fa.farg, tot.xfm); /* transform center */
519 greg 1.1
520 greg 1.14 rad = fa.farg[3] * tot.sca; /* scale radius */
521 greg 1.1
522     printf("0\n0\n4");
523     printf(" %18.12g %18.12g %18.12g %18.12g\n",
524     cent[0], cent[1], cent[2], rad);
525 greg 1.14 freefargs(&fa);
526 greg 1.1 return(0);
527     }
528    
529    
530     o_face(fin) /* transform face arguments */
531     FILE *fin;
532     {
533 greg 1.17 FVECT p;
534 greg 1.1 register int i;
535 greg 2.6 FUNARGS fa;
536 greg 1.1
537 greg 1.15 if (readfargs(&fa, fin) != 1)
538 greg 1.1 return(-1);
539 greg 1.14 if (fa.nsargs != 0 || fa.nfargs % 3)
540 greg 1.1 return(-1);
541    
542 greg 1.14 printf("0\n0\n%d\n", fa.nfargs);
543 greg 1.1
544 greg 1.14 for (i = 0; i < fa.nfargs; i += 3) {
545 greg 1.1 if (reverse)
546 greg 1.14 multp3(p, fa.farg+(fa.nfargs-i-3), tot.xfm);
547 greg 1.1 else
548 greg 1.14 multp3(p, fa.farg+i, tot.xfm);
549 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", p[0], p[1], p[2]);
550     }
551 greg 1.14 freefargs(&fa);
552 greg 1.1 return(0);
553     }
554    
555    
556     o_cone(fin) /* transform cone and cup arguments */
557     FILE *fin;
558     {
559 greg 1.17 FVECT p0, p1;
560 greg 2.6 double r0, r1;
561     FUNARGS fa;
562 greg 1.1
563 greg 1.15 if (readfargs(&fa, fin) != 1)
564 greg 1.1 return(-1);
565 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 8)
566 greg 1.1 return(-1);
567    
568     printf("0\n0\n8\n");
569    
570 greg 1.14 multp3(p0, fa.farg, tot.xfm);
571     multp3(p1, fa.farg+3, tot.xfm);
572     r0 = fa.farg[6] * tot.sca;
573     r1 = fa.farg[7] * tot.sca;
574 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
575     printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]);
576     printf(" %18.12g %18.12g\n", r0, r1);
577    
578 greg 1.14 freefargs(&fa);
579 greg 1.1 return(0);
580     }
581    
582    
583     o_cylinder(fin) /* transform cylinder and tube arguments */
584     FILE *fin;
585     {
586 greg 1.17 FVECT p0, p1;
587 greg 2.6 double rad;
588     FUNARGS fa;
589 greg 1.1
590 greg 1.15 if (readfargs(&fa, fin) != 1)
591 greg 1.1 return(-1);
592 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 7)
593 greg 1.1 return(-1);
594    
595     printf("0\n0\n7\n");
596    
597 greg 1.14 multp3(p0, fa.farg, tot.xfm);
598     multp3(p1, fa.farg+3, tot.xfm);
599     rad = fa.farg[6] * tot.sca;
600 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
601     printf(" %18.12g %18.12g %18.12g\n", p1[0], p1[1], p1[2]);
602     printf(" %18.12g\n", rad);
603 greg 1.14 freefargs(&fa);
604 greg 1.1 return(0);
605     }
606    
607    
608     o_ring(fin) /* transform ring arguments */
609     FILE *fin;
610     {
611 greg 1.17 FVECT p0, pd;
612 greg 2.6 double r0, r1;
613     FUNARGS fa;
614 greg 1.1
615 greg 1.15 if (readfargs(&fa, fin) != 1)
616 greg 1.1 return(-1);
617 greg 1.14 if (fa.nsargs != 0 || fa.nfargs != 8)
618 greg 1.1 return(-1);
619    
620     printf("0\n0\n8\n");
621    
622 greg 1.14 multp3(p0, fa.farg, tot.xfm);
623     multv3(pd, fa.farg+3, tot.xfm);
624 greg 1.16 if (invert) {
625     pd[0] = -pd[0];
626     pd[1] = -pd[1];
627     pd[2] = -pd[2];
628     }
629 greg 1.14 r0 = fa.farg[6] * tot.sca;
630     r1 = fa.farg[7] * tot.sca;
631 greg 1.1 printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
632     printf(" %18.12g %18.12g %18.12g\n", pd[0], pd[1], pd[2]);
633     printf(" %18.12g %18.12g\n", r0, r1);
634 greg 1.14 freefargs(&fa);
635 greg 1.1 return(0);
636 greg 1.11 }
637    
638    
639     initotypes() /* initialize ofun[] array */
640     {
641     extern int o_source();
642     extern int o_sphere();
643     extern int o_face();
644     extern int o_cone();
645     extern int o_cylinder();
646     extern int o_ring();
647     extern int m_glow();
648     extern int m_spot();
649     extern int m_dielectric();
650     extern int m_interface();
651     extern int text();
652     extern int alias();
653     extern int passargs();
654     extern int addxform();
655     register int i;
656    
657     if (ofun[OBJ_SOURCE].funp == o_source)
658     return; /* done already */
659     /* alias is additional */
660     ofun[ALIAS].funame = ALIASID;
661     ofun[ALIAS].flags = 0;
662     /* functions get new transform */
663     for (i = 0; i < NUMTYPES; i++)
664     if (hasfunc(i))
665     ofun[i].funp = addxform;
666     /* special cases */
667     ofun[OBJ_SOURCE].funp = o_source;
668     ofun[OBJ_SPHERE].funp =
669     ofun[OBJ_BUBBLE].funp = o_sphere;
670     ofun[OBJ_FACE].funp = o_face;
671     ofun[OBJ_CONE].funp =
672     ofun[OBJ_CUP].funp = o_cone;
673     ofun[OBJ_CYLINDER].funp =
674     ofun[OBJ_TUBE].funp = o_cylinder;
675     ofun[OBJ_RING].funp = o_ring;
676     ofun[OBJ_INSTANCE].funp = addxform;
677     ofun[MAT_GLOW].funp = m_glow;
678     ofun[MAT_SPOT].funp = m_spot;
679     ofun[MAT_DIELECTRIC].funp = m_dielectric;
680     ofun[MAT_INTERFACE].funp = m_interface;
681     ofun[PAT_CTEXT].funp =
682     ofun[PAT_BTEXT].funp =
683     ofun[MIX_TEXT].funp = text;
684     ofun[ALIAS].funp = alias;
685 greg 1.16 /* surface inverses */
686     tinvers[OBJ_SOURCE] = OBJ_SOURCE;
687     tinvers[OBJ_CONE] = OBJ_CUP;
688     tinvers[OBJ_CUP] = OBJ_CONE;
689     tinvers[OBJ_SPHERE] = OBJ_BUBBLE;
690     tinvers[OBJ_BUBBLE] = OBJ_SPHERE;
691     tinvers[OBJ_RING] = OBJ_RING;
692     tinvers[OBJ_CYLINDER] = OBJ_TUBE;
693     tinvers[OBJ_TUBE] = OBJ_CYLINDER;
694     tinvers[OBJ_INSTANCE] = OBJ_INSTANCE; /* oh, well */
695 greg 1.1 }