13 |
|
#include <string.h> |
14 |
|
|
15 |
|
#include "platform.h" |
16 |
+ |
#include "rtprocess.h" /* win_popen() */ |
17 |
+ |
#include "paths.h" |
18 |
|
#include "ray.h" |
19 |
|
#include "source.h" |
20 |
|
#include "ambient.h" |
63 |
|
|
64 |
|
|
65 |
|
void |
66 |
< |
getview( /* get/show view parameters */ |
66 |
> |
getview( /* get/show/save view parameters */ |
67 |
|
char *s |
68 |
|
) |
69 |
|
{ |
82 |
|
error(COMMAND, "bad view option(s)"); |
83 |
|
return; |
84 |
|
} |
85 |
< |
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
85 |
> |
if (nextword(buf, sizeof(buf), s) != NULL) { /* write to a file */ |
86 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
87 |
|
(fp = fopen(fname, "a")) == NULL) { |
88 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
164 |
|
char *fname; |
165 |
|
int success; |
166 |
|
VIEW nv; |
167 |
< |
|
168 |
< |
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
167 |
> |
/* get parameters from a file */ |
168 |
> |
if (nextword(buf, sizeof(buf), s) != NULL) { |
169 |
|
nv = stdview; |
170 |
|
if ((fname = getpath(buf, "", R_OK)) == NULL || |
171 |
|
(success = viewfile(fname, &nv, NULL)) == -1) { |
206 |
|
} |
207 |
|
s = sskip(s); |
208 |
|
} |
209 |
< |
while (isspace(*s)) |
208 |
< |
s++; |
209 |
< |
if (*s) |
210 |
< |
atos(rifname, sizeof(rifname), s); |
211 |
< |
else if (rifname[0] == '\0') { |
209 |
> |
if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { |
210 |
|
error(COMMAND, "no previous rad file"); |
211 |
|
return; |
212 |
|
} |
239 |
|
s = sskip(s); |
240 |
|
else |
241 |
|
strcat(buf, "1"); |
242 |
< |
if (*s) |
245 |
< |
atos(rifname, sizeof(rifname), s); |
246 |
< |
else if (rifname[0] == '\0') { |
242 |
> |
if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { |
243 |
|
error(COMMAND, "no previous rad file"); |
244 |
|
return; |
245 |
|
} |
337 |
|
) |
338 |
|
{ |
339 |
|
VIEW nv = ourview; |
344 |
– |
FVECT v1; |
340 |
|
double angle, elev, zfact; |
341 |
|
|
342 |
|
elev = 0.0; zfact = 1.0; |
345 |
|
return; |
346 |
|
} |
347 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
348 |
< |
if (elev != 0.0) { |
349 |
< |
fcross(v1, nv.vdir, ourview.vup); |
350 |
< |
normalize(v1); |
356 |
< |
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
357 |
< |
} |
348 |
> |
if (elev != 0.0) |
349 |
> |
geodesic(nv.vdir, nv.vdir, nv.vup, elev*(PI/180.), GEOD_RAD); |
350 |
> |
|
351 |
|
zoomview(&nv, zfact); |
352 |
|
newview(&nv); |
353 |
|
} |
373 |
|
|
374 |
|
|
375 |
|
void |
376 |
+ |
getorigin( /* origin viewpoint */ |
377 |
+ |
char *s |
378 |
+ |
) |
379 |
+ |
{ |
380 |
+ |
VIEW nv = ourview; |
381 |
+ |
double d; |
382 |
+ |
/* get new view origin */ |
383 |
+ |
if (!sscanvec(s, nv.vp)) { |
384 |
+ |
int x, y; |
385 |
+ |
RAY thisray; |
386 |
+ |
if (dev->getcur == NULL) |
387 |
+ |
return; |
388 |
+ |
(*dev->comout)("Pick point on surface for new origin\n"); |
389 |
+ |
if ((*dev->getcur)(&x, &y) == ABORT) |
390 |
+ |
return; |
391 |
+ |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
392 |
+ |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
393 |
+ |
error(COMMAND, "not on image"); |
394 |
+ |
return; |
395 |
+ |
} |
396 |
+ |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
397 |
+ |
if (!localhit(&thisray, &thescene)) { |
398 |
+ |
error(COMMAND, "not a local object"); |
399 |
+ |
return; |
400 |
+ |
} |
401 |
+ |
if (thisray.rod < 0.0) /* don't look through other side */ |
402 |
+ |
flipsurface(&thisray); |
403 |
+ |
VSUM(nv.vp, thisray.rop, thisray.ron, 2.0*FTINY); |
404 |
+ |
VCOPY(nv.vdir, thisray.ron); |
405 |
+ |
} else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0) |
406 |
+ |
VCOPY(nv.vdir, ourview.vdir); |
407 |
+ |
|
408 |
+ |
d = DOT(nv.vdir, nv.vup); /* need different up vector? */ |
409 |
+ |
if (d*d >= 1.-2.*FTINY) { |
410 |
+ |
int i; |
411 |
+ |
nv.vup[0] = nv.vup[1] = nv.vup[2] = 0.0; |
412 |
+ |
for (i = 3; i--; ) |
413 |
+ |
if (nv.vdir[i]*nv.vdir[i] < 0.34) |
414 |
+ |
break; |
415 |
+ |
nv.vup[i] = 1.; |
416 |
+ |
} |
417 |
+ |
newview(&nv); |
418 |
+ |
} |
419 |
+ |
|
420 |
+ |
|
421 |
+ |
void |
422 |
|
getexposure( /* get new exposure */ |
423 |
|
char *s |
424 |
|
) |
843 |
|
FILE *fp; |
844 |
|
COLR *scanline; |
845 |
|
int y; |
846 |
< |
|
847 |
< |
while (isspace(*s)) |
809 |
< |
s++; |
810 |
< |
if (*s) |
811 |
< |
atos(buf, sizeof(buf), s); |
812 |
< |
else if (buf[0] == '\0') { |
846 |
> |
/* XXX relies on words.c 2.11 behavior */ |
847 |
> |
if (nextword(buf, sizeof(buf), s) == NULL && !buf[0]) { |
848 |
|
error(COMMAND, "no file"); |
849 |
|
return; |
850 |
|
} |