ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ambio.c
Revision: 2.1
Committed: Mon Jul 13 16:15:21 1992 UTC (31 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 2.1 /* Copyright (c) 1992 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * Read and write portable ambient values
9     */
10    
11     #include <stdio.h>
12    
13     #include "color.h"
14    
15     #include "ambient.h"
16    
17    
18     #define putvec(v,fp) putflt((v)[0],fp);putflt((v)[1],fp);putflt((v)[2],fp)
19    
20     #define getvec(v,fp) (v)[0]=getflt(fp);(v)[1]=getflt(fp);(v)[2]=getflt(fp)
21    
22    
23     extern double getflt();
24     extern long getint();
25    
26    
27     writambval(av, fp) /* write ambient value to stream */
28     register AMBVAL *av;
29     FILE *fp;
30     {
31     COLR col;
32    
33     putint((long)av->lvl, 1, fp);
34     putflt(av->weight, fp);
35     putvec(av->pos, fp);
36     putvec(av->dir, fp);
37     setcolr(col, colval(av->val,RED),
38     colval(av->val,GRN), colval(av->val,BLU));
39     fwrite((char *)col, sizeof(col), 1, fp);
40     putflt(av->rad, fp);
41     putvec(av->gpos, fp);
42     putvec(av->gdir, fp);
43     return(ferror(fp) ? -1 : 0);
44     }
45    
46    
47     readambval(av, fp) /* read ambient value from stream */
48     register AMBVAL *av;
49     FILE *fp;
50     {
51     COLR col;
52    
53     av->lvl = getint(1, fp);
54     if (feof(fp))
55     return(0);
56     av->weight = getflt(fp);
57     getvec(av->pos, fp);
58     getvec(av->dir, fp);
59     if (fread((char *)col, sizeof(col), 1, fp) != 1)
60     return(0);
61     colr_color(av->val, col);
62     av->rad = getflt(fp);
63     getvec(av->gpos, fp);
64     getvec(av->gdir, fp);
65     return(feof(fp) ? 0 : 1);
66     }