158 |
|
oursizhints.min_height = MINHEIGHT; |
159 |
|
oursizhints.flags = PMinSize; |
160 |
|
XSetNormalHints(ourdisplay, gwind, &oursizhints); |
161 |
+ |
/* figure out sensible view */ |
162 |
+ |
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
163 |
+ |
DisplayWidth(ourdisplay, ourscreen); |
164 |
+ |
pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / |
165 |
+ |
DisplayHeight(ourdisplay, ourscreen); |
166 |
+ |
copystruct(&odev.v, &stdview); |
167 |
+ |
odev.v.type = VT_PER; |
168 |
|
/* map the window and get its size */ |
169 |
|
XMapWindow(ourdisplay, gwind); |
170 |
< |
dev_input(); |
170 |
> |
dev_input(); /* sets size and view angles */ |
171 |
|
/* allocate our leaf pile */ |
172 |
|
if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * |
173 |
|
DisplayHeight(ourdisplay,ourscreen) / |
174 |
|
(qtMinNodesiz*qtMinNodesiz))) |
175 |
|
error(SYSTEM, "insufficient memory for leaf storage"); |
169 |
– |
|
170 |
– |
/* figure out sensible view */ |
171 |
– |
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
172 |
– |
DisplayWidth(ourdisplay, ourscreen); |
173 |
– |
pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / |
174 |
– |
DisplayHeight(ourdisplay, ourscreen); |
175 |
– |
copystruct(&odev.v, &stdview); |
176 |
|
odev.name = id; |
177 |
– |
odev.v.type = VT_PER; |
178 |
– |
odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); |
179 |
– |
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
177 |
|
odev.ifd = ConnectionNumber(ourdisplay); |
178 |
|
} |
179 |
|
|
200 |
|
VIEW *nv; |
201 |
|
{ |
202 |
|
if (nv->type == VT_PAR || /* check view legality */ |
203 |
< |
nv->horiz > 160. || nv->vert > 160.) { |
203 |
> |
nv->horiz > 160. || nv->vert > 160.) { |
204 |
|
error(COMMAND, "illegal view type/angle"); |
205 |
|
nv->type = VT_PER; |
206 |
|
nv->horiz = odev.v.horiz; |
219 |
|
int dh = DisplayHeight(ourdisplay,ourscreen); |
220 |
|
|
221 |
|
dw -= 25; /* for window frame */ |
222 |
< |
dh -= 100; |
222 |
> |
dh -= 50; |
223 |
|
odev.hres = 2.*VIEWDIST/pwidth * |
224 |
|
tan(PI/180./2.*nv->horiz); |
225 |
|
odev.vres = 2.*VIEWDIST/pheight * |
233 |
|
odev.vres = dh; |
234 |
|
} |
235 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
236 |
+ |
dev_input(); /* wait for resize event */ |
237 |
|
} |
238 |
|
copystruct(&odev.v, nv); |
239 |
|
} |
470 |
|
int dx, dy, mov, orb; |
471 |
|
{ |
472 |
|
VIEW nv; |
473 |
< |
FVECT v1; |
473 |
> |
FVECT odir, v1; |
474 |
|
double d; |
475 |
|
register int li; |
476 |
|
/* start with old view */ |
479 |
|
if (mov | orb) { |
480 |
|
if ((li = qtFindLeaf(dx, dy)) < 0) |
481 |
|
return(0); /* not on window */ |
482 |
< |
VSUM(nv.vdir, qtL.wp[li], nv.vp, -1.); |
482 |
> |
VSUM(odir, qtL.wp[li], nv.vp, -1.); |
483 |
|
} else { |
484 |
|
if (viewray(nv.vp, nv.vdir, &odev.v, |
485 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
486 |
|
return(0); /* outside view */ |
487 |
|
} |
488 |
|
if (orb && mov) { /* orbit left/right */ |
489 |
< |
spinvector(nv.vdir, nv.vdir, nv.vup, MOVDEG*PI/180.*mov); |
490 |
< |
VSUM(nv.vp, qtL.wp[li], nv.vdir, -1.); |
489 |
> |
spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov); |
490 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
491 |
> |
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
492 |
|
} else if (orb) { /* orbit up/down */ |
493 |
< |
fcross(v1, nv.vdir, nv.vup); |
493 |
> |
fcross(v1, odir, nv.vup); |
494 |
|
if (normalize(v1) == 0.) |
495 |
|
return(0); |
496 |
< |
spinvector(nv.vdir, nv.vdir, v1, MOVDEG*PI/180.*orb); |
497 |
< |
VSUM(nv.vp, qtL.wp[li], nv.vdir, -1.); |
496 |
> |
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
497 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
498 |
> |
spinvector(nv.vdir, nv.vdir, v1, d); |
499 |
|
} else if (mov) { /* move forward/backward */ |
500 |
|
d = MOVPCT/100. * mov; |
501 |
< |
VSUM(nv.vp, nv.vp, nv.vdir, d); |
501 |
> |
VSUM(nv.vp, nv.vp, odir, d); |
502 |
|
} |
503 |
|
if (!mov ^ !orb && headlocked) { /* restore head height */ |
504 |
|
VSUM(v1, odev.v.vp, nv.vp, -1.); |
600 |
|
new_ctab(ncolors); |
601 |
|
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
602 |
|
return; |
603 |
+ |
case 'K': /* kill rtrace process(es) */ |
604 |
+ |
inpresflags |= DFL(DC_KILL); |
605 |
+ |
break; |
606 |
+ |
case 'R': /* restart rtrace */ |
607 |
+ |
inpresflags |= DFL(DC_RESTART); |
608 |
+ |
break; |
609 |
+ |
case 'C': /* clobber holodeck */ |
610 |
+ |
inpresflags |= DFL(DC_CLOBBER); |
611 |
+ |
break; |
612 |
|
case 'q': /* quit the program */ |
613 |
|
inpresflags |= DFL(DC_QUIT); |
614 |
|
return; |