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

Comparing ray/src/rt/lookamb.c (file contents):
Revision 2.12 by greg, Wed Apr 23 06:04:18 2014 UTC vs.
Revision 2.17 by greg, Tue May 14 17:39:10 2019 UTC

# Line 19 | Line 19 | int  reverse = 0;
19  
20   AMBVAL  av;
21  
22 #ifdef NEWAMB
22  
24
23   static void
24   lookamb(                        /* load & convert ambient values from a file */
25          FILE  *fp
# Line 42 | Line 40 | lookamb(                       /* load & convert ambient values from a fil
40                                                  colval(av.val,GRN),
41                                                  colval(av.val,BLU));
42                          printf("%f\t%f\t", av.gpos[0], av.gpos[1]);
43 <                        printf("%f\t%f\n", av.gdir[0], av.gdir[1]);
43 >                        printf("%f\t%f\t", av.gdir[0], av.gdir[1]);
44 >                        printf("%u\n", av.corral);
45                  } else {
46 <                        printf("\nPosition:\t%f\t%f\t%f\n", av.pos[0],
46 >                        printf("Position:\t%f\t%f\t%f\n", av.pos[0],
47                                          av.pos[1], av.pos[2]);
48                          printf("Normal:\t\t%f\t%f\t%f\n",
49                                          norm[0], norm[1], norm[2]);
# Line 56 | Line 55 | lookamb(                       /* load & convert ambient values from a fil
55                                          colval(av.val,GRN), colval(av.val,BLU));
56                          printf("Pos.Grad:\t%f\t%f\n", av.gpos[0], av.gpos[1]);
57                          printf("Dir.Grad:\t%f\t%f\n", av.gdir[0], av.gdir[1]);
58 +                        printf("Corral:\t\t%8X\n\n", av.corral);
59                  }
60                  if (ferror(stdout))
61                          exit(1);
# Line 88 | Line 88 | writamb(                       /* write binary ambient values to stdout */
88                  av.udir = encodedir(norm);
89                  if (!dataonly)
90                          fscanf(fp, "%*s");
91 <                if (fscanf(fp, "%d %f %f %f", &av.lvl, &av.weight,
91 >                if (fscanf(fp, "%hd %f %f %f", &av.lvl, &av.weight,
92                                  &av.rad[0], &av.rad[1]) != 4)
93                          return;
94                  if (!dataonly)
# Line 104 | Line 104 | writamb(                       /* write binary ambient values to stdout */
104                          fscanf(fp, "%*s");
105                  if (fscanf(fp, "%f %f", &av.gdir[0], &av.gdir[1]) != 2)
106                          return;
107                av.next = NULL;
108                writambval(&av, stdout);
109                if (ferror(stdout))
110                        exit(1);
111        }
112 }
113
114
115 #else /* ! NEWAMB */
116
117
118 static void
119 lookamb(                        /* get ambient values from a file */
120        FILE  *fp
121 )
122 {
123        while (readambval(&av, fp)) {
107                  if (dataonly) {
108 <                        printf("%f\t%f\t%f\t", av.pos[0], av.pos[1], av.pos[2]);
109 <                        printf("%f\t%f\t%f\t", av.dir[0], av.dir[1], av.dir[2]);
110 <                        printf("%d\t%f\t%f\t", av.lvl, av.weight, av.rad);
128 <                        printf("%e\t%e\t%e\t", colval(av.val,RED),
129 <                                                colval(av.val,GRN),
130 <                                                colval(av.val,BLU));
131 <                        printf("%f\t%f\t%f\t", av.gpos[0],
132 <                                        av.gpos[1], av.gpos[2]);
133 <                        printf("%f\t%f\t%f\n", av.gdir[0],
134 <                                        av.gdir[1], av.gdir[2]);
135 <                } else {
136 <                        printf("\nPosition:\t%f\t%f\t%f\n", av.pos[0],
137 <                                        av.pos[1], av.pos[2]);
138 <                        printf("Direction:\t%f\t%f\t%f\n", av.dir[0],
139 <                                        av.dir[1], av.dir[2]);
140 <                        printf("Lvl,Wt,Rad:\t%d\t\t%f\t%f\n", av.lvl,
141 <                                        av.weight, av.rad);
142 <                        printf("Value:\t\t%e\t%e\t%e\n", colval(av.val,RED),
143 <                                        colval(av.val,GRN), colval(av.val,BLU));
144 <                        printf("Pos.Grad:\t%f\t%f\t%f\n", av.gpos[0],
145 <                                        av.gpos[1], av.gpos[2]);
146 <                        printf("Dir.Grad:\t%f\t%f\t%f\n", av.gdir[0],
147 <                                        av.gdir[1], av.gdir[2]);
148 <                }
149 <                if (ferror(stdout))
150 <                        exit(1);
151 <        }
152 < }
153 <
154 <
155 < static void
156 < writamb(                        /* write binary ambient values */
157 <        FILE  *fp
158 < )
159 < {
160 <        for ( ; ; ) {
161 <                if (!dataonly)
162 <                        fscanf(fp, "%*s");
163 <                if (fscanf(fp, "%f %f %f",
164 <                                &av.pos[0], &av.pos[1], &av.pos[2]) != 3)
108 >                        if (fscanf(fp, "%u", &av.corral) != 1)
109 >                                return;
110 >                } else if (fscanf(fp, "%*s %X", &av.corral) != 1)
111                          return;
166                if (!dataonly)
167                        fscanf(fp, "%*s");
168                if (fscanf(fp, "%f %f %f",
169                                &av.dir[0], &av.dir[1], &av.dir[2]) != 3)
170                        return;
171                if (!dataonly)
172                        fscanf(fp, "%*s");
173                if (fscanf(fp, "%d %f %f",
174                                &av.lvl, &av.weight, &av.rad) != 3)
175                        return;
176                if (!dataonly)
177                        fscanf(fp, "%*s");
178                if (fscanf(fp, "%f %f %f",
179                                &av.val[RED], &av.val[GRN], &av.val[BLU]) != 3)
180                        return;
181                if (!dataonly)
182                        fscanf(fp, "%*s");
183                if (fscanf(fp, "%f %f %f",
184                                &av.gpos[0], &av.gpos[1], &av.gpos[2]) != 3)
185                        return;
186                if (!dataonly)
187                        fscanf(fp, "%*s");
188                if (fscanf(fp, "%f %f %f",
189                                &av.gdir[0], &av.gdir[1], &av.gdir[2]) != 3)
190                        return;
112                  av.next = NULL;
113                  writambval(&av, stdout);
114                  if (ferror(stdout))
115                          exit(1);
116          }
117   }
197
198
199 #endif  /* ! NEWAMB */
118  
119  
120   int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines