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.10 by schorsch, Tue Mar 30 16:13:01 2004 UTC vs.
Revision 2.17 by greg, Tue May 14 17:39:10 2019 UTC

# Line 20 | Line 20 | int  reverse = 0;
20   AMBVAL  av;
21  
22  
23 + static void
24 + lookamb(                        /* load & convert ambient values from a file */
25 +        FILE  *fp
26 + )
27 + {
28 +        FVECT   norm, uvec;
29 +
30 +        while (readambval(&av, fp)) {
31 +                decodedir(norm, av.ndir);
32 +                decodedir(uvec, av.udir);
33 +                if (dataonly) {
34 +                        printf("%f\t%f\t%f\t", av.pos[0], av.pos[1], av.pos[2]);
35 +                        printf("%f\t%f\t%f\t", norm[0], norm[1], norm[2]);
36 +                        printf("%f\t%f\t%f\t", uvec[0], uvec[1], uvec[2]);
37 +                        printf("%d\t%f\t%f\t%f\t", av.lvl, av.weight,
38 +                                        av.rad[0], av.rad[1]);
39 +                        printf("%e\t%e\t%e\t", colval(av.val,RED),
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\t", av.gdir[0], av.gdir[1]);
44 +                        printf("%u\n", av.corral);
45 +                } else {
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]);
50 +                        printf("Uvector:\t%f\t%f\t%f\n",
51 +                                        uvec[0], uvec[1], uvec[2]);
52 +                        printf("Lvl,Wt,UVrad:\t%d\t\t%f\t%f\t%f\n", av.lvl,
53 +                                        av.weight, av.rad[0], av.rad[1]);
54 +                        printf("Value:\t\t%e\t%e\t%e\n", colval(av.val,RED),
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);
62 +        }
63 + }
64 +
65 +
66 + static void
67 + writamb(                        /* write binary ambient values to stdout */
68 +        FILE  *fp
69 + )
70 + {
71 +        FVECT   norm;
72 +
73 +        for ( ; ; ) {
74 +                if (!dataonly)
75 +                        fscanf(fp, "%*s");
76 +                if (fscanf(fp, "%f %f %f",
77 +                                &av.pos[0], &av.pos[1], &av.pos[2]) != 3)
78 +                        return;
79 +                if (!dataonly)
80 +                        fscanf(fp, "%*s");
81 +                if (fscanf(fp, FVFORMAT, &norm[0], &norm[1], &norm[2]) != 3)
82 +                        return;
83 +                av.ndir = encodedir(norm);
84 +                if (!dataonly)
85 +                        fscanf(fp, "%*s");
86 +                if (fscanf(fp, FVFORMAT, &norm[0], &norm[1], &norm[2]) != 3)
87 +                        return;
88 +                av.udir = encodedir(norm);
89 +                if (!dataonly)
90 +                        fscanf(fp, "%*s");
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)
95 +                        fscanf(fp, "%*s");
96 +                if (fscanf(fp, "%f %f %f",
97 +                                &av.val[RED], &av.val[GRN], &av.val[BLU]) != 3)
98 +                        return;
99 +                if (!dataonly)
100 +                        fscanf(fp, "%*s");
101 +                if (fscanf(fp, "%f %f", &av.gpos[0], &av.gpos[1]) != 2)
102 +                        return;
103 +                if (!dataonly)
104 +                        fscanf(fp, "%*s");
105 +                if (fscanf(fp, "%f %f", &av.gdir[0], &av.gdir[1]) != 2)
106 +                        return;
107 +                if (dataonly) {
108 +                        if (fscanf(fp, "%u", &av.corral) != 1)
109 +                                return;
110 +                } else if (fscanf(fp, "%*s %X", &av.corral) != 1)
111 +                        return;
112 +                av.next = NULL;
113 +                writambval(&av, stdout);
114 +                if (ferror(stdout))
115 +                        exit(1);
116 +        }
117 + }
118 +
119 +
120   int
121   main(           /* load ambient values from a file */
122          int  argc,
# Line 85 | Line 182 | main(          /* load ambient values from a file */
182   formaterr:
183          fprintf(stderr, "%s: format error on input\n", argv[0]);
184          exit(1);
88 }
89
90
91 extern void
92 lookamb(                        /* get ambient values from a file */
93        FILE  *fp
94 )
95 {
96        while (readambval(&av, fp)) {
97                if (dataonly) {
98                        printf("%f\t%f\t%f\t", av.pos[0], av.pos[1], av.pos[2]);
99                        printf("%f\t%f\t%f\t", av.dir[0], av.dir[1], av.dir[2]);
100                        printf("%d\t%f\t%f\t", av.lvl, av.weight, av.rad);
101                        printf("%e\t%e\t%e\t", colval(av.val,RED),
102                                                colval(av.val,GRN),
103                                                colval(av.val,BLU));
104                        printf("%f\t%f\t%f\t", av.gpos[0],
105                                        av.gpos[1], av.gpos[2]);
106                        printf("%f\t%f\t%f\n", av.gdir[0],
107                                        av.gdir[1], av.gdir[2]);
108                } else {
109                        printf("\nPosition:\t%f\t%f\t%f\n", av.pos[0],
110                                        av.pos[1], av.pos[2]);
111                        printf("Direction:\t%f\t%f\t%f\n", av.dir[0],
112                                        av.dir[1], av.dir[2]);
113                        printf("Lvl,Wt,Rad:\t%d\t\t%f\t%f\n", av.lvl,
114                                        av.weight, av.rad);
115                        printf("Value:\t\t%e\t%e\t%e\n", colval(av.val,RED),
116                                        colval(av.val,GRN), colval(av.val,BLU));
117                        printf("Pos.Grad:\t%f\t%f\t%f\n", av.gpos[0],
118                                        av.gpos[1], av.gpos[2]);
119                        printf("Dir.Grad:\t%f\t%f\t%f\n", av.gdir[0],
120                                        av.gdir[1], av.gdir[2]);
121                }
122                if (ferror(stdout))
123                        exit(1);
124        }
125 }
126
127
128 extern void
129 writamb(                        /* write binary ambient values */
130        FILE  *fp
131 )
132 {
133        for ( ; ; ) {
134                if (!dataonly)
135                        fscanf(fp, "%*s");
136                if (fscanf(fp, "%f %f %f",
137                                &av.pos[0], &av.pos[1], &av.pos[2]) != 3)
138                        return;
139                if (!dataonly)
140                        fscanf(fp, "%*s");
141                if (fscanf(fp, "%f %f %f",
142                                &av.dir[0], &av.dir[1], &av.dir[2]) != 3)
143                        return;
144                if (!dataonly)
145                        fscanf(fp, "%*s");
146                if (fscanf(fp, "%d %f %f",
147                                &av.lvl, &av.weight, &av.rad) != 3)
148                        return;
149                if (!dataonly)
150                        fscanf(fp, "%*s");
151                if (fscanf(fp, "%f %f %f",
152                                &av.val[RED], &av.val[GRN], &av.val[BLU]) != 3)
153                        return;
154                if (!dataonly)
155                        fscanf(fp, "%*s");
156                if (fscanf(fp, "%f %f %f",
157                                &av.gpos[0], &av.gpos[1], &av.gpos[2]) != 3)
158                        return;
159                if (!dataonly)
160                        fscanf(fp, "%*s");
161                if (fscanf(fp, "%f %f %f",
162                                &av.gdir[0], &av.gdir[1], &av.gdir[2]) != 3)
163                        return;
164                av.next = NULL;
165                writambval(&av, stdout);
166                if (ferror(stdout))
167                        exit(1);
168        }
185   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines