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 |
|
*/ |
7 |
|
|
8 |
+ |
#include <string.h> |
9 |
+ |
|
10 |
|
#include "radogl.h" |
11 |
|
#include "tonemap.h" |
12 |
|
#include "rhdisp.h" |
13 |
|
#include "rhdriver.h" |
14 |
|
#include "rhdobj.h" |
15 |
+ |
#include "rtprocess.h" |
16 |
|
|
17 |
|
extern FILE *sstdout; /* user standard output */ |
18 |
|
|
53 |
|
struct dobject *next; /* next object in list */ |
54 |
|
char name[64]; /* object name */ |
55 |
|
FVECT center; /* orig. object center */ |
56 |
< |
FLOAT radius; /* orig. object radius */ |
56 |
> |
RREAL radius; /* orig. object radius */ |
57 |
|
int listid; /* GL display list identifier */ |
58 |
< |
int rtp[3]; /* associated rtrace process */ |
58 |
> |
int nlists; /* number of lists allocated */ |
59 |
> |
SUBPROC rtp; /* associated rtrace process */ |
60 |
|
DLIGHTS *ol; /* object lights */ |
61 |
|
FULLXF xfb; /* coordinate transform */ |
62 |
|
short drawcode; /* drawing code */ |
120 |
|
} |
121 |
|
dobjects = ohead.next; |
122 |
|
if (!foundlink) { |
123 |
< |
glDeleteLists(op->listid, 1); |
124 |
< |
close_process(op->rtp); |
123 |
> |
glDeleteLists(op->listid, op->nlists); |
124 |
> |
close_process(&(op->rtp)); |
125 |
|
} |
126 |
|
while (op->xfac) |
127 |
|
freestr(op->xfav[--op->xfac]); |
128 |
< |
free((char *)op); |
128 |
> |
free((void *)op); |
129 |
|
return(1); |
130 |
|
} |
131 |
|
|
300 |
|
/* avg. reflected brightness */ |
301 |
|
d = AVGREFL / (double)ncells; |
302 |
|
scalecolor(csum, d); |
303 |
< |
if (tmCvColors(&dlightsets->larb, TM_NOCHROM, csum, 1) != TM_E_OK) |
303 |
> |
if (tmCvColors(&dlightsets->larb, TM_NOCHROM, &csum, 1) != TM_E_OK) |
304 |
|
error(CONSISTENCY, "tone mapping problem in ssph_compute"); |
305 |
|
/* greedy light source clustering */ |
306 |
|
while (dlightsets->nl < MAXLIGHTS) { |
340 |
|
d = 1.0/ncells; |
341 |
|
scalecolor(dlightsets->lamb, d); |
342 |
|
done: /* clear sphere sample array */ |
343 |
< |
bzero((char *)ssamp, sizeof(ssamp)); |
343 |
> |
memset((void *)ssamp, '\0', sizeof(ssamp)); |
344 |
|
return(ncells); |
345 |
|
} |
346 |
|
|
373 |
|
if (!force) |
374 |
|
return(0); |
375 |
|
/* need to compute new light set */ |
376 |
< |
copystruct(&cvw, &stdview); |
376 |
> |
cvw = stdview; |
377 |
|
cvw.type = VT_PER; |
378 |
|
VCOPY(cvw.vp, ocent); |
379 |
|
cvw.vup[0] = 1.; cvw.vup[1] = cvw.vup[2] = 0.; |
407 |
|
quit(0); |
408 |
|
if (!ssph_compute()) { /* compute light sources from sphere */ |
409 |
|
dlightsets = dl->next; |
410 |
< |
free((char *)dl); |
410 |
> |
free((void *)dl); |
411 |
|
return(0); |
412 |
|
} |
413 |
|
op->ol = dl; |
538 |
|
dobj_load(oct, nam) /* create/load an octree object */ |
539 |
|
char *oct, *nam; |
540 |
|
{ |
540 |
– |
extern char *getlibpath(), *getpath(); |
541 |
|
char *fpp, fpath[128]; |
542 |
|
register DOBJECT *op; |
543 |
|
/* check arguments */ |
558 |
|
return(0); |
559 |
|
} |
560 |
|
/* get octree path */ |
561 |
< |
if ((fpp = getpath(oct, getlibpath(), R_OK)) == NULL) { |
561 |
> |
if ((fpp = getpath(oct, getrlibpath(), R_OK)) == NULL) { |
562 |
|
sprintf(errmsg, "cannot find octree \"%s\"", oct); |
563 |
|
error(COMMAND, errmsg); |
564 |
|
return(0); |
577 |
|
/* load octree into display list */ |
578 |
|
dolights = 0; |
579 |
|
domats = 1; |
580 |
< |
op->listid = rgl_octlist(fpath, op->center, &op->radius); |
580 |
> |
op->listid = rgl_octlist(fpath, op->center, &op->radius, &op->nlists); |
581 |
|
/* start rtrace */ |
582 |
|
rtargv[RTARGC-1] = fpath; |
583 |
|
rtargv[RTARGC] = NULL; |
584 |
< |
open_process(op->rtp, rtargv); |
584 |
> |
open_process(&(op->rtp), rtargv); |
585 |
|
/* insert into main list */ |
586 |
|
op->next = dobjects; |
587 |
|
curobj = dobjects = op; |
614 |
|
savedxf(curobj = NULL); |
615 |
|
while ((lp = dlightsets) != NULL) { |
616 |
|
dlightsets = lp->next; |
617 |
< |
free((char *)lp); |
617 |
> |
free((void *)lp); |
618 |
|
} |
619 |
|
return(1); |
620 |
|
} |
733 |
|
return(0); |
734 |
|
} |
735 |
|
/* hold last transform */ |
736 |
< |
bcopy((char *)lastxfav, (char *)txfav, |
736 |
> |
memcpy((void *)txfav, (void *)lastxfav, |
737 |
|
(txfac=lastxfac)*sizeof(char *)); |
738 |
|
/* save this transform */ |
739 |
< |
bcopy((char *)curobj->xfav, (char *)lastxfav, |
739 |
> |
memcpy((void *)lastxfav, (void *)curobj->xfav, |
740 |
|
(lastxfac=curobj->xfac)*sizeof(char *)); |
741 |
|
/* copy back last transform */ |
742 |
< |
bcopy((char *)txfav, (char *)curobj->xfav, |
742 |
> |
memcpy((void *)curobj->xfav, (void *)txfav, |
743 |
|
(curobj->xfac=txfac)*sizeof(char *)); |
744 |
|
/* set matrices */ |
745 |
|
fullxf(&curobj->xfb, curobj->xfac, curobj->xfav); |
774 |
|
opdup = (DOBJECT *)malloc(sizeof(DOBJECT)); |
775 |
|
if (opdup == NULL) |
776 |
|
error(SYSTEM, "out of memory in dobj_dup"); |
777 |
< |
copystruct(opdup, op); |
777 |
> |
*opdup = *op; |
778 |
|
/* rename */ |
779 |
|
strcpy(opdup->name, nam); |
780 |
|
/* get our own copy of transform */ |
862 |
|
VCOPY(darr, rorg); VCOPY(darr+3, rdir); |
863 |
|
} |
864 |
|
/* trace it */ |
865 |
< |
if (process(op->rtp, darr, darr, sizeof(double), |
865 |
> |
if (process(&(op->rtp), (char *)darr, (char *)darr, sizeof(double), |
866 |
|
6*sizeof(double)) != sizeof(double)) |
867 |
|
error(SYSTEM, "rtrace communication error"); |
868 |
|
/* return distance */ |