1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
14 |
|
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
+ |
#include "ambient.h" |
18 |
|
|
18 |
– |
typedef double FVECT[3]; |
19 |
|
|
20 |
– |
typedef struct ambval { |
21 |
– |
FVECT pos; /* position in space */ |
22 |
– |
FVECT dir; /* normal direction */ |
23 |
– |
int lvl; /* recursion level of parent ray */ |
24 |
– |
float weight; /* weight of parent ray */ |
25 |
– |
COLOR val; /* computed ambient value */ |
26 |
– |
float rad; /* validity radius */ |
27 |
– |
struct ambval *next; /* next in list */ |
28 |
– |
} AMBVAL; /* ambient value */ |
29 |
– |
|
20 |
|
int dataonly = 0; |
21 |
|
|
22 |
|
int reverse = 0; |
65 |
|
lookamb(fp) /* get ambient values from a file */ |
66 |
|
FILE *fp; |
67 |
|
{ |
68 |
< |
while (fread(&av, sizeof(AMBVAL), 1, fp) == 1) { |
68 |
> |
while (readambval(&av, fp)) { |
69 |
|
if (dataonly) { |
70 |
|
printf("%f\t%f\t%f\t", av.pos[0], av.pos[1], av.pos[2]); |
71 |
|
printf("%f\t%f\t%f\t", av.dir[0], av.dir[1], av.dir[2]); |
72 |
|
printf("%d\t%f\t%f\t", av.lvl, av.weight, av.rad); |
73 |
< |
printf("%e\t%e\t%e\n", colval(av.val,RED), |
73 |
> |
printf("%e\t%e\t%e\t", colval(av.val,RED), |
74 |
|
colval(av.val,GRN), |
75 |
|
colval(av.val,BLU)); |
76 |
+ |
printf("%f\t%f\t%f\t", av.gpos[0], |
77 |
+ |
av.gpos[1], av.gpos[2]); |
78 |
+ |
printf("%f\t%f\t%f\n", av.gdir[0], |
79 |
+ |
av.gdir[1], av.gdir[2]); |
80 |
|
} else { |
81 |
|
printf("\nPosition:\t%f\t%f\t%f\n", av.pos[0], |
82 |
|
av.pos[1], av.pos[2]); |
86 |
|
av.weight, av.rad); |
87 |
|
printf("Value:\t\t%e\t%e\t%e\n", colval(av.val,RED), |
88 |
|
colval(av.val,GRN), colval(av.val,BLU)); |
89 |
+ |
printf("Pos.Grad:\t%f\t%f\t%f\n", av.gpos[0], |
90 |
+ |
av.gpos[1], av.gpos[2]); |
91 |
+ |
printf("Dir.Grad:\t%f\t%f\t%f\n", av.gdir[0], |
92 |
+ |
av.gdir[1], av.gdir[2]); |
93 |
|
} |
94 |
|
if (ferror(stdout)) |
95 |
|
exit(1); |
103 |
|
for ( ; ; ) { |
104 |
|
if (!dataonly) |
105 |
|
fscanf(fp, "%*s"); |
106 |
< |
if (fscanf(fp, "%lf %lf %lf", |
106 |
> |
if (fscanf(fp, "%f %f %f", |
107 |
|
&av.pos[0], &av.pos[1], &av.pos[2]) != 3) |
108 |
|
return; |
109 |
|
if (!dataonly) |
110 |
|
fscanf(fp, "%*s"); |
111 |
< |
if (fscanf(fp, "%lf %lf %lf", |
111 |
> |
if (fscanf(fp, "%f %f %f", |
112 |
|
&av.dir[0], &av.dir[1], &av.dir[2]) != 3) |
113 |
|
return; |
114 |
|
if (!dataonly) |
121 |
|
if (fscanf(fp, "%f %f %f", |
122 |
|
&av.val[RED], &av.val[GRN], &av.val[BLU]) != 3) |
123 |
|
return; |
124 |
< |
fwrite(&av, sizeof(AMBVAL), 1, stdout); |
124 |
> |
if (!dataonly) |
125 |
> |
fscanf(fp, "%*s"); |
126 |
> |
if (fscanf(fp, "%f %f %f", |
127 |
> |
&av.gpos[0], &av.gpos[1], &av.gpos[2]) != 3) |
128 |
> |
return; |
129 |
> |
if (!dataonly) |
130 |
> |
fscanf(fp, "%*s"); |
131 |
> |
if (fscanf(fp, "%f %f %f", |
132 |
> |
&av.gdir[0], &av.gdir[1], &av.gdir[2]) != 3) |
133 |
> |
return; |
134 |
> |
av.next = NULL; |
135 |
> |
writambval(&av, stdout); |
136 |
|
if (ferror(stdout)) |
137 |
|
exit(1); |
138 |
|
} |