7 |
|
* External symbols declared in rpaint.h |
8 |
|
*/ |
9 |
|
|
10 |
– |
#include <ctype.h> |
11 |
– |
|
10 |
|
#include "copyright.h" |
11 |
|
|
12 |
+ |
#include <ctype.h> |
13 |
+ |
#include <string.h> |
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 */ |
71 |
– |
copystruct(&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 |
100 |
< |
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++; |
108 |
– |
else |
109 |
– |
VCOPY(nv.vp, ourview.vp); |
111 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
112 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
113 |
|
(*dev->comout)(buf); |
115 |
|
if (buf[0] == CTRL('C')) return; |
116 |
|
if (sscanvec(buf, nv.vdir)) |
117 |
|
change++; |
117 |
– |
else |
118 |
– |
VCOPY(nv.vdir, ourview.vdir); |
118 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
119 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
120 |
|
(*dev->comout)(buf); |
122 |
|
if (buf[0] == CTRL('C')) return; |
123 |
|
if (sscanvec(buf, nv.vup)) |
124 |
|
change++; |
126 |
– |
else |
127 |
– |
VCOPY(nv.vup, ourview.vup); |
125 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
126 |
|
ourview.horiz, ourview.vert); |
127 |
|
(*dev->comout)(buf); |
129 |
|
if (buf[0] == CTRL('C')) return; |
130 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
131 |
|
change++; |
135 |
– |
else { |
136 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
137 |
– |
} |
132 |
|
sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", |
133 |
|
ourview.vfore, ourview.vaft); |
134 |
|
(*dev->comout)(buf); |
136 |
|
if (buf[0] == CTRL('C')) return; |
137 |
|
if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) |
138 |
|
change++; |
145 |
– |
else { |
146 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
147 |
– |
} |
139 |
|
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
140 |
|
ourview.hoff, ourview.voff); |
141 |
|
(*dev->comout)(buf); |
143 |
|
if (buf[0] == CTRL('C')) return; |
144 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
145 |
|
change++; |
155 |
– |
else { |
156 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
157 |
– |
} |
146 |
|
if (change) |
147 |
|
newview(&nv); |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
< |
void |
152 |
< |
lastview(s) /* return to a previous view */ |
153 |
< |
char *s; |
151 |
> |
extern void |
152 |
> |
lastview( /* return to a previous view */ |
153 |
> |
char *s |
154 |
> |
) |
155 |
|
{ |
156 |
|
char buf[128]; |
157 |
|
char *fname; |
159 |
|
VIEW nv; |
160 |
|
|
161 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
162 |
< |
copystruct(&nv, &stdview); |
162 |
> |
nv = stdview; |
163 |
|
if ((fname = getpath(buf, "", R_OK)) == NULL || |
164 |
|
(success = viewfile(fname, &nv, NULL)) == -1) { |
165 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
176 |
|
error(COMMAND, "no previous view"); |
177 |
|
return; |
178 |
|
} |
179 |
< |
copystruct(&nv, &ourview); |
180 |
< |
copystruct(&ourview, &oldview); |
181 |
< |
copystruct(&oldview, &nv); |
179 |
> |
nv = ourview; |
180 |
> |
ourview = oldview; |
181 |
> |
oldview = nv; |
182 |
|
newimage(); |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
< |
void |
187 |
< |
saveview(s) /* save view to rad file */ |
188 |
< |
char *s; |
186 |
> |
extern void |
187 |
> |
saveview( /* save view to rad file */ |
188 |
> |
char *s |
189 |
> |
) |
190 |
|
{ |
191 |
|
char view[64]; |
192 |
|
char *fname; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
void |
225 |
< |
loadview(s) /* load view from rad file */ |
226 |
< |
char *s; |
224 |
> |
extern void |
225 |
> |
loadview( /* load view from rad file */ |
226 |
> |
char *s |
227 |
> |
) |
228 |
|
{ |
229 |
|
char buf[512]; |
230 |
|
char *fname; |
255 |
|
buf[0] = '\0'; |
256 |
|
fgets(buf, sizeof(buf), fp); |
257 |
|
pclose(fp); |
258 |
< |
copystruct(&nv, &stdview); |
258 |
> |
nv = stdview; |
259 |
|
if (!sscanview(&nv, buf)) { |
260 |
|
error(COMMAND, "rad error -- no such view?"); |
261 |
|
return; |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
< |
void |
268 |
< |
getaim(s) /* aim camera */ |
269 |
< |
char *s; |
267 |
> |
extern void |
268 |
> |
getaim( /* aim camera */ |
269 |
> |
char *s |
270 |
> |
) |
271 |
|
{ |
272 |
+ |
VIEW nv = ourview; |
273 |
|
double zfact; |
281 |
– |
VIEW nv; |
274 |
|
|
275 |
|
if (getinterest(s, 1, nv.vdir, &zfact) < 0) |
276 |
|
return; |
285 |
– |
nv.type = ourview.type; |
286 |
– |
VCOPY(nv.vp, ourview.vp); |
287 |
– |
VCOPY(nv.vup, ourview.vup); |
288 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
289 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
290 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
277 |
|
zoomview(&nv, zfact); |
278 |
|
newview(&nv); |
279 |
|
} |
280 |
|
|
281 |
|
|
282 |
< |
void |
283 |
< |
getmove(s) /* move camera */ |
284 |
< |
char *s; |
282 |
> |
extern void |
283 |
> |
getmove( /* move camera */ |
284 |
> |
char *s |
285 |
> |
) |
286 |
|
{ |
287 |
|
FVECT vc; |
288 |
|
double mag; |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
< |
void |
297 |
< |
getrotate(s) /* rotate camera */ |
298 |
< |
char *s; |
296 |
> |
extern void |
297 |
> |
getrotate( /* rotate camera */ |
298 |
> |
char *s |
299 |
> |
) |
300 |
|
{ |
301 |
< |
VIEW nv; |
301 |
> |
VIEW nv = ourview; |
302 |
|
FVECT v1; |
303 |
|
double angle, elev, zfact; |
304 |
|
|
307 |
|
error(COMMAND, "missing angle"); |
308 |
|
return; |
309 |
|
} |
322 |
– |
nv.type = ourview.type; |
323 |
– |
VCOPY(nv.vp, ourview.vp); |
324 |
– |
VCOPY(nv.vup, ourview.vup); |
325 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
326 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
310 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
311 |
|
if (elev != 0.0) { |
312 |
|
fcross(v1, nv.vdir, ourview.vup); |
313 |
|
normalize(v1); |
314 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
315 |
|
} |
333 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
316 |
|
zoomview(&nv, zfact); |
317 |
|
newview(&nv); |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
< |
void |
322 |
< |
getpivot(s) /* pivot viewpoint */ |
323 |
< |
register char *s; |
321 |
> |
extern void |
322 |
> |
getpivot( /* pivot viewpoint */ |
323 |
> |
register char *s |
324 |
> |
) |
325 |
|
{ |
326 |
|
FVECT vc; |
327 |
|
double angle, elev, mag; |
337 |
|
} |
338 |
|
|
339 |
|
|
340 |
< |
void |
341 |
< |
getexposure(s) /* get new exposure */ |
342 |
< |
char *s; |
340 |
> |
extern void |
341 |
> |
getexposure( /* get new exposure */ |
342 |
> |
char *s |
343 |
> |
) |
344 |
|
{ |
345 |
|
char buf[128]; |
346 |
|
register char *cp; |
406 |
|
|
407 |
|
typedef union {int i; double d; COLOR C;} *MyUptr; |
408 |
|
|
409 |
< |
int |
410 |
< |
getparam(str, dsc, typ, p) /* get variable from user */ |
411 |
< |
char *str, *dsc; |
412 |
< |
int typ; |
413 |
< |
void *p; |
409 |
> |
extern int |
410 |
> |
getparam( /* get variable from user */ |
411 |
> |
char *str, |
412 |
> |
char *dsc, |
413 |
> |
int typ, |
414 |
> |
void *p |
415 |
> |
) |
416 |
|
{ |
417 |
|
register MyUptr ptr = (MyUptr)p; |
418 |
|
int i0; |
449 |
|
(*dev->comout)(buf); |
450 |
|
(*dev->comin)(buf, NULL); |
451 |
|
if (buf[0] == '\0' || |
452 |
< |
index("yY+1tTnN-0fF", buf[0]) == NULL) |
452 |
> |
strchr("yY+1tTnN-0fF", buf[0]) == NULL) |
453 |
|
return(0); |
454 |
|
} |
455 |
< |
ptr->i = index("yY+1tT", buf[0]) != NULL; |
455 |
> |
ptr->i = strchr("yY+1tT", buf[0]) != NULL; |
456 |
|
return(1); |
457 |
|
case 'C': /* color */ |
458 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
469 |
|
setcolor(ptr->C, d0, d1, d2); |
470 |
|
return(1); |
471 |
|
} |
472 |
+ |
return 0; /* nothing matched */ |
473 |
|
} |
474 |
|
|
475 |
|
|
476 |
< |
void |
477 |
< |
setparam(s) /* get/set program parameter */ |
478 |
< |
register char *s; |
476 |
> |
extern void |
477 |
> |
setparam( /* get/set program parameter */ |
478 |
> |
register char *s |
479 |
> |
) |
480 |
|
{ |
481 |
|
char buf[128]; |
482 |
|
|
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
< |
void |
651 |
> |
extern void |
652 |
|
traceray(s) /* trace a single ray */ |
653 |
|
char *s; |
654 |
|
{ |
717 |
|
} |
718 |
|
|
719 |
|
|
720 |
< |
void |
720 |
> |
extern void |
721 |
|
writepict(s) /* write the picture to a file */ |
722 |
|
char *s; |
723 |
|
{ |