1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Routines for loading and displaying Radiance objects in rholo with GLX. |
6 |
|
*/ |
52 |
|
FVECT center; /* orig. object center */ |
53 |
|
FLOAT radius; /* orig. object radius */ |
54 |
|
int listid; /* GL display list identifier */ |
55 |
+ |
int nlists; /* number of lists allocated */ |
56 |
|
int rtp[3]; /* associated rtrace process */ |
57 |
|
DLIGHTS *ol; /* object lights */ |
58 |
|
FULLXF xfb; /* coordinate transform */ |
117 |
|
} |
118 |
|
dobjects = ohead.next; |
119 |
|
if (!foundlink) { |
120 |
< |
glDeleteLists(op->listid, 1); |
120 |
> |
glDeleteLists(op->listid, op->nlists); |
121 |
|
close_process(op->rtp); |
122 |
|
} |
123 |
|
while (op->xfac) |
124 |
|
freestr(op->xfav[--op->xfac]); |
125 |
< |
free((char *)op); |
125 |
> |
free((void *)op); |
126 |
|
return(1); |
127 |
|
} |
128 |
|
|
297 |
|
/* avg. reflected brightness */ |
298 |
|
d = AVGREFL / (double)ncells; |
299 |
|
scalecolor(csum, d); |
300 |
< |
if (tmCvColors(&dlightsets->larb, TM_NOCHROM, csum, 1) != TM_E_OK) |
300 |
> |
if (tmCvColors(&dlightsets->larb, TM_NOCHROM, &csum, 1) != TM_E_OK) |
301 |
|
error(CONSISTENCY, "tone mapping problem in ssph_compute"); |
302 |
|
/* greedy light source clustering */ |
303 |
|
while (dlightsets->nl < MAXLIGHTS) { |
404 |
|
quit(0); |
405 |
|
if (!ssph_compute()) { /* compute light sources from sphere */ |
406 |
|
dlightsets = dl->next; |
407 |
< |
free((char *)dl); |
407 |
> |
free((void *)dl); |
408 |
|
return(0); |
409 |
|
} |
410 |
|
op->ol = dl; |
414 |
|
} |
415 |
|
|
416 |
|
|
417 |
< |
static int |
417 |
> |
static |
418 |
|
cmderror(cn, err) /* report command error */ |
419 |
|
int cn; |
420 |
|
char *err; |
421 |
|
{ |
422 |
|
sprintf(errmsg, "%s: %s", rhdcmd[cn], err); |
423 |
|
error(COMMAND, errmsg); |
426 |
– |
return(cn); |
424 |
|
} |
425 |
|
|
426 |
|
|
430 |
|
register char *args; |
431 |
|
{ |
432 |
|
int somechange = 0; |
436 |
– |
VIEW sameview; |
433 |
|
int cn, na, doxfm; |
434 |
|
register int nn; |
435 |
|
char *alist[MAXAC+1], *nm; |
457 |
|
dobj_load(alist[0], alist[0]); |
458 |
|
else if (na == 2) |
459 |
|
dobj_load(alist[0], alist[1]); |
460 |
< |
else |
461 |
< |
return(cmderror(cn, "need octree [name]")); |
460 |
> |
else { |
461 |
> |
cmderror(cn, "need octree [name]"); |
462 |
> |
return(0); |
463 |
> |
} |
464 |
|
break; |
465 |
|
case DO_UNLOAD: /* clear an object */ |
466 |
|
if (na > 1) goto toomany; |
476 |
|
} else { |
477 |
|
nm = curname; nn = 0; |
478 |
|
} |
479 |
< |
if (cn == DO_MOVE && nn >= na) |
480 |
< |
return(cmderror(cn, "missing transform")); |
479 |
> |
if (cn == DO_MOVE && nn >= na) { |
480 |
> |
cmderror(cn, "missing transform"); |
481 |
> |
return(0); |
482 |
> |
} |
483 |
|
somechange += dobj_xform(nm, cn==DO_MOVE, na-nn, alist+nn); |
484 |
|
break; |
485 |
|
case DO_UNMOVE: /* undo last transform */ |
497 |
|
break; |
498 |
|
switch (nn) { |
499 |
|
case 0: |
500 |
< |
return(cmderror(cn, "need new object name")); |
500 |
> |
cmderror(cn, "need new object name"); |
501 |
> |
return(0); |
502 |
|
case 1: |
503 |
|
nm = curname; |
504 |
|
break; |
526 |
|
default: |
527 |
|
error(CONSISTENCY, "bad command id in dobj_command"); |
528 |
|
} |
529 |
< |
if (somechange) { |
529 |
< |
copystruct(&sameview, &odev.v); /* make 'em think new view */ |
530 |
< |
dev_view(&sameview); /* redraw */ |
531 |
< |
} |
532 |
< |
return(cn); |
529 |
> |
return(somechange); |
530 |
|
toomany: |
531 |
|
return(cmderror(cn, "too many arguments")); |
532 |
|
} |
575 |
|
/* load octree into display list */ |
576 |
|
dolights = 0; |
577 |
|
domats = 1; |
578 |
< |
op->listid = rgl_octlist(fpath, op->center, &op->radius); |
578 |
> |
op->listid = rgl_octlist(fpath, op->center, &op->radius, &op->nlists); |
579 |
|
/* start rtrace */ |
580 |
|
rtargv[RTARGC-1] = fpath; |
581 |
|
rtargv[RTARGC] = NULL; |
612 |
|
savedxf(curobj = NULL); |
613 |
|
while ((lp = dlightsets) != NULL) { |
614 |
|
dlightsets = lp->next; |
615 |
< |
free((char *)lp); |
615 |
> |
free((void *)lp); |
616 |
|
} |
617 |
|
return(1); |
618 |
|
} |
860 |
|
VCOPY(darr, rorg); VCOPY(darr+3, rdir); |
861 |
|
} |
862 |
|
/* trace it */ |
863 |
< |
if (process(op->rtp, darr, darr, sizeof(double), |
863 |
> |
if (process(op->rtp, (char *)darr, (char *)darr, sizeof(double), |
864 |
|
6*sizeof(double)) != sizeof(double)) |
865 |
|
error(SYSTEM, "rtrace communication error"); |
866 |
|
/* return distance */ |