133 |
|
fprintf(stderr, "%s: no view in picture\n", argv[i]); |
134 |
|
exit(1); |
135 |
|
} |
136 |
< |
if (i+1 < argc) { |
137 |
< |
zfd = open(argv[i+1], O_RDONLY); |
138 |
< |
if (zfd < 0) { |
139 |
< |
fprintf(stderr, |
140 |
< |
"%s: cannot open depth buffer\n", |
141 |
< |
argv[i+1]); |
136 |
> |
if (!getdim & (i+1 < argc)) { |
137 |
> |
zfd = open_float_depth(argv[i+1], (long)rs.xr*rs.yr); |
138 |
> |
if (zfd < 0) |
139 |
|
exit(1); |
143 |
– |
} |
140 |
|
} |
141 |
|
} |
142 |
|
if ((err = setview(&vw)) != NULL) { |
147 |
|
normaspect(viewaspect(&vw), &pa, &rs.xr, &rs.yr); |
148 |
|
if (getdim) { |
149 |
|
printf("-x %d -y %d -ld%c\n", rs.xr, rs.yr, |
150 |
< |
vw.vaft > FTINY ? '+' : '-'); |
150 |
> |
(i+1 == argc) & (vw.vaft > FTINY) ? '+' : '-'); |
151 |
|
exit(0); |
152 |
|
} |
153 |
|
if (fromstdin) |
192 |
|
px += .5; py += .5; |
193 |
|
loc[0] = px/rs.xr; loc[1] = py/rs.yr; |
194 |
|
if (zfd >= 0) { |
195 |
+ |
if ((loc[0] < 0) | (loc[0] >= 1) | |
196 |
+ |
(loc[1] < 0) | (loc[1] >= 1)) { |
197 |
+ |
fprintf(stderr, "%s: input pixel outside image\n", |
198 |
+ |
progname); |
199 |
+ |
exit(1); |
200 |
+ |
} |
201 |
|
loc2pix(pp, &rs, loc[0], loc[1]); |
202 |
|
if (lseek(zfd, |
203 |
|
(pp[1]*scanlen(&rs)+pp[0])*sizeof(float), |
269 |
|
rdir[0] = rdir[1] = rdir[2] = 0.; |
270 |
|
else if (zfd >= 0) |
271 |
|
for (i = 0; i < 3; i++) { |
272 |
< |
rorg[i] += rdir[i]*zbuf[si]; |
273 |
< |
rdir[i] = -rdir[i]; |
272 |
> |
rdir[i] = -rdir[i]*zbuf[si]; |
273 |
> |
rorg[i] -= rdir[i]; |
274 |
|
} |
275 |
|
else if (d > FTINY) { |
276 |
|
rdir[0] *= d; rdir[1] *= d; rdir[2] *= d; |