41 |
|
|
42 |
|
if (getrect(s, &box) < 0) |
43 |
|
return; |
44 |
< |
paintrect(&ptrunk, 0, 0, ourview.hresolu, ourview.vresolu, &box); |
44 |
> |
paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box); |
45 |
|
} |
46 |
|
|
47 |
|
|
69 |
|
} |
70 |
|
sprintf(buf, "view type (%c): ", ourview.type); |
71 |
|
(*dev->comout)(buf); |
72 |
< |
(*dev->comin)(buf); |
72 |
> |
(*dev->comin)(buf, NULL); |
73 |
|
if (buf[0] == CTRL(C)) return; |
74 |
|
if (buf[0] && buf[0] != ourview.type) { |
75 |
|
nv.type = buf[0]; |
79 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
80 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
81 |
|
(*dev->comout)(buf); |
82 |
< |
(*dev->comin)(buf); |
82 |
> |
(*dev->comin)(buf, NULL); |
83 |
|
if (buf[0] == CTRL(C)) return; |
84 |
|
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
85 |
|
change++; |
88 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
89 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
90 |
|
(*dev->comout)(buf); |
91 |
< |
(*dev->comin)(buf); |
91 |
> |
(*dev->comin)(buf, NULL); |
92 |
|
if (buf[0] == CTRL(C)) return; |
93 |
|
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
94 |
|
change++; |
97 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
98 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
99 |
|
(*dev->comout)(buf); |
100 |
< |
(*dev->comin)(buf); |
100 |
> |
(*dev->comin)(buf, NULL); |
101 |
|
if (buf[0] == CTRL(C)) return; |
102 |
|
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
103 |
|
change++; |
106 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
107 |
|
ourview.horiz, ourview.vert); |
108 |
|
(*dev->comout)(buf); |
109 |
< |
(*dev->comin)(buf); |
109 |
> |
(*dev->comin)(buf, NULL); |
110 |
|
if (buf[0] == CTRL(C)) return; |
111 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
112 |
|
change++; |
113 |
|
else { |
114 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
115 |
|
} |
116 |
< |
sprintf(buf, "x and y resolution (%d %d): ", |
117 |
< |
ourview.hresolu, ourview.vresolu); |
116 |
> |
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
117 |
> |
ourview.hoff, ourview.voff); |
118 |
|
(*dev->comout)(buf); |
119 |
< |
(*dev->comin)(buf); |
119 |
> |
(*dev->comin)(buf, NULL); |
120 |
|
if (buf[0] == CTRL(C)) return; |
121 |
< |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) |
121 |
> |
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
122 |
|
change++; |
123 |
|
else { |
124 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
124 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
125 |
|
} |
126 |
|
if (change) |
127 |
|
newview(&nv); |
137 |
|
VIEW nv; |
138 |
|
|
139 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
140 |
< |
bcopy(&stdview, &nv, sizeof(VIEW)); |
140 |
> |
copystruct(&nv, &stdview); |
141 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
142 |
< |
(success = viewfile(fname, &nv)) == -1) { |
142 |
> |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
143 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
144 |
|
error(COMMAND, errmsg); |
145 |
|
return; |
150 |
|
newview(&nv); |
151 |
|
return; |
152 |
|
} |
153 |
< |
if (oldview.hresolu == 0) { /* no old view! */ |
153 |
> |
if (oldview.horiz == 0) { /* no old view! */ |
154 |
|
error(COMMAND, "no previous view"); |
155 |
|
return; |
156 |
|
} |
157 |
< |
bcopy(&ourview, &nv, sizeof(VIEW)); |
158 |
< |
bcopy(&oldview, &ourview, sizeof(VIEW)); |
159 |
< |
bcopy(&nv, &oldview, sizeof(VIEW)); |
157 |
> |
copystruct(&nv, &ourview); |
158 |
> |
copystruct(&ourview, &oldview); |
159 |
> |
copystruct(&oldview, &nv); |
160 |
|
newimage(); |
161 |
|
} |
162 |
|
|
172 |
|
return; |
173 |
|
VCOPY(nv.vp, ourview.vp); |
174 |
|
VCOPY(nv.vup, ourview.vup); |
175 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
175 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
176 |
|
if ((nv.type = ourview.type) == VT_PAR) { |
177 |
|
nv.horiz = ourview.horiz / zfact; |
178 |
|
nv.vert = ourview.vert / zfact; |
213 |
|
} |
214 |
|
VCOPY(nv.vp, ourview.vp); |
215 |
|
VCOPY(nv.vup, ourview.vup); |
216 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
216 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
217 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
218 |
|
if (elev != 0.0) { |
219 |
|
fcross(v1, nv.vdir, ourview.vup); |
270 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
271 |
|
return; |
272 |
|
r.l = r.d = 0; |
273 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
273 |
> |
r.r = hresolu; r.u = vresolu; |
274 |
|
p = findrect(x, y, &ptrunk, &r, -1); |
275 |
|
e = 1.0; |
276 |
|
} else { |
282 |
|
if (*cp == '\0') { /* interactive */ |
283 |
|
sprintf(buf, "exposure (%lf): ", exposure); |
284 |
|
(*dev->comout)(buf); |
285 |
< |
(*dev->comin)(buf); |
285 |
> |
(*dev->comin)(buf, NULL); |
286 |
|
for (cp = buf; isspace(*cp); cp++) |
287 |
|
; |
288 |
|
if (*cp == '\0') |
335 |
|
|
336 |
|
if (s[0] == '\0') { |
337 |
|
(*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: "); |
338 |
< |
(*dev->comin)(buf); |
338 |
> |
(*dev->comin)(buf, NULL); |
339 |
|
s = buf; |
340 |
|
} |
341 |
|
switch (s[0]) { |
346 |
|
sprintf(buf, "limit weight (%.6g): ", |
347 |
|
minweight); |
348 |
|
(*dev->comout)(buf); |
349 |
< |
(*dev->comin)(buf); |
349 |
> |
(*dev->comin)(buf, NULL); |
350 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
351 |
|
break; |
352 |
|
} |
357 |
|
sprintf(buf, "limit reflection (%d): ", |
358 |
|
maxdepth); |
359 |
|
(*dev->comout)(buf); |
360 |
< |
(*dev->comin)(buf); |
360 |
> |
(*dev->comin)(buf, NULL); |
361 |
|
if (sscanf(buf, "%d", &i0) != 1) |
362 |
|
break; |
363 |
|
} |
374 |
|
sprintf(buf, "direct jitter (%.6g): ", |
375 |
|
dstrsrc); |
376 |
|
(*dev->comout)(buf); |
377 |
< |
(*dev->comin)(buf); |
377 |
> |
(*dev->comin)(buf, NULL); |
378 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
379 |
|
break; |
380 |
|
} |
385 |
|
sprintf(buf, "direct certainty (%.6g): ", |
386 |
|
shadcert); |
387 |
|
(*dev->comout)(buf); |
388 |
< |
(*dev->comin)(buf); |
388 |
> |
(*dev->comin)(buf, NULL); |
389 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
390 |
|
break; |
391 |
|
} |
396 |
|
sprintf(buf, "direct threshold (%.6g): ", |
397 |
|
shadthresh); |
398 |
|
(*dev->comout)(buf); |
399 |
< |
(*dev->comin)(buf); |
399 |
> |
(*dev->comin)(buf, NULL); |
400 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
401 |
|
break; |
402 |
|
} |
416 |
|
colval(ambval,GRN), |
417 |
|
colval(ambval,BLU)); |
418 |
|
(*dev->comout)(buf); |
419 |
< |
(*dev->comin)(buf); |
419 |
> |
(*dev->comin)(buf, NULL); |
420 |
|
if (sscanf(buf, "%lf %lf %lf", |
421 |
|
&d0, &d1, &d2) != 3) |
422 |
|
break; |
428 |
|
sprintf(buf, "ambient accuracy (%.6g): ", |
429 |
|
ambacc); |
430 |
|
(*dev->comout)(buf); |
431 |
< |
(*dev->comin)(buf); |
431 |
> |
(*dev->comin)(buf, NULL); |
432 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
433 |
|
break; |
434 |
|
} |
439 |
|
sprintf(buf, "ambient divisions (%d): ", |
440 |
|
ambdiv); |
441 |
|
(*dev->comout)(buf); |
442 |
< |
(*dev->comin)(buf); |
442 |
> |
(*dev->comin)(buf, NULL); |
443 |
|
if (sscanf(buf, "%d", &i0) != 1) |
444 |
|
break; |
445 |
|
} |
450 |
|
sprintf(buf, "ambient super-samples (%d): ", |
451 |
|
ambssamp); |
452 |
|
(*dev->comout)(buf); |
453 |
< |
(*dev->comin)(buf); |
453 |
> |
(*dev->comin)(buf, NULL); |
454 |
|
if (sscanf(buf, "%d", &i0) != 1) |
455 |
|
break; |
456 |
|
} |
461 |
|
sprintf(buf, "ambient bounces (%d): ", |
462 |
|
ambounce); |
463 |
|
(*dev->comout)(buf); |
464 |
< |
(*dev->comin)(buf); |
464 |
> |
(*dev->comin)(buf, NULL); |
465 |
|
if (sscanf(buf, "%d", &i0) != 1) |
466 |
|
break; |
467 |
|
} |
472 |
|
sprintf(buf, "ambient resolution (%d): ", |
473 |
|
ambres); |
474 |
|
(*dev->comout)(buf); |
475 |
< |
(*dev->comin)(buf); |
475 |
> |
(*dev->comin)(buf, NULL); |
476 |
|
if (sscanf(buf, "%d", &i0) != 1) |
477 |
|
break; |
478 |
|
} |
489 |
|
if (sscanf(s+2, "%d", &i0) != 1) { |
490 |
|
sprintf(buf, "sample pixel (%d): ", psample); |
491 |
|
(*dev->comout)(buf); |
492 |
< |
(*dev->comin)(buf); |
492 |
> |
(*dev->comin)(buf, NULL); |
493 |
|
if (sscanf(buf, "%d", &i0) != 1) |
494 |
|
break; |
495 |
|
} |
501 |
|
sprintf(buf, "sample threshold (%.6g): ", |
502 |
|
maxdiff); |
503 |
|
(*dev->comout)(buf); |
504 |
< |
(*dev->comin)(buf); |
504 |
> |
(*dev->comin)(buf, NULL); |
505 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
506 |
|
break; |
507 |
|
} |
540 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
541 |
|
return; |
542 |
|
|
543 |
< |
rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5); |
543 |
> |
viewray(thisray.rorg, thisray.rdir, &ourview, |
544 |
> |
(x+.5)/hresolu, (y+.5)/vresolu); |
545 |
|
|
546 |
|
} else if (normalize(thisray.rdir) == 0.0) { |
547 |
|
error(COMMAND, "zero ray direction"); |
560 |
|
ofun[thisray.ro->otype].funame, |
561 |
|
thisray.ro->oname); |
562 |
|
(*dev->comout)(buf); |
563 |
< |
(*dev->comin)(buf); |
563 |
> |
(*dev->comin)(buf, NULL); |
564 |
|
if (thisray.rot >= FHUGE) |
565 |
|
(*dev->comout)("at infinity"); |
566 |
|
else { |
568 |
|
thisray.rop[1], thisray.rop[2]); |
569 |
|
(*dev->comout)(buf); |
570 |
|
} |
571 |
< |
(*dev->comin)(buf); |
571 |
> |
(*dev->comin)(buf, NULL); |
572 |
|
sprintf(buf, "with value (%.6g %.6g %.6g)", |
573 |
|
colval(thisray.rcol,RED), |
574 |
|
colval(thisray.rcol,GRN), |
575 |
|
colval(thisray.rcol,BLU)); |
576 |
|
(*dev->comout)(buf); |
577 |
|
} |
578 |
< |
(*dev->comin)(buf); |
578 |
> |
(*dev->comin)(buf, NULL); |
579 |
|
} |
580 |
|
|
581 |
|
|
606 |
|
fprintview(&ourview, fp); |
607 |
|
putc('\n', fp); |
608 |
|
if (exposure != 1.0) |
609 |
< |
fprintf(fp, "EXPOSURE=%e\n", exposure); |
609 |
> |
fputexpos(exposure, fp); |
610 |
> |
if (dev->pixaspect != 1.0) |
611 |
> |
fputaspect(dev->pixaspect, fp); |
612 |
|
putc('\n', fp); |
613 |
< |
fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, fp); |
613 |
> |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
614 |
|
|
615 |
< |
scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR)); |
615 |
> |
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
616 |
|
if (scanline == NULL) |
617 |
|
error(SYSTEM, "out of memory in writepict"); |
618 |
< |
for (y = ourview.vresolu-1; y >= 0; y--) { |
619 |
< |
getpictcolrs(y, scanline, &ptrunk, |
620 |
< |
ourview.hresolu, ourview.vresolu); |
618 |
< |
if (fwritecolrs(scanline, ourview.hresolu, fp) < 0) |
618 |
> |
for (y = vresolu-1; y >= 0; y--) { |
619 |
> |
getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); |
620 |
> |
if (fwritecolrs(scanline, hresolu, fp) < 0) |
621 |
|
break; |
622 |
|
} |
623 |
|
if (fclose(fp) < 0) |