7 |
|
|
8 |
|
#include "platform.h" |
9 |
|
#include "standard.h" |
10 |
+ |
#include "random.h" |
11 |
|
#include "view.h" |
12 |
|
|
13 |
|
typedef void putfunc(FVECT ro, FVECT rd); |
25 |
|
|
26 |
|
double pa = 1.; |
27 |
|
|
28 |
+ |
double pj = 0.; |
29 |
+ |
|
30 |
|
int zfd = -1; |
31 |
|
|
32 |
|
int fromstdin = 0; |
56 |
|
break; |
57 |
|
case 'f': /* float */ |
58 |
|
putr = putf; |
59 |
+ |
SET_FILE_BINARY(stdout); |
60 |
|
break; |
61 |
|
case 'd': /* double */ |
62 |
|
putr = putd; |
63 |
+ |
SET_FILE_BINARY(stdout); |
64 |
|
break; |
65 |
|
default: |
66 |
|
goto userr; |
101 |
|
exit(1); |
102 |
|
} |
103 |
|
break; |
104 |
< |
case 'p': /* pixel aspect ratio */ |
105 |
< |
pa = atof(argv[++i]); |
104 |
> |
case 'p': /* pixel aspect or jitter */ |
105 |
> |
if (argv[i][2] == 'a') |
106 |
> |
pa = atof(argv[++i]); |
107 |
> |
else if (argv[i][2] == 'j') |
108 |
> |
pj= atof(argv[++i]); |
109 |
> |
else |
110 |
> |
goto userr; |
111 |
|
break; |
112 |
|
case 'i': /* get pixels from stdin */ |
113 |
|
fromstdin = 1; |
158 |
|
|
159 |
|
|
160 |
|
static void |
161 |
+ |
jitterloc( |
162 |
+ |
RREAL loc[2] |
163 |
+ |
) |
164 |
+ |
{ |
165 |
+ |
if (pj > FTINY) { |
166 |
+ |
loc[0] += pj*(.5 - frandom())/rs.xr; |
167 |
+ |
loc[1] += pj*(.5 - frandom())/rs.yr; |
168 |
+ |
} |
169 |
+ |
} |
170 |
+ |
|
171 |
+ |
|
172 |
+ |
static void |
173 |
|
pix2rays( |
174 |
|
FILE *fp |
175 |
|
) |
177 |
|
static FVECT rorg, rdir; |
178 |
|
float zval; |
179 |
|
double px, py; |
180 |
+ |
RREAL loc[2]; |
181 |
|
int pp[2]; |
182 |
|
double d; |
183 |
|
register int i; |
184 |
|
|
185 |
|
while (fscanf(fp, "%lf %lf", &px, &py) == 2) { |
186 |
|
px += .5; py += .5; |
187 |
< |
if (px < 0 || px >= rs.xr || |
165 |
< |
py < 0 || py >= rs.yr) { |
166 |
< |
fprintf(stderr, |
167 |
< |
"%s: (x,y) pair (%.0f,%.0f) out of range\n", |
168 |
< |
progname, px, py); |
169 |
< |
exit(1); |
170 |
< |
} |
187 |
> |
loc[0] = px/rs.xr; loc[1] = py/rs.yr; |
188 |
|
if (zfd >= 0) { |
189 |
< |
loc2pix(pp, &rs, px/rs.xr, py/rs.yr); |
189 |
> |
loc2pix(pp, &rs, loc[0], loc[1]); |
190 |
|
if (lseek(zfd, |
191 |
|
(pp[1]*scanlen(&rs)+pp[0])*sizeof(float), |
192 |
|
SEEK_SET) < 0 || |
197 |
|
exit(1); |
198 |
|
} |
199 |
|
} |
200 |
< |
d = viewray(rorg, rdir, &vw, px/rs.xr, py/rs.yr); |
200 |
> |
jitterloc(loc); |
201 |
> |
d = viewray(rorg, rdir, &vw, loc[0], loc[1]); |
202 |
|
if (d < -FTINY) |
203 |
|
rorg[0] = rorg[1] = rorg[2] = |
204 |
|
rdir[0] = rdir[1] = rdir[2] = 0.; |
222 |
|
static void |
223 |
|
putrays(void) |
224 |
|
{ |
225 |
< |
static RREAL loc[2]; |
226 |
< |
static FVECT rorg, rdir; |
225 |
> |
RREAL loc[2]; |
226 |
> |
FVECT rorg, rdir; |
227 |
|
float *zbuf = NULL; |
228 |
|
int sc; |
229 |
|
double d; |
247 |
|
} |
248 |
|
for (si = 0; si < scanlen(&rs); si++) { |
249 |
|
pix2loc(loc, &rs, si, sc); |
250 |
+ |
jitterloc(loc); |
251 |
|
d = viewray(rorg, rdir, &vw, loc[0], loc[1]); |
252 |
|
if (d < -FTINY) |
253 |
|
rorg[0] = rorg[1] = rorg[2] = |