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

Comparing ray/src/cv/nff2rad.c (file contents):
Revision 2.3 by greg, Fri Mar 5 15:16:16 1993 UTC vs.
Revision 2.7 by schorsch, Sat Nov 15 17:54:06 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Convert Neutral File Format input to Radiance scene description.
6   *
# Line 69 | Line 66 | These are explained in depth below:    { see conversion r
66  
67   ***********************************************************************/
68  
69 + #include <stdlib.h>
70   #include <stdio.h>
71 + #include <string.h>
72  
73 + #include "rtmath.h"
74 +
75 + typedef double Flt ;
76 + typedef Flt Vec[3] ;
77 + typedef Vec Point ;
78 + typedef Vec Color ;
79 +
80 + #define VecCopy(a,b)     (b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];
81 + #define         NCOLORS         (738)
82 +
83 + typedef struct t_color_entry {
84 +        char *  ce_name ;
85 +        Vec     ce_color ;
86 + } ColorEntry ;
87 +
88 + #define LESS_THAN -1
89 + #define GREATER_THAN 1
90 + #define EQUAL_TO 0
91 +
92   char    *viewfile = NULL;       /* view parameters file */
93  
94   char    *progname;
95  
96 + void init(void);
97 + void nff2rad(void);
98 + void comment(void);
99 + void view(void);
100 + void light(void);
101 + void background(void);
102 + void fill(void);
103 + void cone(void);
104 + void sphere(void);
105 + void poly(void);
106 + int LookupColorByName(char * name, Vec color);
107 + int BinarySearch(char * name, int l, int h, ColorEntry array[]);
108  
109 < main(argc, argv)                /* convert NFF file to Radiance */
110 < int     argc;
111 < char    *argv[];
109 >
110 > int
111 > main(           /* convert NFF file to Radiance */
112 >        int     argc,
113 >        char    *argv[]
114 > )
115   {
116          int     i;
117          
# Line 105 | Line 138 | userr:
138   }
139  
140  
141 < init()                  /* spit out initial definitions */
141 > void
142 > init(void)                      /* spit out initial definitions */
143   {
144          printf("# File created by %s\n", progname);
145          printf("\nvoid light light\n");
146 <        printf("0\n0\n3 1 1 1\n");
146 >        printf("0\n0\n3 1e6 1e6 1e6\n");
147          printf("\nvoid plastic fill\n");
148          printf("0\n0\n5 .5 .5 .5 0 0\n");
149   }
150  
151  
152 < nff2rad()               /* convert NFF on stdin to Radiance on stdout */
152 > void
153 > nff2rad(void)           /* convert NFF on stdin to Radiance on stdout */
154   {
155          register int    c;
156          
# Line 171 | Line 206 | Format:
206      
207   ******************/
208  
209 < comment()
209 > void
210 > comment(void)
211   {
212          register int    c;
213          
# Line 228 | Line 264 | The parameters are:
264  
265   ***************/
266  
267 < view()
267 > void
268 > view(void)
269   {
270          static FILE     *fp = NULL;
271          float   from[3], at[3], up[3], angle;
# Line 277 | Line 314 | Format:
314  
315   **************************/
316  
317 < light()
317 > void
318 > light(void)
319   {
320          static int      nlights = 0;
321          register int    c;
# Line 290 | Line 328 | light()
328          while ((c = getchar()) != EOF && c != '\n')
329                  ;
330          printf("\nlight sphere l%d \n", ++nlights);
331 <        printf("0\n0\n4 %g %g %g 1\n", x, y, z);
331 >        printf("0\n0\n4 %g %g %g .01\n", x, y, z);
332   }
333  
334  
# Line 306 | Line 344 | Format:
344  
345   ********************/
346  
347 < background()
347 > void
348 > background(void)
349   {
350          float   r, g, b;
351          char colname[50];
# Line 353 | Line 392 | Format:
392  
393   *********************/
394  
395 < fill()
395 > void
396 > fill(void)
397   {
398          float   r, g, b, d, s, p, t, n;
399          char colname[50];
# Line 375 | Line 415 | fill()
415                  fprintf(stderr, "%s: fill material syntax error\n", progname);
416                  exit(1);
417          }
378        d /= 1.-s-t;
379        r *= d;
380        g *= d;
381        b *= d;
418          if (p > 1.)
419                  p = 1./p;
420          if (t > .001) {         /* has transmission */
421 <                printf("\nvoid trans fill\n");
422 <                printf("0\n0\n7 %g %g %g %g 0 %g 1\n", r, g, b, s, t);
421 >                if (n > 1.1) {          /* has index of refraction */
422 >                        printf("\nvoid dielectric fill\n");
423 >                        printf("0\n0\n5 %g %g %g %g 0\n", r, g, b, n);
424 >                } else {                /* transmits w/o refraction */
425 >                        printf("\nvoid trans fill\n");
426 >                        printf("0\n0\n7 %g %g %g %g 0 %g 1\n",
427 >                                        r*d, g*d, b*d, s, t);
428 >                }
429          } else {                /* no transmission */
430                  printf("\nvoid plastic fill\n");
431 <                printf("0\n0\n5 %g %g %g %g %g\n", r, g, b, s, p);
431 >                printf("0\n0\n5 %g %g %g %g %g\n", r*d, g*d, b*d, s, p);
432          }
433   }
434  
# Line 416 | Line 458 | Format:
458  
459   ************************/
460  
461 < cone()
461 > void
462 > cone(void)
463   {
464          static int      ncs = 0;
465          int     invert;
# Line 428 | Line 471 | cone()
471                                  progname);
472                  exit(1);
473          }
474 <        if (invert = r0 < 0.) {
474 >        if ( (invert = r0 < 0.) ) {
475                  r0 = -r0;
476                  r1 = -r1;
477          }
# Line 461 | Line 504 | Format:
504  
505   ******************/
506  
507 < sphere()
507 > void
508 > sphere(void)
509   {
510          static int      nspheres = 0;
511          float   x, y, z, r;
# Line 516 | Line 560 | Format:
560  
561   *******************/
562  
563 < poly()
563 > void
564 > poly(void)
565   {
566          static int      npolys = 0;
567          int     ispatch;
# Line 549 | Line 594 | fmterr:
594   * $Revision$
595   * $Date$
596   * $Log$
597 < * Revision 2.3  1993/03/05 15:16:16  greg
598 < * portability improvements
597 > * Revision 2.7  2003/11/15 17:54:06  schorsch
598 > * Continued ANSIfication and reduced compile warnings.
599   *
600 + * Revision 2.6  2003/07/27 22:12:01  schorsch
601 + * Added grouping parens to reduce ambiguity warnings.
602 + *
603 + * Revision 2.5  2003/02/22 02:07:23  greg
604 + * Changes and check-in for 3.5 release
605 + * Includes new source files and modifications not recorded for many years
606 + * See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release
607 + *
608   * Revision 1.2  88/09/12  12:53:47  markv
609   * Fixed problem in LookupColorbyName, had return ; and return(0).
610   * [ Thank you lint! ]
# Line 565 | Line 618 | fmterr:
618   *
619   ***********************************************************************/
620  
568 typedef double Flt ;
569 typedef Flt Vec[3] ;
570 typedef Vec Point ;
571 typedef Vec Color ;
572
573 #define VecCopy(a,b)     (b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];
574 #define         NCOLORS         (738)
575
576 typedef struct t_color_entry {
577        char *  ce_name ;
578        Vec     ce_color ;
579 } ColorEntry ;
580
581 #define LESS_THAN -1
582 #define GREATER_THAN 1
583 #define EQUAL_TO 0
584
621   /*
622   * Note: These colors must be in sorted order, because we binary search
623   * for them.
# Line 1331 | Line 1367 | ColorEntry Colors[] = {
1367   } ;
1368  
1369   int
1370 < LookupColorByName(name, color)
1371 < char * name ;
1372 < Vec color ;
1370 > LookupColorByName(
1371 >                char * name,
1372 >                Vec color
1373 > )
1374   {
1375          int rc ;
1376          rc = BinarySearch(name, 0, NCOLORS - 1 , Colors) ;
# Line 1347 | Line 1384 | LookupColorByName(name, color)
1384  
1385  
1386   int
1387 < BinarySearch(name, l, h, array)
1388 < char * name ;
1389 < int l, h ;
1390 < ColorEntry array[] ;
1387 > BinarySearch(
1388 >        char * name,
1389 >        int l,
1390 >        int h,
1391 >        ColorEntry array[]
1392 > )
1393   {
1394          int m, rc ;
1395          if (l > h)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines