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.1 by greg, Tue Nov 12 17:04:57 1991 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 225 | Line 236 | xfobject(fname, fin)                           /* transform an object */
236   char  *fname;
237   FILE  *fin;
238   {
239 +        extern char  *strcpy();
240          char  typ[16], nam[MAXSTR];
241          int  fn;
242                                                  /* modifier and type */
# Line 236 | Line 248 | FILE  *fin;
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))
# Line 365 | Line 381 | FILE  *fin;
381   m_spot(fin)                     /* transform arguments for spotlight */
382   FILE  *fin;
383   {
384 <        double  v[3];
384 >        FVECT  v;
385          FUNARGS  fa;
386  
387          if (readfargs(&fa, fin) != 1)
# Line 433 | Line 449 | text(fin)                      /* transform text arguments */
449   FILE  *fin;
450   {
451          int  i;
452 <        double  v[3];
452 >        FVECT  v;
453          FUNARGS  fa;
454  
455          if (readfargs(&fa, fin) != 1)
# Line 471 | Line 487 | FILE  *fin;
487   o_source(fin)                   /* transform source arguments */
488   FILE  *fin;
489   {
490 <        double  dv[3];
490 >        FVECT  dv;
491          FUNARGS  fa;
492  
493          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 508 | FILE  *fin;
508   o_sphere(fin)                   /* transform sphere arguments */
509   FILE  *fin;
510   {
511 <        double  cent[3], rad;
511 >        FVECT  cent;
512 >        double  rad;
513          FUNARGS  fa;
514  
515          if (readfargs(&fa, fin) != 1)
# Line 515 | Line 532 | FILE  *fin;
532   o_face(fin)                     /* transform face arguments */
533   FILE  *fin;
534   {
535 <        double  p[3];
535 >        FVECT  p;
536          register int  i;
537          FUNARGS  fa;
538  
# Line 541 | Line 558 | FILE  *fin;
558   o_cone(fin)                     /* transform cone and cup arguments */
559   FILE  *fin;
560   {
561 <        double  p0[3], p1[3], r0, r1;
561 >        FVECT  p0, p1;
562 >        double  r0, r1;
563          FUNARGS  fa;
564  
565          if (readfargs(&fa, fin) != 1)
# Line 567 | Line 585 | FILE  *fin;
585   o_cylinder(fin)                 /* transform cylinder and tube arguments */
586   FILE  *fin;
587   {
588 <        double  p0[3], p1[3], rad;
588 >        FVECT  p0, p1;
589 >        double  rad;
590          FUNARGS  fa;
591  
592          if (readfargs(&fa, fin) != 1)
# Line 591 | Line 610 | FILE  *fin;
610   o_ring(fin)                     /* transform ring arguments */
611   FILE  *fin;
612   {
613 <        double  p0[3], pd[3], r0, r1;
613 >        FVECT  p0, pd;
614 >        double  r0, r1;
615          FUNARGS  fa;
616  
617          if (readfargs(&fa, fin) != 1)
# Line 603 | Line 623 | FILE  *fin;
623  
624          multp3(p0, fa.farg, tot.xfm);
625          multv3(pd, fa.farg+3, tot.xfm);
626 +        if (invert) {
627 +                pd[0] = -pd[0];
628 +                pd[1] = -pd[1];
629 +                pd[2] = -pd[2];
630 +        }
631          r0 = fa.farg[6] * tot.sca;
632          r1 = fa.farg[7] * tot.sca;
633          printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
# Line 659 | Line 684 | initotypes()                   /* initialize ofun[] array */
684          ofun[PAT_BTEXT].funp =
685          ofun[MIX_TEXT].funp = text;
686          ofun[ALIAS].funp = alias;
687 +                                        /* surface inverses */
688 +        tinvers[OBJ_SOURCE] = OBJ_SOURCE;
689 +        tinvers[OBJ_CONE] = OBJ_CUP;
690 +        tinvers[OBJ_CUP] = OBJ_CONE;
691 +        tinvers[OBJ_SPHERE] = OBJ_BUBBLE;
692 +        tinvers[OBJ_BUBBLE] = OBJ_SPHERE;
693 +        tinvers[OBJ_RING] = OBJ_RING;
694 +        tinvers[OBJ_CYLINDER] = OBJ_TUBE;
695 +        tinvers[OBJ_TUBE] = OBJ_CYLINDER;
696 +        tinvers[OBJ_INSTANCE] = OBJ_INSTANCE;   /* oh, well */
697   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines