1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 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 |
+ |
|
34 |
|
extern char VersionID[]; |
35 |
|
extern char *progname; |
36 |
|
extern char *octname; |
65 |
|
int change = 0; |
66 |
|
VIEW nv; |
67 |
|
|
68 |
+ |
while (isspace(*s)) |
69 |
+ |
s++; |
70 |
+ |
if (*s == '-') { /* command line parameters */ |
71 |
+ |
copystruct(&nv, &ourview); |
72 |
+ |
if (sscanview(&nv, s)) |
73 |
+ |
newview(&nv); |
74 |
+ |
else |
75 |
+ |
error(COMMAND, "bad view option(s)"); |
76 |
+ |
return; |
77 |
+ |
} |
78 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
79 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
80 |
|
(fp = fopen(fname, "a")) == NULL) { |
92 |
|
sprintf(buf, "view type (%c): ", ourview.type); |
93 |
|
(*dev->comout)(buf); |
94 |
|
(*dev->comin)(buf, NULL); |
95 |
< |
if (buf[0] == CTRL(C)) return; |
95 |
> |
if (buf[0] == CTRL('C')) return; |
96 |
|
if (buf[0] && buf[0] != ourview.type) { |
97 |
|
nv.type = buf[0]; |
98 |
|
change++; |
102 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
103 |
|
(*dev->comout)(buf); |
104 |
|
(*dev->comin)(buf, NULL); |
105 |
< |
if (buf[0] == CTRL(C)) return; |
106 |
< |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
105 |
> |
if (buf[0] == CTRL('C')) return; |
106 |
> |
if (sscanvec(buf, nv.vp)) |
107 |
|
change++; |
108 |
|
else |
109 |
|
VCOPY(nv.vp, ourview.vp); |
111 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
112 |
|
(*dev->comout)(buf); |
113 |
|
(*dev->comin)(buf, NULL); |
114 |
< |
if (buf[0] == CTRL(C)) return; |
115 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
114 |
> |
if (buf[0] == CTRL('C')) return; |
115 |
> |
if (sscanvec(buf, nv.vdir)) |
116 |
|
change++; |
117 |
|
else |
118 |
|
VCOPY(nv.vdir, ourview.vdir); |
120 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
121 |
|
(*dev->comout)(buf); |
122 |
|
(*dev->comin)(buf, NULL); |
123 |
< |
if (buf[0] == CTRL(C)) return; |
124 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
123 |
> |
if (buf[0] == CTRL('C')) return; |
124 |
> |
if (sscanvec(buf, nv.vup)) |
125 |
|
change++; |
126 |
|
else |
127 |
|
VCOPY(nv.vup, ourview.vup); |
129 |
|
ourview.horiz, ourview.vert); |
130 |
|
(*dev->comout)(buf); |
131 |
|
(*dev->comin)(buf, NULL); |
132 |
< |
if (buf[0] == CTRL(C)) return; |
132 |
> |
if (buf[0] == CTRL('C')) return; |
133 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
134 |
|
change++; |
135 |
|
else { |
139 |
|
ourview.hoff, ourview.voff); |
140 |
|
(*dev->comout)(buf); |
141 |
|
(*dev->comin)(buf, NULL); |
142 |
< |
if (buf[0] == CTRL(C)) return; |
142 |
> |
if (buf[0] == CTRL('C')) return; |
143 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
144 |
|
change++; |
145 |
|
else { |
161 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
162 |
|
copystruct(&nv, &stdview); |
163 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
164 |
< |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
164 |
> |
(success = viewfile(fname, &nv, NULL)) == -1) { |
165 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
166 |
|
error(COMMAND, errmsg); |
167 |
|
return; |
186 |
|
getaim(s) /* aim camera */ |
187 |
|
char *s; |
188 |
|
{ |
170 |
– |
extern double tan(), atan(); |
189 |
|
double zfact; |
190 |
|
VIEW nv; |
191 |
|
|
216 |
|
getrotate(s) /* rotate camera */ |
217 |
|
char *s; |
218 |
|
{ |
201 |
– |
extern double normalize(), tan(), atan(); |
219 |
|
VIEW nv; |
220 |
|
FVECT v1; |
221 |
|
double angle, elev, zfact; |
261 |
|
getexposure(s) /* get new exposure */ |
262 |
|
char *s; |
263 |
|
{ |
247 |
– |
double atof(), pow(), fabs(); |
264 |
|
char buf[128]; |
265 |
|
register char *cp; |
266 |
|
register PNODE *p; |
305 |
|
e *= atof(cp); |
306 |
|
} |
307 |
|
if (p != NULL) { /* relative setting */ |
308 |
< |
if (bright(p->v) <= FTINY) { |
308 |
> |
if (bright(p->v) < 1e-25) { |
309 |
|
error(COMMAND, "cannot normalize to zero"); |
310 |
|
return; |
311 |
|
} |
355 |
|
case 'b': /* boolean */ |
356 |
|
if (sscanf(str, "%1s", buf) != 1) { |
357 |
|
(*dev->comout)(dsc); |
358 |
< |
sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n'); |
358 |
> |
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
359 |
|
(*dev->comout)(buf); |
360 |
|
(*dev->comin)(buf, NULL); |
361 |
|
if (buf[0] == '\0' || |
394 |
|
extern double shadcert; |
395 |
|
extern COLOR ambval; |
396 |
|
extern double ambacc; |
381 |
– |
extern double minarad; |
397 |
|
extern int ambres; |
398 |
|
extern int ambdiv; |
399 |
|
extern int ambssamp; |
401 |
|
extern int directinvis; |
402 |
|
extern double srcsizerat; |
403 |
|
extern int do_irrad; |
404 |
+ |
extern double specjitter; |
405 |
+ |
extern double specthresh; |
406 |
|
char buf[128]; |
407 |
|
|
408 |
|
if (s[0] == '\0') { |
409 |
|
(*dev->comout)( |
410 |
< |
"aa ab ad ar as av b dc di dj ds dt i lr lw sp st: "); |
410 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: "); |
411 |
|
(*dev->comin)(buf, NULL); |
412 |
|
s = buf; |
413 |
|
} |
455 |
|
case 'a': /* ambient */ |
456 |
|
switch (s[1]) { |
457 |
|
case 'v': /* value */ |
458 |
< |
getparam(s+2, "ambient value", 'C', ambval); |
458 |
> |
getparam(s+2, "ambient value", 'C', (COLOR *)ambval); |
459 |
|
break; |
460 |
|
case 'a': /* accuracy */ |
461 |
|
getparam(s+2, "ambient accuracy", 'r', &ambacc); |
471 |
|
break; |
472 |
|
case 'r': |
473 |
|
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
474 |
< |
minarad = ambres > 0 ? |
458 |
< |
thescene.cusize/ambres : 0.0; |
474 |
> |
setambres(ambres); |
475 |
|
break; |
476 |
|
default: |
477 |
|
goto badparam; |
478 |
|
} |
479 |
|
break; |
480 |
< |
case 's': /* sample */ |
480 |
> |
case 'p': /* pixel */ |
481 |
|
switch (s[1]) { |
482 |
< |
case 'p': /* pixel */ |
483 |
< |
if (getparam(s+2, "sample pixel", 'i', &psample)) |
482 |
> |
case 's': /* sample */ |
483 |
> |
if (getparam(s+2, "pixel sample", 'i', &psample)) |
484 |
|
pdepth = 0; |
485 |
|
break; |
486 |
|
case 't': /* threshold */ |
487 |
< |
if (getparam(s+2, "sample threshold", 'r', &maxdiff)) |
487 |
> |
if (getparam(s+2, "pixel threshold", 'r', &maxdiff)) |
488 |
|
pdepth = 0; |
489 |
|
break; |
490 |
|
default: |
491 |
|
goto badparam; |
492 |
|
} |
493 |
|
break; |
494 |
+ |
case 's': /* specular */ |
495 |
+ |
switch (s[1]) { |
496 |
+ |
case 'j': /* jitter */ |
497 |
+ |
getparam(s+2, "specular jitter", 'r', &specjitter); |
498 |
+ |
break; |
499 |
+ |
case 't': /* threshold */ |
500 |
+ |
getparam(s+2, "specular threshold", 'r', &specthresh); |
501 |
+ |
break; |
502 |
+ |
default: |
503 |
+ |
goto badparam; |
504 |
+ |
} |
505 |
+ |
break; |
506 |
|
case '\0': /* nothing */ |
507 |
|
break; |
508 |
|
default:; |
522 |
|
int x, y; |
523 |
|
RAY thisray; |
524 |
|
|
525 |
< |
if (sscanf(s, "%lf %lf %lf %lf %lf %lf", |
526 |
< |
&thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2], |
499 |
< |
&thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) { |
525 |
> |
if (!sscanvec(s, thisray.rorg) || |
526 |
> |
!sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { |
527 |
|
|
528 |
|
if (dev->getcur == NULL) |
529 |
|
return; |
610 |
|
fputaspect(dev->pixaspect, fp); |
611 |
|
fputformat(COLRFMT, fp); |
612 |
|
putc('\n', fp); |
613 |
< |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
613 |
> |
fprtresolu(hresolu, vresolu, fp); |
614 |
|
|
615 |
|
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
616 |
|
if (scanline == NULL) { |