66 |
|
int currentview = 0; /* current view number */ |
67 |
|
VIEW thisview = STDVIEW; /* displayed view */ |
68 |
|
VIEW lastview; /* last recorded view */ |
69 |
– |
char *lastvc = NULL; /* cause of last view change */ |
69 |
|
|
70 |
|
char *progname; /* global argv[0] */ |
71 |
|
char *radfile; /* rad input file */ |
79 |
|
|
80 |
|
int displist; /* our scene display list */ |
81 |
|
|
82 |
+ |
int in_dev_view = 0; /* currently in dev_view() */ |
83 |
+ |
|
84 |
|
extern char *fgets(), *fgetline(), *atos(), *scan4var(); |
85 |
|
extern int nowarn; /* turn warnings off? */ |
86 |
|
extern time_t time(); |
117 |
|
/* run rad and get views */ |
118 |
|
runrad(argc-i, argv+i); |
119 |
|
/* check view */ |
120 |
< |
if (viewsel != NULL && (currentview = findvw(viewsel)) < 0) { |
121 |
< |
fprintf(stderr, "%s: no such view\n", viewsel); |
122 |
< |
quit(1); |
123 |
< |
} |
120 |
> |
if (viewsel != NULL) |
121 |
> |
if (viewsel[0] == '-') { |
122 |
> |
char *ve = viewsel; |
123 |
> |
if (!sscanview(&thisview, viewsel) || |
124 |
> |
(ve = setview(&thisview)) != NULL) { |
125 |
> |
fprintf(stderr, "%s: bad view: %s\n", |
126 |
> |
progname, ve); |
127 |
> |
quit(1); |
128 |
> |
} |
129 |
> |
currentview = -1; |
130 |
> |
} else if ((currentview = findvw(viewsel)) < 0) { |
131 |
> |
fprintf(stderr, "%s: no such view: %s\n", |
132 |
> |
progname, viewsel); |
133 |
> |
quit(1); |
134 |
> |
} |
135 |
|
/* open GL */ |
136 |
|
dev_open(radfile = argv[i]); |
137 |
|
/* load octree or scene files */ |
141 |
|
} else |
142 |
|
displist = rgl_filelist(nscenef, scene); |
143 |
|
/* set initial view */ |
144 |
< |
dev_view(vwl[currentview].v); |
144 |
> |
dev_view(currentview < 0 ? &thisview : vwl[currentview].v); |
145 |
|
/* input/render loop */ |
146 |
|
while (dev_input(vwintvl)) |
147 |
|
; |
148 |
|
/* all done */ |
149 |
|
quit(0); |
150 |
|
userr: |
151 |
< |
fprintf(stderr, "Usage: %s [-w][-c #secs][-v view] rfile [VAR=value]..\n", |
151 |
> |
fprintf(stderr, "Usage: %s [-w][-b][-v view] rfile [VAR=value]..\n", |
152 |
|
argv[0]); |
153 |
|
quit(1); |
154 |
|
} |
216 |
|
expval = atof(cp); |
217 |
|
if (*cp == '-' | *cp == '+') |
218 |
|
expval = pow(2., expval); |
219 |
+ |
expval *= 0.5; /* compensate for local shading */ |
220 |
|
} |
221 |
|
/* look for materials */ |
222 |
|
while ((cp = scan4var(buf, sizeof(buf), "materials", fp)) != NULL) { |
397 |
|
DisplayHeight(ourdisplay, ourscreen); |
398 |
|
/* map the window */ |
399 |
|
XMapWindow(ourdisplay, gwind); |
400 |
+ |
do |
401 |
+ |
dev_input(0); /* get resize event */ |
402 |
+ |
while (hres == 0 & vres == 0); |
403 |
|
rgl_checkerr("initializing GLX"); |
404 |
|
} |
405 |
|
|
435 |
|
} |
436 |
|
if (hres != 0 & vres != 0) { |
437 |
|
wa = (vres*pheight)/(hres*pwidth); |
438 |
< |
va = viewaspect(&thisview); |
438 |
> |
va = viewaspect(nv); |
439 |
|
if (va > wa+.05) { |
440 |
|
newvres = (pwidth/pheight)*va*newhres + .5; |
441 |
|
if (newvres > maxvres) { |
450 |
|
} |
451 |
|
} |
452 |
|
if (newhres != hres | newvres != vres) { |
453 |
+ |
in_dev_view++; |
454 |
|
XResizeWindow(ourdisplay, gwind, newhres, newvres); |
455 |
|
do |
456 |
|
dev_input(0); /* get resize event */ |
457 |
|
while (newhres != hres | newvres != vres); |
458 |
+ |
in_dev_view--; |
459 |
|
} |
460 |
|
} |
461 |
|
copystruct(&thisview, nv); |
572 |
|
int rootx, rooty, wx, wy; |
573 |
|
unsigned int statemask; |
574 |
|
|
575 |
< |
copylastv("moving"); |
575 |
> |
copylastv( movorb ? (movdir ? "left/right" : "up/down") : |
576 |
> |
(movdir ? "fore/back" : "rotate") ); |
577 |
|
XNoOp(ourdisplay); |
578 |
|
|
579 |
|
while (!XCheckMaskEvent(ourdisplay, |
628 |
|
{ |
629 |
|
double d, xmin, xmax, ymin, ymax, zmin, zmax; |
630 |
|
|
631 |
< |
zmin = 0.05; |
632 |
< |
zmax = 5000.; |
631 |
> |
zmin = 0.1; |
632 |
> |
zmax = 1000.; |
633 |
|
if (thisview.vfore > FTINY) |
634 |
|
zmin = thisview.vfore; |
635 |
|
if (thisview.vaft > FTINY) |
673 |
|
headlocked = 0; |
674 |
|
break; |
675 |
|
case 'l': /* retrieve last (premouse) view */ |
676 |
< |
if (lastvc != NULL) { |
676 |
> |
if (lastview.type) { |
677 |
|
VIEW vtmp; |
678 |
|
copystruct(&vtmp, &thisview); |
679 |
|
dev_view(&lastview); |
747 |
|
vwnum = 0; |
748 |
|
if (vwnum == currentview) |
749 |
|
return; |
750 |
+ |
/* copylastv("change view"); */ |
751 |
|
dev_view(vwl[currentview=vwnum].v); |
752 |
|
} |
753 |
|
|
788 |
|
copylastv(cause) /* copy last view position */ |
789 |
|
char *cause; |
790 |
|
{ |
791 |
+ |
static char *lastvc; |
792 |
+ |
|
793 |
|
if (cause == lastvc) |
794 |
|
return; /* only record one view per cause */ |
795 |
|
lastvc = cause; |
820 |
|
glViewport(0, 0, hres=ersz->width, vres=ersz->height); |
821 |
|
if (hres > maxhres) maxhres = hres; |
822 |
|
if (vres > maxvres) maxvres = vres; |
823 |
+ |
if (in_dev_view) |
824 |
+ |
return; |
825 |
|
wa = (vres*pheight)/(hres*pwidth); |
826 |
|
va = viewaspect(&thisview); |
827 |
|
if (va > wa+.05) { |