27 |
|
#define MAXSCENE 127 /* maximum number of scene files */ |
28 |
|
#endif |
29 |
|
|
30 |
< |
#define ZOOMPCT 9 /* percent to zoom at a time */ |
30 |
> |
#define ZOOMPCT 9 /* percent to zoom for +/- */ |
31 |
> |
#define WZOOMPCT 3 /* percent to zoom for mouse wheel */ |
32 |
|
|
33 |
< |
#define MOVPCT 7 /* percent distance to move /frame */ |
33 |
> |
#define MOVPCT 4 /* percent distance to move /frame */ |
34 |
|
#define MOVDIR(b) ((b)==Button1 ? 1 : (b)==Button2 ? 0 : -1) |
35 |
< |
#define MOVDEG (-5) /* degrees to orbit CW/down /frame */ |
35 |
> |
#define MOVDEG (-1.5) /* degrees to orbit CW/down /frame */ |
36 |
|
#define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0) |
37 |
|
|
38 |
|
#define BORWIDTH 5 /* border width */ |
76 |
|
int nscenef = 0; /* number of scene files */ |
77 |
|
char *octree; /* octree name (NULL if unnec.) */ |
78 |
|
|
79 |
< |
SUBPROC rtpd; /* rtrace process descriptors */ |
79 |
> |
SUBPROC rtpd = SP_INACTIVE; /* rtrace process descriptors */ |
80 |
|
|
81 |
|
int silent = 0; /* run rad silently? */ |
82 |
|
int backvis = 1; /* back faces visible? */ |
98 |
|
|
99 |
|
static void startrtrace(char *octname); |
100 |
|
static void runrad(int ac, char **av); |
101 |
< |
static int findvw(register char *nm); |
102 |
< |
static int varmatch(register char *s, register char *vn); |
101 |
> |
static int findvw(char *nm); |
102 |
> |
static int varmatch(char *s, char *vn); |
103 |
|
static char * scan4var(char *buf, int buflen, char *vname, FILE *fp); |
104 |
|
static void dev_open(char *id); |
105 |
|
static void dev_close(void); |
106 |
< |
static int dev_view(register VIEW *nv); |
106 |
> |
static int dev_view(VIEW *nv); |
107 |
|
static int dev_input(int nsecs); |
108 |
|
static void render(void); |
109 |
|
static int moveview(int dx, int dy, int mov, int orb); |
110 |
|
static void waitabit(void); |
111 |
|
static void getmove(XButtonPressedEvent *ebut); |
112 |
|
static int getintersect(FVECT wp, FVECT org, FVECT dir, double md); |
113 |
< |
static void setglpersp(register VIEW *vp); |
114 |
< |
static int getkey(register XKeyPressedEvent *ekey); |
113 |
> |
static void setglpersp(VIEW *vp); |
114 |
> |
static int getkey(XKeyPressedEvent *ekey); |
115 |
|
static void zoomview(int pct, int dx, int dy); |
116 |
|
static void gotoview(int vwnum); |
117 |
|
static void appendview(char *nm, VIEW *vp); |
118 |
|
static void copylastv(char *cause); |
119 |
< |
static void fixwindow(register XExposeEvent *eexp); |
120 |
< |
static void resizewindow(register XConfigureEvent *ersz); |
119 |
> |
static void fixwindow(XExposeEvent *eexp); |
120 |
> |
static void resizewindow(XConfigureEvent *ersz); |
121 |
|
|
122 |
|
|
123 |
|
int |
204 |
|
|
205 |
|
|
206 |
|
void |
207 |
< |
quit(code) /* exit gracefully */ |
208 |
< |
int code; |
207 |
> |
quit( /* exit gracefully */ |
208 |
> |
int code |
209 |
> |
) |
210 |
|
{ |
211 |
|
if (ourdisplay != NULL) |
212 |
|
dev_close(); |
213 |
|
/* if (rtpd.pid > 0) { */ |
214 |
< |
if (rtpd.running) { |
214 |
> |
if (rtpd.flags & PF_RUNNING) { |
215 |
|
if (close_process(&rtpd) > 0) |
216 |
|
wputs("bad exit status from rtrace\n"); |
217 |
|
/* rtpd.pid = 0; */ |
246 |
|
static char optfile[] = TEMPLATE; |
247 |
|
int nvn = 0, nvv = 0; |
248 |
|
FILE *fp; |
249 |
< |
register char *cp; |
249 |
> |
char *cp; |
250 |
|
char radcomm[256], buf[128], nam[32]; |
251 |
|
/* set rad commmand */ |
252 |
|
strcpy(radcomm, "rad -w -v 0 "); /* look out below! */ |
282 |
|
eyedist = atof(cp); |
283 |
|
/* look for materials */ |
284 |
|
while ((cp = scan4var(buf, sizeof(buf), "materials", fp)) != NULL) { |
285 |
< |
nscenef += wordstring(scene+nscenef, cp); |
285 |
> |
nscenef += wordstring(scene+nscenef, MAXSCENE-nscenef, cp); |
286 |
|
buf[0] = '\0'; |
287 |
|
} |
288 |
|
/* look for octree */ |
290 |
|
octree = savqstr(cp); |
291 |
|
/* look for scene files */ |
292 |
|
while ((cp = scan4var(buf, sizeof(buf), "scene", fp)) != NULL) { |
293 |
< |
nscenef += wordstring(scene+nscenef, cp); |
293 |
> |
nscenef += wordstring(scene+nscenef, MAXSCENE-nscenef, cp); |
294 |
|
buf[0] = '\0'; |
295 |
|
} |
296 |
|
/* load view names */ |
336 |
|
|
337 |
|
static int |
338 |
|
findvw( /* find named view */ |
339 |
< |
register char *nm |
339 |
> |
char *nm |
340 |
|
) |
341 |
|
{ |
342 |
< |
register int n; |
342 |
> |
int n; |
343 |
|
|
344 |
|
if ((*nm >= '1') & (*nm <= '9') && |
345 |
|
(n = atoi(nm)-1) <= MAXVIEW && vwl[n].v != NULL) |
353 |
|
|
354 |
|
static int |
355 |
|
varmatch( /* match line to variable */ |
356 |
< |
register char *s, |
357 |
< |
register char *vn |
356 |
> |
char *s, |
357 |
> |
char *vn |
358 |
|
) |
359 |
|
{ |
360 |
< |
register int c; |
360 |
> |
int c; |
361 |
|
|
362 |
|
for ( ; *vn && *s == *vn; s++, vn++) |
363 |
|
; |
380 |
|
) |
381 |
|
{ |
382 |
|
int cval; |
383 |
< |
register char *cp; |
383 |
> |
char *cp; |
384 |
|
/* search out matching line */ |
385 |
|
while ((cval = varmatch(buf, vname))) { |
386 |
|
if (cval > 0) /* gone too far? */ |
450 |
|
/* set window manager hints */ |
451 |
|
ourxwmhints.flags = InputHint|IconPixmapHint; |
452 |
|
ourxwmhints.input = True; |
453 |
< |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, |
454 |
< |
gwind, glradicon_bits, glradicon_width, glradicon_height); |
453 |
> |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, gwind, |
454 |
> |
(char *)glradicon_bits, glradicon_width, glradicon_height); |
455 |
|
XSetWMHints(ourdisplay, gwind, &ourxwmhints); |
456 |
|
/* set GLX context */ |
457 |
|
glXMakeCurrent(ourdisplay, gwind, gctx); |
502 |
|
|
503 |
|
static int |
504 |
|
dev_view( /* assign new driver view */ |
505 |
< |
register VIEW *nv |
505 |
> |
VIEW *nv |
506 |
|
) |
507 |
|
{ |
508 |
|
int newhres = hres, newvres = vres; |
540 |
|
XResizeWindow(ourdisplay, gwind, newhres, newvres); |
541 |
|
do |
542 |
|
dev_input(0); /* get resize event */ |
543 |
< |
while ((newhres != hres) | (newvres != vres)); |
543 |
> |
while ((newhres != hres) & (newvres != vres)); |
544 |
|
no_render--; |
545 |
|
} |
546 |
|
} |
585 |
|
case KeyPress: |
586 |
|
return(getkey(levptr(XKeyPressedEvent))); |
587 |
|
case ButtonPress: |
588 |
< |
getmove(levptr(XButtonPressedEvent)); |
588 |
> |
switch (levptr(XButtonPressedEvent)->button) { |
589 |
> |
case Button4: /* wheel up */ |
590 |
> |
zoomview(100+WZOOMPCT, levptr(XButtonPressedEvent)->x, |
591 |
> |
vres-1-levptr(XButtonPressedEvent)->y); |
592 |
> |
break; |
593 |
> |
case Button5: /* wheel down */ |
594 |
> |
zoomview(100-WZOOMPCT, levptr(XButtonPressedEvent)->x, |
595 |
> |
vres-1-levptr(XButtonPressedEvent)->y); |
596 |
> |
break; |
597 |
> |
default: |
598 |
> |
getmove(levptr(XButtonPressedEvent)); |
599 |
> |
break; |
600 |
> |
} |
601 |
|
break; |
602 |
|
} |
603 |
|
return(1); |
659 |
|
VSUM(nv.vp, wp, odir, -1.); |
660 |
|
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
661 |
|
} else if (orb) { /* orbit up/down */ |
662 |
< |
fcross(v1, odir, nv.vup); |
663 |
< |
if (normalize(v1) == 0.) |
662 |
> |
if (geodesic(odir, odir, nv.vup, |
663 |
> |
d=MOVDEG*PI/180.*orb, GEOD_RAD) == 0.0) |
664 |
|
return(0); |
651 |
– |
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
665 |
|
VSUM(nv.vp, wp, odir, -1.); |
666 |
< |
spinvector(nv.vdir, nv.vdir, v1, d); |
666 |
> |
geodesic(nv.vdir, nv.vdir, nv.vup, d, GEOD_RAD); |
667 |
|
} else if (mov) { /* move forward/backward */ |
668 |
|
d = MOVPCT/100. * mov; |
669 |
|
VSUM(nv.vp, nv.vp, odir, d); |
685 |
|
{ |
686 |
|
struct timespec ts; |
687 |
|
ts.tv_sec = 0; |
688 |
< |
ts.tv_nsec = 5000000; |
688 |
> |
ts.tv_nsec = 50000000; |
689 |
|
nanosleep(&ts, NULL); |
690 |
|
} |
691 |
|
|
741 |
|
float fbuf[6]; |
742 |
|
/* check to see if rtrace is running */ |
743 |
|
/* if (rtpd.pid <= 0) */ |
744 |
< |
if (!rtpd.running) |
744 |
> |
if (!(rtpd.flags & PF_RUNNING)) |
745 |
|
return(0); |
746 |
|
/* assign origin */ |
747 |
|
fbuf[0] = org[0]; fbuf[1] = org[1]; fbuf[2] = org[2]; |
749 |
|
if (md <= FTINY) md = FHUGE; |
750 |
|
fbuf[3] = dir[0]*md; fbuf[4] = dir[1]*md; fbuf[5] = dir[2]*md; |
751 |
|
/* trace that ray */ |
752 |
< |
if (process(&rtpd, (char *)fbuf, (char *)fbuf, |
752 |
> |
if (process(&rtpd, fbuf, fbuf, |
753 |
|
4*sizeof(float), 6*sizeof(float)) != 4*sizeof(float)) |
754 |
|
error(INTERNAL, "error getting data back from rtrace process"); |
755 |
|
if (fbuf[3] >= .99*FHUGE) |
761 |
|
|
762 |
|
static void |
763 |
|
setglpersp( /* set perspective view in GL */ |
764 |
< |
register VIEW *vp |
764 |
> |
VIEW *vp |
765 |
|
) |
766 |
|
{ |
767 |
|
double d, xmin, xmax, ymin, ymax, zmin, zmax; |
795 |
|
|
796 |
|
static int |
797 |
|
getkey( /* get input key */ |
798 |
< |
register XKeyPressedEvent *ekey |
798 |
> |
XKeyPressedEvent *ekey |
799 |
|
) |
800 |
|
{ |
801 |
|
int n; |
840 |
|
case 'V': /* append view to rad file */ |
841 |
|
appendview(NULL, &thisview); |
842 |
|
break; |
843 |
+ |
case 'Q': |
844 |
|
case 'q': /* quit the program */ |
845 |
|
return(0); |
846 |
|
default: |
945 |
|
|
946 |
|
static void |
947 |
|
fixwindow( /* repair damage to window */ |
948 |
< |
register XExposeEvent *eexp |
948 |
> |
XExposeEvent *eexp |
949 |
|
) |
950 |
|
{ |
951 |
|
if ((hres == 0) | (vres == 0)) { /* first exposure */ |
961 |
|
|
962 |
|
static void |
963 |
|
resizewindow( /* resize window */ |
964 |
< |
register XConfigureEvent *ersz |
964 |
> |
XConfigureEvent *ersz |
965 |
|
) |
966 |
|
{ |
967 |
|
static char resizing[] = "resizing window"; |