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.3 by greg, Thu Mar 12 11:43:58 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 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 (ismodifier(fn))
252 >                printf("\n%s %s ", nam, typ);
253 >        else
254 >                printf("\n%s %s ", newmod != NULL ? newmod : nam,
255 >                                invert ? ofun[tinvers[fn]].funame : typ);
256                                                  /* object name */
257          fgetword(nam, sizeof(nam), fin);
258 <        if (idprefix != NULL && issurface(fn))
243 <                printf("%s.%s\n", idprefix, nam);
244 <        else
258 >        if (idprefix == NULL || ismodifier(fn))
259                  printf("%s\n", nam);
260 +        else
261 +                printf("%s.%s\n", idprefix, nam);
262                                                  /* transform arguments */
263          if ((*ofun[fn].funp)(fin) < 0) {
264                  fprintf(stderr, "%s: (%s): bad %s \"%s\"\n",
# Line 288 | Line 304 | addxform(fin)                  /* add xf arguments to strings */
304   FILE  *fin;
305   {
306          register int  i;
307 +        int  resetarr = 0;
308          FUNARGS  fa;
309  
310          if (readfargs(&fa, fin) != 1)
311                  return(-1);
312                                          /* string arguments */
313 <        printf("%d", fa.nsargs + xac-xfa);
313 >        if (xac > xfa && strcmp(xav[xfa], "-i"))
314 >                resetarr = 2;
315 >        printf("%d", fa.nsargs + resetarr + xac-xfa);
316          for (i = 0; i < fa.nsargs; i++)
317                  printf(" %s", fa.sarg[i]);
318 +        if (resetarr)
319 +                printf(" -i 1");
320          for (i = xfa; i < xac; i++)     /* add xf arguments */
321                  printf(" %s", xav[i]);
322          printf("\n");
# Line 365 | Line 386 | FILE  *fin;
386   m_spot(fin)                     /* transform arguments for spotlight */
387   FILE  *fin;
388   {
389 <        double  v[3];
389 >        FVECT  v;
390          FUNARGS  fa;
391  
392          if (readfargs(&fa, fin) != 1)
# Line 433 | Line 454 | text(fin)                      /* transform text arguments */
454   FILE  *fin;
455   {
456          int  i;
457 <        double  v[3];
457 >        FVECT  v;
458          FUNARGS  fa;
459  
460          if (readfargs(&fa, fin) != 1)
# Line 471 | Line 492 | FILE  *fin;
492   o_source(fin)                   /* transform source arguments */
493   FILE  *fin;
494   {
495 <        double  dv[3];
495 >        FVECT  dv;
496          FUNARGS  fa;
497  
498          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 513 | FILE  *fin;
513   o_sphere(fin)                   /* transform sphere arguments */
514   FILE  *fin;
515   {
516 <        double  cent[3], rad;
516 >        FVECT  cent;
517 >        double  rad;
518          FUNARGS  fa;
519  
520          if (readfargs(&fa, fin) != 1)
# Line 515 | Line 537 | FILE  *fin;
537   o_face(fin)                     /* transform face arguments */
538   FILE  *fin;
539   {
540 <        double  p[3];
540 >        FVECT  p;
541          register int  i;
542          FUNARGS  fa;
543  
# Line 541 | Line 563 | FILE  *fin;
563   o_cone(fin)                     /* transform cone and cup arguments */
564   FILE  *fin;
565   {
566 <        double  p0[3], p1[3], r0, r1;
566 >        FVECT  p0, p1;
567 >        double  r0, r1;
568          FUNARGS  fa;
569  
570          if (readfargs(&fa, fin) != 1)
# Line 567 | Line 590 | FILE  *fin;
590   o_cylinder(fin)                 /* transform cylinder and tube arguments */
591   FILE  *fin;
592   {
593 <        double  p0[3], p1[3], rad;
593 >        FVECT  p0, p1;
594 >        double  rad;
595          FUNARGS  fa;
596  
597          if (readfargs(&fa, fin) != 1)
# Line 591 | Line 615 | FILE  *fin;
615   o_ring(fin)                     /* transform ring arguments */
616   FILE  *fin;
617   {
618 <        double  p0[3], pd[3], r0, r1;
618 >        FVECT  p0, pd;
619 >        double  r0, r1;
620          FUNARGS  fa;
621  
622          if (readfargs(&fa, fin) != 1)
# Line 603 | Line 628 | FILE  *fin;
628  
629          multp3(p0, fa.farg, tot.xfm);
630          multv3(pd, fa.farg+3, tot.xfm);
631 +        if (invert) {
632 +                pd[0] = -pd[0];
633 +                pd[1] = -pd[1];
634 +                pd[2] = -pd[2];
635 +        }
636          r0 = fa.farg[6] * tot.sca;
637          r1 = fa.farg[7] * tot.sca;
638          printf(" %18.12g %18.12g %18.12g\n", p0[0], p0[1], p0[2]);
# Line 659 | Line 689 | initotypes()                   /* initialize ofun[] array */
689          ofun[PAT_BTEXT].funp =
690          ofun[MIX_TEXT].funp = text;
691          ofun[ALIAS].funp = alias;
692 +                                        /* surface inverses */
693 +        tinvers[OBJ_SOURCE] = OBJ_SOURCE;
694 +        tinvers[OBJ_CONE] = OBJ_CUP;
695 +        tinvers[OBJ_CUP] = OBJ_CONE;
696 +        tinvers[OBJ_SPHERE] = OBJ_BUBBLE;
697 +        tinvers[OBJ_BUBBLE] = OBJ_SPHERE;
698 +        tinvers[OBJ_RING] = OBJ_RING;
699 +        tinvers[OBJ_CYLINDER] = OBJ_TUBE;
700 +        tinvers[OBJ_TUBE] = OBJ_CYLINDER;
701 +        tinvers[OBJ_INSTANCE] = OBJ_INSTANCE;   /* oh, well */
702   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines