1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
18 |
|
|
19 |
|
#include "rpaint.h" |
20 |
|
|
21 |
+ |
#include "resolu.h" |
22 |
+ |
|
23 |
|
#include <ctype.h> |
24 |
|
|
25 |
< |
#define CTRL(c) ('c'-'@') |
25 |
> |
#define CTRL(c) ((c)-'@') |
26 |
|
|
27 |
+ |
#ifdef SMLFLT |
28 |
+ |
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
29 |
+ |
#else |
30 |
+ |
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
31 |
+ |
#endif |
32 |
+ |
|
33 |
+ |
extern char *atos(); |
34 |
+ |
|
35 |
+ |
extern FILE *popen(); |
36 |
+ |
|
37 |
+ |
extern char rifname[128]; /* rad input file name */ |
38 |
+ |
|
39 |
|
extern char VersionID[]; |
40 |
|
extern char *progname; |
41 |
|
extern char *octname; |
70 |
|
int change = 0; |
71 |
|
VIEW nv; |
72 |
|
|
73 |
+ |
while (isspace(*s)) |
74 |
+ |
s++; |
75 |
+ |
if (*s == '-') { /* command line parameters */ |
76 |
+ |
copystruct(&nv, &ourview); |
77 |
+ |
if (sscanview(&nv, s)) |
78 |
+ |
newview(&nv); |
79 |
+ |
else |
80 |
+ |
error(COMMAND, "bad view option(s)"); |
81 |
+ |
return; |
82 |
+ |
} |
83 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
84 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
85 |
|
(fp = fopen(fname, "a")) == NULL) { |
90 |
|
fputs(progname, fp); |
91 |
|
fprintview(&ourview, fp); |
92 |
|
fputs(sskip(s), fp); |
93 |
< |
fputs("\n", fp); |
93 |
> |
putc('\n', fp); |
94 |
|
fclose(fp); |
95 |
|
return; |
96 |
|
} |
97 |
|
sprintf(buf, "view type (%c): ", ourview.type); |
98 |
|
(*dev->comout)(buf); |
99 |
|
(*dev->comin)(buf, NULL); |
100 |
< |
if (buf[0] == CTRL(C)) return; |
100 |
> |
if (buf[0] == CTRL('C')) return; |
101 |
|
if (buf[0] && buf[0] != ourview.type) { |
102 |
|
nv.type = buf[0]; |
103 |
|
change++; |
107 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
108 |
|
(*dev->comout)(buf); |
109 |
|
(*dev->comin)(buf, NULL); |
110 |
< |
if (buf[0] == CTRL(C)) return; |
111 |
< |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
110 |
> |
if (buf[0] == CTRL('C')) return; |
111 |
> |
if (sscanvec(buf, nv.vp)) |
112 |
|
change++; |
113 |
|
else |
114 |
|
VCOPY(nv.vp, ourview.vp); |
116 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
117 |
|
(*dev->comout)(buf); |
118 |
|
(*dev->comin)(buf, NULL); |
119 |
< |
if (buf[0] == CTRL(C)) return; |
120 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
119 |
> |
if (buf[0] == CTRL('C')) return; |
120 |
> |
if (sscanvec(buf, nv.vdir)) |
121 |
|
change++; |
122 |
|
else |
123 |
|
VCOPY(nv.vdir, ourview.vdir); |
125 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
126 |
|
(*dev->comout)(buf); |
127 |
|
(*dev->comin)(buf, NULL); |
128 |
< |
if (buf[0] == CTRL(C)) return; |
129 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
128 |
> |
if (buf[0] == CTRL('C')) return; |
129 |
> |
if (sscanvec(buf, nv.vup)) |
130 |
|
change++; |
131 |
|
else |
132 |
|
VCOPY(nv.vup, ourview.vup); |
134 |
|
ourview.horiz, ourview.vert); |
135 |
|
(*dev->comout)(buf); |
136 |
|
(*dev->comin)(buf, NULL); |
137 |
< |
if (buf[0] == CTRL(C)) return; |
137 |
> |
if (buf[0] == CTRL('C')) return; |
138 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
139 |
|
change++; |
140 |
|
else { |
141 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
142 |
|
} |
143 |
+ |
sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", |
144 |
+ |
ourview.vfore, ourview.vaft); |
145 |
+ |
(*dev->comout)(buf); |
146 |
+ |
(*dev->comin)(buf, NULL); |
147 |
+ |
if (buf[0] == CTRL('C')) return; |
148 |
+ |
if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) |
149 |
+ |
change++; |
150 |
+ |
else { |
151 |
+ |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
152 |
+ |
} |
153 |
|
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
154 |
|
ourview.hoff, ourview.voff); |
155 |
|
(*dev->comout)(buf); |
156 |
|
(*dev->comin)(buf, NULL); |
157 |
< |
if (buf[0] == CTRL(C)) return; |
157 |
> |
if (buf[0] == CTRL('C')) return; |
158 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
159 |
|
change++; |
160 |
|
else { |
175 |
|
|
176 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
177 |
|
copystruct(&nv, &stdview); |
178 |
< |
if ((fname = getpath(buf, NULL, 0)) == NULL || |
179 |
< |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
178 |
> |
if ((fname = getpath(buf, "", R_OK)) == NULL || |
179 |
> |
(success = viewfile(fname, &nv, NULL)) == -1) { |
180 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
181 |
|
error(COMMAND, errmsg); |
182 |
|
return; |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
+ |
saveview(s) /* save view to rad file */ |
202 |
+ |
char *s; |
203 |
+ |
{ |
204 |
+ |
char view[64]; |
205 |
+ |
char *fname; |
206 |
+ |
FILE *fp; |
207 |
+ |
|
208 |
+ |
if (*atos(view, sizeof(view), s)) { |
209 |
+ |
if (isint(view)) { |
210 |
+ |
error(COMMAND, "cannot write view by number"); |
211 |
+ |
return; |
212 |
+ |
} |
213 |
+ |
s = sskip(s); |
214 |
+ |
} |
215 |
+ |
while (isspace(*s)) |
216 |
+ |
s++; |
217 |
+ |
if (*s) |
218 |
+ |
atos(rifname, sizeof(rifname), s); |
219 |
+ |
else if (rifname[0] == '\0') { |
220 |
+ |
error(COMMAND, "no previous rad file"); |
221 |
+ |
return; |
222 |
+ |
} |
223 |
+ |
if ((fname = getpath(rifname, NULL, 0)) == NULL || |
224 |
+ |
(fp = fopen(fname, "a")) == NULL) { |
225 |
+ |
sprintf(errmsg, "cannot open \"%s\"", rifname); |
226 |
+ |
error(COMMAND, errmsg); |
227 |
+ |
return; |
228 |
+ |
} |
229 |
+ |
fputs("view= ", fp); |
230 |
+ |
fputs(view, fp); |
231 |
+ |
fprintview(&ourview, fp); |
232 |
+ |
putc('\n', fp); |
233 |
+ |
fclose(fp); |
234 |
+ |
} |
235 |
+ |
|
236 |
+ |
|
237 |
+ |
loadview(s) /* load view from rad file */ |
238 |
+ |
char *s; |
239 |
+ |
{ |
240 |
+ |
char buf[512]; |
241 |
+ |
char *fname; |
242 |
+ |
FILE *fp; |
243 |
+ |
VIEW nv; |
244 |
+ |
|
245 |
+ |
strcpy(buf, "rad -n -s -V -v "); |
246 |
+ |
if (sscanf(s, "%s", buf+strlen(buf)) == 1) |
247 |
+ |
s = sskip(s); |
248 |
+ |
else |
249 |
+ |
strcat(buf, "1"); |
250 |
+ |
if (*s) |
251 |
+ |
atos(rifname, sizeof(rifname), s); |
252 |
+ |
else if (rifname[0] == '\0') { |
253 |
+ |
error(COMMAND, "no previous rad file"); |
254 |
+ |
return; |
255 |
+ |
} |
256 |
+ |
if ((fname = getpath(rifname, "", R_OK)) == NULL) { |
257 |
+ |
sprintf(errmsg, "cannot access \"%s\"", rifname); |
258 |
+ |
error(COMMAND, errmsg); |
259 |
+ |
return; |
260 |
+ |
} |
261 |
+ |
sprintf(buf+strlen(buf), " %s", fname); |
262 |
+ |
if ((fp = popen(buf, "r")) == NULL) { |
263 |
+ |
error(COMMAND, "cannot run rad"); |
264 |
+ |
return; |
265 |
+ |
} |
266 |
+ |
buf[0] = '\0'; |
267 |
+ |
fgets(buf, sizeof(buf), fp); |
268 |
+ |
pclose(fp); |
269 |
+ |
copystruct(&nv, &stdview); |
270 |
+ |
if (!sscanview(&nv, buf)) { |
271 |
+ |
error(COMMAND, "rad error -- no such view?"); |
272 |
+ |
return; |
273 |
+ |
} |
274 |
+ |
newview(&nv); |
275 |
+ |
} |
276 |
+ |
|
277 |
+ |
|
278 |
|
getaim(s) /* aim camera */ |
279 |
|
char *s; |
280 |
|
{ |
170 |
– |
extern double tan(), atan(); |
281 |
|
double zfact; |
282 |
|
VIEW nv; |
283 |
|
|
286 |
|
nv.type = ourview.type; |
287 |
|
VCOPY(nv.vp, ourview.vp); |
288 |
|
VCOPY(nv.vup, ourview.vup); |
179 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
289 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
290 |
+ |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
291 |
+ |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
292 |
|
zoomview(&nv, zfact); |
293 |
|
newview(&nv); |
294 |
|
} |
309 |
|
getrotate(s) /* rotate camera */ |
310 |
|
char *s; |
311 |
|
{ |
201 |
– |
extern double normalize(), tan(), atan(); |
312 |
|
VIEW nv; |
313 |
|
FVECT v1; |
314 |
|
double angle, elev, zfact; |
322 |
|
VCOPY(nv.vp, ourview.vp); |
323 |
|
VCOPY(nv.vup, ourview.vup); |
324 |
|
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
325 |
+ |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
326 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
327 |
|
if (elev != 0.0) { |
328 |
|
fcross(v1, nv.vdir, ourview.vup); |
355 |
|
getexposure(s) /* get new exposure */ |
356 |
|
char *s; |
357 |
|
{ |
247 |
– |
double atof(), pow(), fabs(); |
358 |
|
char buf[128]; |
359 |
|
register char *cp; |
250 |
– |
register PNODE *p; |
360 |
|
RECT r; |
361 |
|
int x, y; |
362 |
< |
double e; |
362 |
> |
register PNODE *p = &ptrunk; |
363 |
> |
int adapt = 0; |
364 |
> |
double e = 1.0; |
365 |
|
|
366 |
|
for (cp = s; isspace(*cp); cp++) |
367 |
|
; |
368 |
+ |
if (*cp == '@') { |
369 |
+ |
adapt++; |
370 |
+ |
while (isspace(*++cp)) |
371 |
+ |
; |
372 |
+ |
} |
373 |
|
if (*cp == '\0') { /* normalize to point */ |
374 |
|
if (dev->getcur == NULL) |
375 |
|
return; |
379 |
|
r.l = r.d = 0; |
380 |
|
r.r = hresolu; r.u = vresolu; |
381 |
|
p = findrect(x, y, &ptrunk, &r, -1); |
266 |
– |
e = 1.0; |
382 |
|
} else { |
383 |
|
if (*cp == '=') { /* absolute setting */ |
384 |
|
p = NULL; |
386 |
|
for (cp++; isspace(*cp); cp++) |
387 |
|
; |
388 |
|
if (*cp == '\0') { /* interactive */ |
389 |
< |
sprintf(buf, "exposure (%lf): ", exposure); |
389 |
> |
sprintf(buf, "exposure (%f): ", exposure); |
390 |
|
(*dev->comout)(buf); |
391 |
|
(*dev->comin)(buf, NULL); |
392 |
|
for (cp = buf; isspace(*cp); cp++) |
394 |
|
if (*cp == '\0') |
395 |
|
return; |
396 |
|
} |
282 |
– |
} else { /* normalize to average */ |
283 |
– |
p = &ptrunk; |
284 |
– |
e = 1.0; |
397 |
|
} |
398 |
|
if (*cp == '+' || *cp == '-') /* f-stops */ |
399 |
|
e *= pow(2.0, atof(cp)); |
401 |
|
e *= atof(cp); |
402 |
|
} |
403 |
|
if (p != NULL) { /* relative setting */ |
404 |
< |
if (bright(p->v) <= FTINY) { |
404 |
> |
if (bright(p->v) < 1e-15) { |
405 |
|
error(COMMAND, "cannot normalize to zero"); |
406 |
|
return; |
407 |
|
} |
408 |
< |
e *= 0.5 / bright(p->v); |
408 |
> |
if (adapt) |
409 |
> |
e *= 106./pow(1.219+pow(luminance(p->v)/exposure,.4),2.5)/exposure; |
410 |
> |
else |
411 |
> |
e *= 0.5 / bright(p->v); |
412 |
|
} |
413 |
|
if (e <= FTINY || fabs(1.0 - e) <= FTINY) |
414 |
|
return; |
436 |
|
(*dev->comout)(buf); |
437 |
|
(*dev->comin)(buf, NULL); |
438 |
|
if (sscanf(buf, "%d", &i0) != 1) |
439 |
< |
break; |
439 |
> |
return(0); |
440 |
|
} |
441 |
|
ptr->i = i0; |
442 |
< |
break; |
442 |
> |
return(1); |
443 |
|
case 'r': /* real */ |
444 |
|
if (sscanf(str, "%lf", &d0) != 1) { |
445 |
|
(*dev->comout)(dsc); |
447 |
|
(*dev->comout)(buf); |
448 |
|
(*dev->comin)(buf, NULL); |
449 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
450 |
< |
break; |
450 |
> |
return(0); |
451 |
|
} |
452 |
|
ptr->d = d0; |
453 |
< |
break; |
453 |
> |
return(1); |
454 |
|
case 'b': /* boolean */ |
455 |
|
if (sscanf(str, "%1s", buf) != 1) { |
456 |
|
(*dev->comout)(dsc); |
457 |
< |
sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n'); |
457 |
> |
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
458 |
|
(*dev->comout)(buf); |
459 |
|
(*dev->comin)(buf, NULL); |
460 |
|
if (buf[0] == '\0' || |
461 |
|
index("yY+1tTnN-0fF", buf[0]) == NULL) |
462 |
< |
break; |
462 |
> |
return(0); |
463 |
|
} |
464 |
|
ptr->i = index("yY+1tT", buf[0]) != NULL; |
465 |
< |
break; |
465 |
> |
return(1); |
466 |
|
case 'C': /* color */ |
467 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
468 |
|
(*dev->comout)(dsc); |
473 |
|
(*dev->comout)(buf); |
474 |
|
(*dev->comin)(buf, NULL); |
475 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
476 |
< |
break; |
476 |
> |
return(0); |
477 |
|
} |
478 |
|
setcolor(ptr->C, d0, d1, d2); |
479 |
< |
break; |
479 |
> |
return(1); |
480 |
|
} |
481 |
|
} |
482 |
|
|
493 |
|
extern double shadcert; |
494 |
|
extern COLOR ambval; |
495 |
|
extern double ambacc; |
381 |
– |
extern double minarad; |
496 |
|
extern int ambres; |
497 |
|
extern int ambdiv; |
498 |
|
extern int ambssamp; |
499 |
|
extern int ambounce; |
500 |
< |
extern int directinvis; |
500 |
> |
extern int directvis; |
501 |
> |
extern double srcsizerat; |
502 |
|
extern int do_irrad; |
503 |
+ |
extern double specjitter; |
504 |
+ |
extern double specthresh; |
505 |
+ |
extern int backvis; |
506 |
|
char buf[128]; |
507 |
|
|
508 |
|
if (s[0] == '\0') { |
509 |
|
(*dev->comout)( |
510 |
< |
"aa ab ad ar as av b dc di dj dt i lr lw sp st: "); |
510 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st bv: "); |
511 |
|
(*dev->comin)(buf, NULL); |
512 |
|
s = buf; |
513 |
|
} |
535 |
|
case 't': /* threshold */ |
536 |
|
getparam(s+2, "direct threshold", 'r', &shadthresh); |
537 |
|
break; |
538 |
< |
case 'i': /* invisibility */ |
539 |
< |
getparam(s+2, "direct invisibility", |
540 |
< |
'b', &directinvis); |
538 |
> |
case 'v': /* visibility */ |
539 |
> |
getparam(s+2, "direct visibility", |
540 |
> |
'b', &directvis); |
541 |
|
break; |
542 |
+ |
case 's': /* sampling */ |
543 |
+ |
getparam(s+2, "direct sampling", 'r', &srcsizerat); |
544 |
+ |
break; |
545 |
|
default: |
546 |
|
goto badparam; |
547 |
|
} |
548 |
|
break; |
549 |
< |
case 'b': /* black and white */ |
550 |
< |
getparam(s+1, "black and white", 'b', &greyscale); |
549 |
> |
case 'b': /* back faces or black and white */ |
550 |
> |
switch (s[1]) { |
551 |
> |
case 'v': /* back face visibility */ |
552 |
> |
getparam(s+2, "back face visibility", 'b', &backvis); |
553 |
> |
break; |
554 |
> |
case '\0': /* black and white */ |
555 |
> |
case 'y': case 'Y': case 't': case 'T': case '1': case '+': |
556 |
> |
case 'n': case 'N': case 'f': case 'F': case '0': case '-': |
557 |
> |
getparam(s+1, "black and white", 'b', &greyscale); |
558 |
> |
break; |
559 |
> |
default: |
560 |
> |
goto badparam; |
561 |
> |
} |
562 |
|
break; |
563 |
|
case 'i': /* irradiance */ |
564 |
|
getparam(s+1, "irradiance", 'b', &do_irrad); |
566 |
|
case 'a': /* ambient */ |
567 |
|
switch (s[1]) { |
568 |
|
case 'v': /* value */ |
569 |
< |
getparam(s+2, "ambient value", 'C', ambval); |
569 |
> |
getparam(s+2, "ambient value", 'C', (COLOR *)ambval); |
570 |
|
break; |
571 |
|
case 'a': /* accuracy */ |
572 |
< |
getparam(s+2, "ambient accuracy", 'r', &ambacc); |
572 |
> |
if (getparam(s+2, "ambient accuracy", 'r', &ambacc)) |
573 |
> |
setambacc(ambacc); |
574 |
|
break; |
575 |
|
case 'd': /* divisions */ |
576 |
|
getparam(s+2, "ambient divisions", 'i', &ambdiv); |
582 |
|
getparam(s+2, "ambient bounces", 'i', &ambounce); |
583 |
|
break; |
584 |
|
case 'r': |
585 |
< |
getparam(s+2, "ambient resolution", 'i', &ambres); |
586 |
< |
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
585 |
> |
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
586 |
> |
setambres(ambres); |
587 |
|
break; |
588 |
|
default: |
589 |
|
goto badparam; |
590 |
|
} |
591 |
|
break; |
592 |
< |
case 's': /* sample */ |
592 |
> |
case 'p': /* pixel */ |
593 |
|
switch (s[1]) { |
594 |
< |
case 'p': /* pixel */ |
595 |
< |
getparam(s+2, "sample pixel", 'i', &psample); |
596 |
< |
pdepth = 0; |
594 |
> |
case 's': /* sample */ |
595 |
> |
if (getparam(s+2, "pixel sample", 'i', &psample)) |
596 |
> |
pdepth = 0; |
597 |
|
break; |
598 |
|
case 't': /* threshold */ |
599 |
< |
getparam(s+2, "sample threshold", 'r', &maxdiff); |
600 |
< |
pdepth = 0; |
599 |
> |
if (getparam(s+2, "pixel threshold", 'r', &maxdiff)) |
600 |
> |
pdepth = 0; |
601 |
|
break; |
602 |
|
default: |
603 |
|
goto badparam; |
604 |
|
} |
605 |
|
break; |
606 |
+ |
case 's': /* specular */ |
607 |
+ |
switch (s[1]) { |
608 |
+ |
case 'j': /* jitter */ |
609 |
+ |
getparam(s+2, "specular jitter", 'r', &specjitter); |
610 |
+ |
break; |
611 |
+ |
case 't': /* threshold */ |
612 |
+ |
getparam(s+2, "specular threshold", 'r', &specthresh); |
613 |
+ |
break; |
614 |
+ |
default: |
615 |
+ |
goto badparam; |
616 |
+ |
} |
617 |
+ |
break; |
618 |
|
case '\0': /* nothing */ |
619 |
|
break; |
620 |
|
default:; |
634 |
|
int x, y; |
635 |
|
RAY thisray; |
636 |
|
|
637 |
< |
if (sscanf(s, "%lf %lf %lf %lf %lf %lf", |
493 |
< |
&thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2], |
494 |
< |
&thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) { |
637 |
> |
thisray.rmax = 0.0; |
638 |
|
|
639 |
+ |
if (!sscanvec(s, thisray.rorg) || |
640 |
+ |
!sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { |
641 |
+ |
|
642 |
|
if (dev->getcur == NULL) |
643 |
|
return; |
644 |
|
(*dev->comout)("Pick ray\n"); |
645 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
646 |
|
return; |
647 |
|
|
648 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
649 |
< |
(x+.5)/hresolu, (y+.5)/vresolu) < 0) { |
648 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
649 |
> |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
650 |
|
error(COMMAND, "not on image"); |
651 |
|
return; |
652 |
|
} |
663 |
|
if (thisray.ro == NULL) |
664 |
|
(*dev->comout)("ray hit nothing"); |
665 |
|
else { |
666 |
< |
sprintf(buf, "ray hit %s %s \"%s\"", |
667 |
< |
objptr(thisray.ro->omod)->oname, |
666 |
> |
sprintf(buf, "ray hit %s%s %s \"%s\"", |
667 |
> |
thisray.rod < 0.0 ? "back of " : "", |
668 |
> |
thisray.ro->omod == OVOID ? VOIDID : |
669 |
> |
objptr(thisray.ro->omod)->oname, |
670 |
|
ofun[thisray.ro->otype].funame, |
671 |
|
thisray.ro->oname); |
672 |
|
(*dev->comout)(buf); |
679 |
|
(*dev->comout)(buf); |
680 |
|
} |
681 |
|
(*dev->comin)(buf, NULL); |
682 |
< |
sprintf(buf, "with value (%.6g %.6g %.6g)", |
682 |
> |
sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)", |
683 |
|
colval(thisray.rcol,RED), |
684 |
|
colval(thisray.rcol,GRN), |
685 |
< |
colval(thisray.rcol,BLU)); |
685 |
> |
colval(thisray.rcol,BLU), |
686 |
> |
luminance(thisray.rcol)); |
687 |
|
(*dev->comout)(buf); |
688 |
|
} |
689 |
|
(*dev->comin)(buf, NULL); |
699 |
|
COLR *scanline; |
700 |
|
int y; |
701 |
|
|
702 |
< |
if (sscanf(s, "%s", buf) != 1 && buf[0] == '\0') { |
702 |
> |
while (isspace(*s)) |
703 |
> |
s++; |
704 |
> |
if (*s) |
705 |
> |
atos(buf, sizeof(buf), s); |
706 |
> |
else if (buf[0] == '\0') { |
707 |
|
error(COMMAND, "no file"); |
708 |
|
return; |
709 |
|
} |
713 |
|
error(COMMAND, errmsg); |
714 |
|
return; |
715 |
|
} |
716 |
+ |
#ifdef MSDOS |
717 |
+ |
setmode(fileno(fp), O_BINARY); |
718 |
+ |
#endif |
719 |
|
(*dev->comout)("writing \""); |
720 |
|
(*dev->comout)(fname); |
721 |
|
(*dev->comout)("\"...\n"); |
722 |
|
/* write header */ |
723 |
+ |
newheader("RADIANCE", fp); |
724 |
|
fputs(progname, fp); |
725 |
|
fprintview(&ourview, fp); |
726 |
|
if (octname != NULL) |
734 |
|
fputaspect(dev->pixaspect, fp); |
735 |
|
fputformat(COLRFMT, fp); |
736 |
|
putc('\n', fp); |
737 |
< |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
737 |
> |
fprtresolu(hresolu, vresolu, fp); |
738 |
|
|
739 |
|
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
740 |
|
if (scanline == NULL) { |