14 |
|
|
15 |
|
#include "platform.h" |
16 |
|
#include "ray.h" |
17 |
+ |
#include "ambient.h" |
18 |
|
#include "otypes.h" |
19 |
|
#include "rpaint.h" |
20 |
|
|
35 |
|
extern char *octname; |
36 |
|
|
37 |
|
|
38 |
< |
void |
39 |
< |
getframe(s) /* get a new frame */ |
40 |
< |
char *s; |
38 |
> |
extern void |
39 |
> |
getframe( /* get a new frame */ |
40 |
> |
char *s |
41 |
> |
) |
42 |
|
{ |
43 |
|
if (getrect(s, &pframe) < 0) |
44 |
|
return; |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
< |
void |
50 |
< |
getrepaint(s) /* get area and repaint */ |
51 |
< |
char *s; |
49 |
> |
extern void |
50 |
> |
getrepaint( /* get area and repaint */ |
51 |
> |
char *s |
52 |
> |
) |
53 |
|
{ |
54 |
|
RECT box; |
55 |
|
|
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
< |
void |
63 |
< |
getview(s) /* get/show view parameters */ |
64 |
< |
char *s; |
62 |
> |
extern void |
63 |
> |
getview( /* get/show view parameters */ |
64 |
> |
char *s |
65 |
> |
) |
66 |
|
{ |
67 |
|
FILE *fp; |
68 |
|
char buf[128]; |
69 |
|
char *fname; |
70 |
|
int change = 0; |
71 |
< |
VIEW nv; |
71 |
> |
VIEW nv = ourview; |
72 |
|
|
73 |
|
while (isspace(*s)) |
74 |
|
s++; |
75 |
|
if (*s == '-') { /* command line parameters */ |
72 |
– |
nv = ourview; |
76 |
|
if (sscanview(&nv, s)) |
77 |
|
newview(&nv); |
78 |
|
else |
100 |
|
if (buf[0] && buf[0] != ourview.type) { |
101 |
|
nv.type = buf[0]; |
102 |
|
change++; |
103 |
< |
} else |
101 |
< |
nv.type = ourview.type; |
103 |
> |
} |
104 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
105 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
106 |
|
(*dev->comout)(buf); |
108 |
|
if (buf[0] == CTRL('C')) return; |
109 |
|
if (sscanvec(buf, nv.vp)) |
110 |
|
change++; |
109 |
– |
else |
110 |
– |
VCOPY(nv.vp, ourview.vp); |
111 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
112 |
< |
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
112 |
> |
ourview.vdir[0]*ourview.vdist, |
113 |
> |
ourview.vdir[1]*ourview.vdist, |
114 |
> |
ourview.vdir[2]*ourview.vdist); |
115 |
|
(*dev->comout)(buf); |
116 |
|
(*dev->comin)(buf, NULL); |
117 |
|
if (buf[0] == CTRL('C')) return; |
118 |
< |
if (sscanvec(buf, nv.vdir)) |
118 |
> |
if (sscanvec(buf, nv.vdir)) { |
119 |
> |
nv.vdist = 1.; |
120 |
|
change++; |
121 |
< |
else |
119 |
< |
VCOPY(nv.vdir, ourview.vdir); |
121 |
> |
} |
122 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
123 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
124 |
|
(*dev->comout)(buf); |
126 |
|
if (buf[0] == CTRL('C')) return; |
127 |
|
if (sscanvec(buf, nv.vup)) |
128 |
|
change++; |
127 |
– |
else |
128 |
– |
VCOPY(nv.vup, ourview.vup); |
129 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
130 |
|
ourview.horiz, ourview.vert); |
131 |
|
(*dev->comout)(buf); |
133 |
|
if (buf[0] == CTRL('C')) return; |
134 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
135 |
|
change++; |
136 |
– |
else { |
137 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
138 |
– |
} |
136 |
|
sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", |
137 |
|
ourview.vfore, ourview.vaft); |
138 |
|
(*dev->comout)(buf); |
140 |
|
if (buf[0] == CTRL('C')) return; |
141 |
|
if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) |
142 |
|
change++; |
146 |
– |
else { |
147 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
148 |
– |
} |
143 |
|
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
144 |
|
ourview.hoff, ourview.voff); |
145 |
|
(*dev->comout)(buf); |
147 |
|
if (buf[0] == CTRL('C')) return; |
148 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
149 |
|
change++; |
156 |
– |
else { |
157 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
158 |
– |
} |
150 |
|
if (change) |
151 |
|
newview(&nv); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
< |
void |
156 |
< |
lastview(s) /* return to a previous view */ |
157 |
< |
char *s; |
155 |
> |
extern void |
156 |
> |
lastview( /* return to a previous view */ |
157 |
> |
char *s |
158 |
> |
) |
159 |
|
{ |
160 |
|
char buf[128]; |
161 |
|
char *fname; |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
< |
void |
191 |
< |
saveview(s) /* save view to rad file */ |
192 |
< |
char *s; |
190 |
> |
extern void |
191 |
> |
saveview( /* save view to rad file */ |
192 |
> |
char *s |
193 |
> |
) |
194 |
|
{ |
195 |
|
char view[64]; |
196 |
|
char *fname; |
225 |
|
} |
226 |
|
|
227 |
|
|
228 |
< |
void |
229 |
< |
loadview(s) /* load view from rad file */ |
230 |
< |
char *s; |
228 |
> |
extern void |
229 |
> |
loadview( /* load view from rad file */ |
230 |
> |
char *s |
231 |
> |
) |
232 |
|
{ |
233 |
|
char buf[512]; |
234 |
|
char *fname; |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
< |
void |
272 |
< |
getaim(s) /* aim camera */ |
273 |
< |
char *s; |
271 |
> |
extern void |
272 |
> |
getaim( /* aim camera */ |
273 |
> |
char *s |
274 |
> |
) |
275 |
|
{ |
276 |
+ |
VIEW nv = ourview; |
277 |
|
double zfact; |
282 |
– |
VIEW nv; |
278 |
|
|
279 |
|
if (getinterest(s, 1, nv.vdir, &zfact) < 0) |
280 |
|
return; |
286 |
– |
nv.type = ourview.type; |
287 |
– |
VCOPY(nv.vp, ourview.vp); |
288 |
– |
VCOPY(nv.vup, ourview.vup); |
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; |
281 |
|
zoomview(&nv, zfact); |
282 |
|
newview(&nv); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
< |
void |
287 |
< |
getmove(s) /* move camera */ |
288 |
< |
char *s; |
286 |
> |
extern void |
287 |
> |
getfocus( /* set focus distance */ |
288 |
> |
char *s |
289 |
> |
) |
290 |
|
{ |
291 |
|
FVECT vc; |
292 |
+ |
double dist; |
293 |
+ |
|
294 |
+ |
if (sscanf(s, "%lf", &dist) < 1) { |
295 |
+ |
int x, y; |
296 |
+ |
RAY thisray; |
297 |
+ |
if (dev->getcur == NULL) |
298 |
+ |
return; |
299 |
+ |
(*dev->comout)("Pick focus point\n"); |
300 |
+ |
if ((*dev->getcur)(&x, &y) == ABORT) |
301 |
+ |
return; |
302 |
+ |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
303 |
+ |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
304 |
+ |
error(COMMAND, "not on image"); |
305 |
+ |
return; |
306 |
+ |
} |
307 |
+ |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
308 |
+ |
if (!localhit(&thisray, &thescene)) { |
309 |
+ |
error(COMMAND, "not a local object"); |
310 |
+ |
return; |
311 |
+ |
} |
312 |
+ |
dist = thisray.rot; |
313 |
+ |
} else if (dist <= .0) { |
314 |
+ |
error(COMMAND, "focus distance must be positive"); |
315 |
+ |
return; |
316 |
+ |
} |
317 |
+ |
ourview.vdist = dist; |
318 |
+ |
} |
319 |
+ |
|
320 |
+ |
|
321 |
+ |
extern void |
322 |
+ |
getmove( /* move camera */ |
323 |
+ |
char *s |
324 |
+ |
) |
325 |
+ |
{ |
326 |
+ |
FVECT vc; |
327 |
|
double mag; |
328 |
|
|
329 |
|
if (getinterest(s, 0, vc, &mag) < 0) |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
< |
void |
336 |
< |
getrotate(s) /* rotate camera */ |
337 |
< |
char *s; |
335 |
> |
extern void |
336 |
> |
getrotate( /* rotate camera */ |
337 |
> |
char *s |
338 |
> |
) |
339 |
|
{ |
340 |
< |
VIEW nv; |
340 |
> |
VIEW nv = ourview; |
341 |
|
FVECT v1; |
342 |
|
double angle, elev, zfact; |
343 |
|
|
346 |
|
error(COMMAND, "missing angle"); |
347 |
|
return; |
348 |
|
} |
323 |
– |
nv.type = ourview.type; |
324 |
– |
VCOPY(nv.vp, ourview.vp); |
325 |
– |
VCOPY(nv.vup, ourview.vup); |
326 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
327 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
349 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
350 |
|
if (elev != 0.0) { |
351 |
|
fcross(v1, nv.vdir, ourview.vup); |
352 |
|
normalize(v1); |
353 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
354 |
|
} |
334 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
355 |
|
zoomview(&nv, zfact); |
356 |
|
newview(&nv); |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
< |
void |
361 |
< |
getpivot(s) /* pivot viewpoint */ |
362 |
< |
register char *s; |
360 |
> |
extern void |
361 |
> |
getpivot( /* pivot viewpoint */ |
362 |
> |
register char *s |
363 |
> |
) |
364 |
|
{ |
365 |
|
FVECT vc; |
366 |
|
double angle, elev, mag; |
376 |
|
} |
377 |
|
|
378 |
|
|
379 |
< |
void |
380 |
< |
getexposure(s) /* get new exposure */ |
381 |
< |
char *s; |
379 |
> |
extern void |
380 |
> |
getexposure( /* get new exposure */ |
381 |
> |
char *s |
382 |
> |
) |
383 |
|
{ |
384 |
|
char buf[128]; |
385 |
|
register char *cp; |
445 |
|
|
446 |
|
typedef union {int i; double d; COLOR C;} *MyUptr; |
447 |
|
|
448 |
< |
int |
449 |
< |
getparam(str, dsc, typ, p) /* get variable from user */ |
450 |
< |
char *str, *dsc; |
451 |
< |
int typ; |
452 |
< |
void *p; |
448 |
> |
extern int |
449 |
> |
getparam( /* get variable from user */ |
450 |
> |
char *str, |
451 |
> |
char *dsc, |
452 |
> |
int typ, |
453 |
> |
void *p |
454 |
> |
) |
455 |
|
{ |
456 |
|
register MyUptr ptr = (MyUptr)p; |
457 |
|
int i0; |
508 |
|
setcolor(ptr->C, d0, d1, d2); |
509 |
|
return(1); |
510 |
|
} |
511 |
+ |
return 0; /* nothing matched */ |
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
< |
void |
516 |
< |
setparam(s) /* get/set program parameter */ |
517 |
< |
register char *s; |
515 |
> |
extern void |
516 |
> |
setparam( /* get/set program parameter */ |
517 |
> |
register char *s |
518 |
> |
) |
519 |
|
{ |
520 |
|
char buf[128]; |
521 |
|
|
687 |
|
} |
688 |
|
|
689 |
|
|
690 |
< |
void |
690 |
> |
extern void |
691 |
|
traceray(s) /* trace a single ray */ |
692 |
|
char *s; |
693 |
|
{ |
756 |
|
} |
757 |
|
|
758 |
|
|
759 |
< |
void |
759 |
> |
extern void |
760 |
|
writepict(s) /* write the picture to a file */ |
761 |
|
char *s; |
762 |
|
{ |