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 */ |
76 |
– |
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 |
105 |
< |
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++; |
113 |
– |
else |
114 |
– |
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 |
123 |
< |
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++; |
131 |
– |
else |
132 |
– |
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++; |
140 |
– |
else { |
141 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
142 |
– |
} |
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++; |
150 |
– |
else { |
151 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
152 |
– |
} |
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++; |
160 |
– |
else { |
161 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
162 |
– |
} |
150 |
|
if (change) |
151 |
|
newview(&nv); |
152 |
|
} |
273 |
|
char *s |
274 |
|
) |
275 |
|
{ |
276 |
+ |
VIEW nv = ourview; |
277 |
|
double zfact; |
290 |
– |
VIEW nv; |
278 |
|
|
279 |
|
if (getinterest(s, 1, nv.vdir, &zfact) < 0) |
280 |
|
return; |
294 |
– |
nv.type = ourview.type; |
295 |
– |
VCOPY(nv.vp, ourview.vp); |
296 |
– |
VCOPY(nv.vup, ourview.vup); |
297 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
298 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
299 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
281 |
|
zoomview(&nv, zfact); |
282 |
|
newview(&nv); |
283 |
|
} |
284 |
|
|
285 |
|
|
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 |
|
) |
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 |
|
} |
333 |
– |
nv.type = ourview.type; |
334 |
– |
VCOPY(nv.vp, ourview.vp); |
335 |
– |
VCOPY(nv.vup, ourview.vup); |
336 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
337 |
– |
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 |
|
} |
344 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
355 |
|
zoomview(&nv, zfact); |
356 |
|
newview(&nv); |
357 |
|
} |