ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/xform.c
(Generate patch)

Comparing ray/src/gen/xform.c (file contents):
Revision 1.15 by greg, Tue Jul 23 15:24:21 1991 UTC vs.
Revision 2.4 by greg, Thu May 28 12:33:20 1992 UTC

# Line 25 | Line 25 | char  **xav;                           /* global xform argument pointer */
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 */
# Line 39 | Line 41 | char  *idprefix = NULL;                        /* prefix for object identif
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])
# Line 76 | Line 80 | char  *argv[];
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          }
# Line 87 | Line 96 | char  *argv[];
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",
# Line 196 | Line 207 | FILE  *fin;
207  
208          fgetline(buf, sizeof(buf), fin);
209          if (expand) {
210 <                if (xac > 2) {
211 <                        if ((pin = popen(buf+1, "r")) == NULL) {
212 <                                fprintf(stderr,
213 <                                "%s: (%s): cannot execute \"%s\"\n",
203 <                                                progname, fname, buf);
204 <                                exit(1);
205 <                        }
206 <                        xform(buf, pin);
207 <                        pclose(pin);
208 <                } else {
209 <                        fflush(stdout);
210 <                        system(buf+1);
210 >                if ((pin = popen(buf+1, "r")) == NULL) {
211 >                        fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n",
212 >                                        progname, fname, buf);
213 >                        exit(1);
214                  }
215 +                xform(buf, pin);
216 +                pclose(pin);
217          } else {
218                  printf("\n%s", buf);
219                  if (xac > 1) {
# Line 225 | Line 230 | xfobject(fname, fin)                           /* transform an object */
230   char  *fname;
231   FILE  *fin;
232   {
233 +        extern char  *strcpy();
234          char  typ[16], nam[MAXSTR];
235          int  fn;
236                                                  /* modifier and type */
# Line 236 | Line 242 | FILE  *fin;
242                                  progname, fname, typ);
243                  exit(1);
244          }
245 <        printf("\n%s %s ", newmod!=NULL && issurface(fn) ? newmod : nam, typ);
245 >        if (ismodifier(fn))
246 >                printf("\n%s %s ", nam, typ);
247 >        else
248 >                printf("\n%s %s ", newmod != NULL ? newmod : nam,
249 >                                invert ? ofun[tinvers[fn]].funame : typ);
250                                                  /* object name */
251          fgetword(nam, sizeof(nam), fin);
252 <        if (idprefix != NULL && issurface(fn))
243 <                printf("%s.%s\n", idprefix, nam);
244 <        else
252 >        if (idprefix == NULL || ismodifier(fn))
253                  printf("%s\n", nam);
254 +        else
255 +                printf("%s.%s\n", idprefix, nam);
256                                                  /* transform arguments */
257          if ((*ofun[fn].funp)(fin) < 0) {
258                  fprintf(stderr, "%s: (%s): bad %s \"%s\"\n",
# Line 288 | Line 298 | addxform(fin)                  /* add xf arguments to strings */
298   FILE  *fin;
299   {
300          register int  i;
301 +        int  resetarr = 0;
302          FUNARGS  fa;
303  
304          if (readfargs(&fa, fin) != 1)
305                  return(-1);
306                                          /* string arguments */
307 <        printf("%d", fa.nsargs + xac-xfa);
307 >        if (xac > xfa && strcmp(xav[xfa], "-i"))
308 >                resetarr = 2;
309 >        printf("%d", fa.nsargs + resetarr + xac-xfa);
310          for (i = 0; i < fa.nsargs; i++)
311                  printf(" %s", fa.sarg[i]);
312 +        if (resetarr)
313 +                printf(" -i 1");
314          for (i = xfa; i < xac; i++)     /* add xf arguments */
315                  printf(" %s", xav[i]);
316          printf("\n");
# Line 365 | Line 380 | FILE  *fin;
380   m_spot(fin)                     /* transform arguments for spotlight */
381   FILE  *fin;
382   {
383 <        double  v[3];
383 >        FVECT  v;
384          FUNARGS  fa;
385  
386          if (readfargs(&fa, fin) != 1)
# Line 433 | Line 448 | text(fin)                      /* transform text arguments */
448   FILE  *fin;
449   {
450          int  i;
451 <        double  v[3];
451 >        FVECT  v;
452          FUNARGS  fa;
453  
454          if (readfargs(&fa, fin) != 1)
# Line 471 | Line 486 | FILE  *fin;
486   o_source(fin)                   /* transform source arguments */
487   FILE  *fin;
488   {
489 <        double  dv[3];
489 >        FVECT  dv;
490          FUNARGS  fa;
491  
492          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 507 | FILE  *fin;
507   o_sphere(fin)                   /* transform sphere arguments */
508   FILE  *fin;
509   {
510 <        double  cent[3], rad;
510 >        FVECT  cent;
511 >        double  rad;
512          FUNARGS  fa;
513  
514          if (readfargs(&fa, fin) != 1)
# Line 515 | Line 531 | FILE  *fin;
531   o_face(fin)                     /* transform face arguments */
532   FILE  *fin;
533   {
534 <        double  p[3];
534 >        FVECT  p;
535          register int  i;
536          FUNARGS  fa;
537  
# Line 541 | Line 557 | FILE  *fin;
557   o_cone(fin)                     /* transform cone and cup arguments */
558   FILE  *fin;
559   {
560 <        double  p0[3], p1[3], r0, r1;
560 >        FVECT  p0, p1;
561 >        double  r0, r1;
562          FUNARGS  fa;
563  
564          if (readfargs(&fa, fin) != 1)
# Line 567 | Line 584 | FILE  *fin;
584   o_cylinder(fin)                 /* transform cylinder and tube arguments */
585   FILE  *fin;
586   {
587 <        double  p0[3], p1[3], rad;
587 >        FVECT  p0, p1;
588 >        double  rad;
589          FUNARGS  fa;
590  
591          if (readfargs(&fa, fin) != 1)
# Line 591 | Line 609 | FILE  *fin;
609   o_ring(fin)                     /* transform ring arguments */
610   FILE  *fin;
611   {
612 <        double  p0[3], pd[3], r0, r1;
612 >        FVECT  p0, pd;
613 >        double  r0, r1;
614          FUNARGS  fa;
615  
616          if (readfargs(&fa, fin) != 1)
# Line 603 | Line 622 | FILE  *fin;
622  
623          multp3(p0, fa.farg, tot.xfm);
624          multv3(pd, fa.farg+3, tot.xfm);
625 +        if (invert) {
626 +                pd[0] = -pd[0];
627 +                pd[1] = -pd[1];
628 +                pd[2] = -pd[2];
629 +        }
630          r0 = fa.farg[6] * tot.sca;
631          r1 = fa.farg[7] * tot.sca;
632          printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
# Line 659 | Line 683 | initotypes()                   /* initialize ofun[] array */
683          ofun[PAT_BTEXT].funp =
684          ofun[MIX_TEXT].funp = text;
685          ofun[ALIAS].funp = alias;
686 +                                        /* surface inverses */
687 +        tinvers[OBJ_SOURCE] = OBJ_SOURCE;
688 +        tinvers[OBJ_CONE] = OBJ_CUP;
689 +        tinvers[OBJ_CUP] = OBJ_CONE;
690 +        tinvers[OBJ_SPHERE] = OBJ_BUBBLE;
691 +        tinvers[OBJ_BUBBLE] = OBJ_SPHERE;
692 +        tinvers[OBJ_RING] = OBJ_RING;
693 +        tinvers[OBJ_CYLINDER] = OBJ_TUBE;
694 +        tinvers[OBJ_TUBE] = OBJ_CYLINDER;
695 +        tinvers[OBJ_INSTANCE] = OBJ_INSTANCE;   /* oh, well */
696   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines