| 5 | 
  | 
 * Routines for loading and displaying Radiance objects in rholo with GLX. | 
| 6 | 
  | 
 */ | 
| 7 | 
  | 
 | 
| 8 | 
+ | 
#include <string.h> | 
| 9 | 
+ | 
#include <ctype.h> | 
| 10 | 
+ | 
 | 
| 11 | 
  | 
#include "radogl.h" | 
| 12 | 
  | 
#include "tonemap.h" | 
| 13 | 
  | 
#include "rhdisp.h" | 
| 14 | 
  | 
#include "rhdriver.h" | 
| 15 | 
  | 
#include "rhdobj.h" | 
| 16 | 
+ | 
#include "rtprocess.h" | 
| 17 | 
  | 
 | 
| 18 | 
  | 
extern FILE     *sstdout;               /* user standard output */ | 
| 19 | 
  | 
 | 
| 20 | 
  | 
char    rhdcmd[DO_NCMDS][8] = DO_INIT;  /* user command list */ | 
| 21 | 
  | 
 | 
| 22 | 
< | 
int     (*dobj_lightsamp)() = NULL;     /* pointer to function to get lights */ | 
| 22 | 
> | 
/* pointer to function to get lights */ | 
| 23 | 
> | 
void    (*dobj_lightsamp)(COLR clr, FVECT direc, FVECT pos) = NULL; | 
| 24 | 
  | 
 | 
| 25 | 
  | 
#define AVGREFL         0.5             /* assumed average reflectance */ | 
| 26 | 
  | 
 | 
| 34 | 
  | 
#define NALT            11              /* # sampling altitude angles */ | 
| 35 | 
  | 
#endif | 
| 36 | 
  | 
#ifndef NAZI | 
| 37 | 
< | 
#define NAZI            ((int)(PI/2.*NALT+.5)) | 
| 37 | 
> | 
#define NAZI            17 | 
| 38 | 
  | 
#endif | 
| 39 | 
  | 
 | 
| 40 | 
  | 
typedef struct dlights { | 
| 55 | 
  | 
        struct dobject  *next;          /* next object in list */ | 
| 56 | 
  | 
        char    name[64];               /* object name */ | 
| 57 | 
  | 
        FVECT   center;                 /* orig. object center */ | 
| 58 | 
< | 
        FLOAT   radius;                 /* orig. object radius */ | 
| 58 | 
> | 
        RREAL   radius;                 /* orig. object radius */ | 
| 59 | 
  | 
        int     listid;                 /* GL display list identifier */ | 
| 60 | 
  | 
        int     nlists;                 /* number of lists allocated */ | 
| 61 | 
< | 
        int     rtp[3];                 /* associated rtrace process */ | 
| 61 | 
> | 
        SUBPROC rtp;                    /* associated rtrace process */ | 
| 62 | 
  | 
        DLIGHTS *ol;                    /* object lights */ | 
| 63 | 
  | 
        FULLXF  xfb;                    /* coordinate transform */ | 
| 64 | 
  | 
        short   drawcode;               /* drawing code */ | 
| 86 | 
  | 
 | 
| 87 | 
  | 
#define curname         (curobj==NULL ? (char *)NULL : curobj->name) | 
| 88 | 
  | 
 | 
| 89 | 
+ | 
static DOBJECT *getdobj(char *nm); | 
| 90 | 
+ | 
static int freedobj(DOBJECT *op); | 
| 91 | 
+ | 
static int savedxf(DOBJECT *op); | 
| 92 | 
+ | 
static void ssph_sample(COLR clr, FVECT direc, FVECT pos); | 
| 93 | 
+ | 
static void ssph_direc(FVECT direc, int alt, int azi); | 
| 94 | 
+ | 
static int ssph_neigh(int sp[2], int next); | 
| 95 | 
+ | 
static int ssph_compute(void); | 
| 96 | 
+ | 
static int getdlights(DOBJECT *op, int force); | 
| 97 | 
+ | 
static void cmderror(int cn, char *err); | 
| 98 | 
  | 
 | 
| 99 | 
+ | 
 | 
| 100 | 
  | 
static DOBJECT * | 
| 101 | 
< | 
getdobj(nm)                     /* get object from list by name */ | 
| 102 | 
< | 
char    *nm; | 
| 101 | 
> | 
getdobj(                        /* get object from list by name */ | 
| 102 | 
> | 
        char    *nm | 
| 103 | 
> | 
) | 
| 104 | 
  | 
{ | 
| 105 | 
< | 
        register DOBJECT        *op; | 
| 105 | 
> | 
        DOBJECT *op; | 
| 106 | 
  | 
 | 
| 107 | 
  | 
        if (nm == NULL) | 
| 108 | 
  | 
                return(NULL); | 
| 115 | 
  | 
} | 
| 116 | 
  | 
 | 
| 117 | 
  | 
 | 
| 118 | 
< | 
static | 
| 119 | 
< | 
freedobj(op)                    /* free resources and memory assoc. with op */ | 
| 120 | 
< | 
register DOBJECT        *op; | 
| 118 | 
> | 
static int | 
| 119 | 
> | 
freedobj(                       /* free resources and memory assoc. with op */ | 
| 120 | 
> | 
        DOBJECT *op | 
| 121 | 
> | 
) | 
| 122 | 
  | 
{ | 
| 123 | 
  | 
        int     foundlink = 0; | 
| 124 | 
  | 
        DOBJECT ohead; | 
| 125 | 
< | 
        register DOBJECT        *opl; | 
| 125 | 
> | 
        DOBJECT *opl; | 
| 126 | 
  | 
 | 
| 127 | 
  | 
        if (op == NULL) | 
| 128 | 
  | 
                return(0); | 
| 135 | 
  | 
        dobjects = ohead.next; | 
| 136 | 
  | 
        if (!foundlink) { | 
| 137 | 
  | 
                glDeleteLists(op->listid, op->nlists); | 
| 138 | 
< | 
                close_process(op->rtp); | 
| 138 | 
> | 
                close_process(&op->rtp); | 
| 139 | 
  | 
        } | 
| 140 | 
  | 
        while (op->xfac) | 
| 141 | 
  | 
                freestr(op->xfav[--op->xfac]); | 
| 144 | 
  | 
} | 
| 145 | 
  | 
 | 
| 146 | 
  | 
 | 
| 147 | 
< | 
static | 
| 148 | 
< | 
savedxf(op)                     /* save transform for display object */ | 
| 149 | 
< | 
register DOBJECT        *op; | 
| 147 | 
> | 
static int | 
| 148 | 
> | 
savedxf(                        /* save transform for display object */ | 
| 149 | 
> | 
        DOBJECT *op | 
| 150 | 
> | 
) | 
| 151 | 
  | 
{ | 
| 152 | 
  | 
                                        /* free old */ | 
| 153 | 
  | 
        while (lastxfac) | 
| 165 | 
  | 
} | 
| 166 | 
  | 
 | 
| 167 | 
  | 
 | 
| 168 | 
< | 
static | 
| 169 | 
< | 
ssph_sample(clr, direc, pos)    /* add sample to current source sphere */ | 
| 170 | 
< | 
COLR    clr; | 
| 171 | 
< | 
FVECT   direc, pos; | 
| 168 | 
> | 
static void | 
| 169 | 
> | 
ssph_sample(    /* add sample to current source sphere */ | 
| 170 | 
> | 
        COLR    clr, | 
| 171 | 
> | 
        FVECT   direc, | 
| 172 | 
> | 
        FVECT   pos | 
| 173 | 
> | 
) | 
| 174 | 
  | 
{ | 
| 175 | 
  | 
        COLOR   col; | 
| 176 | 
  | 
        double  d; | 
| 177 | 
< | 
        register int    alt, azi; | 
| 177 | 
> | 
        int     alt, azi; | 
| 178 | 
  | 
 | 
| 179 | 
  | 
        if (dlightsets == NULL) | 
| 180 | 
  | 
                return; | 
| 194 | 
  | 
} | 
| 195 | 
  | 
 | 
| 196 | 
  | 
 | 
| 197 | 
< | 
static | 
| 198 | 
< | 
ssph_direc(direc, alt, azi)     /* compute sphere sampling direction */ | 
| 199 | 
< | 
FVECT   direc; | 
| 200 | 
< | 
int     alt, azi; | 
| 197 | 
> | 
static void | 
| 198 | 
> | 
ssph_direc(     /* compute sphere sampling direction */ | 
| 199 | 
> | 
        FVECT   direc, | 
| 200 | 
> | 
        int     alt, | 
| 201 | 
> | 
        int     azi | 
| 202 | 
> | 
) | 
| 203 | 
  | 
{ | 
| 204 | 
  | 
        double  phi, d; | 
| 205 | 
  | 
 | 
| 212 | 
  | 
 | 
| 213 | 
  | 
 | 
| 214 | 
  | 
static int | 
| 215 | 
< | 
ssph_neigh(sp, next)            /* neighbor counter on sphere */ | 
| 216 | 
< | 
register int    sp[2]; | 
| 217 | 
< | 
int     next; | 
| 215 | 
> | 
ssph_neigh(             /* neighbor counter on sphere */ | 
| 216 | 
> | 
        int     sp[2], | 
| 217 | 
> | 
        int     next | 
| 218 | 
> | 
) | 
| 219 | 
  | 
{ | 
| 220 | 
  | 
        static short    nneigh = 0;             /* neighbor count */ | 
| 221 | 
  | 
        static short    neighlist[NAZI+6][2];   /* neighbor list (0 is home) */ | 
| 222 | 
< | 
        register int    i; | 
| 222 | 
> | 
        int     i; | 
| 223 | 
  | 
 | 
| 224 | 
  | 
        if (next) { | 
| 225 | 
  | 
                if (nneigh <= 0) | 
| 228 | 
  | 
                sp[1] = neighlist[nneigh][1]; | 
| 229 | 
  | 
                return(1); | 
| 230 | 
  | 
        } | 
| 231 | 
< | 
        if (sp[0] < 0 | sp[0] >= NALT | sp[1] < 0 | sp[1] >= NAZI) | 
| 231 | 
> | 
        if ((sp[0] < 0) | (sp[0] >= NALT) | (sp[1] < 0) | (sp[1] >= NAZI)) | 
| 232 | 
  | 
                return(nneigh=0); | 
| 233 | 
  | 
        neighlist[0][0] = sp[0]; neighlist[0][1] = sp[1]; | 
| 234 | 
  | 
        nneigh = 1; | 
| 278 | 
  | 
} | 
| 279 | 
  | 
 | 
| 280 | 
  | 
 | 
| 281 | 
< | 
static | 
| 282 | 
< | 
ssph_compute()                  /* compute source set from sphere samples */ | 
| 281 | 
> | 
static int | 
| 282 | 
> | 
ssph_compute(void)                      /* compute source set from sphere samples */ | 
| 283 | 
  | 
{ | 
| 284 | 
  | 
        int     ncells, nsamps; | 
| 285 | 
  | 
        COLOR   csum; | 
| 286 | 
  | 
        FVECT   v; | 
| 287 | 
  | 
        double  d, thresh, maxbr; | 
| 288 | 
  | 
        int     maxalt, maxazi, spos[2]; | 
| 289 | 
< | 
        register int    alt, azi; | 
| 290 | 
< | 
        register struct lsource *ls; | 
| 289 | 
> | 
        int     alt, azi; | 
| 290 | 
> | 
        struct lsource  *ls; | 
| 291 | 
  | 
                                        /* count & average sampled cells */ | 
| 292 | 
  | 
        setcolor(csum, 0., 0., 0.); | 
| 293 | 
  | 
        ncells = nsamps = 0; | 
| 302 | 
  | 
                                nsamps += ssamp[alt][azi].nsamp; | 
| 303 | 
  | 
                                ncells++; | 
| 304 | 
  | 
                        } | 
| 305 | 
< | 
        if (dlightsets == NULL | ncells < NALT*NAZI/4) { | 
| 305 | 
> | 
        if ((dlightsets == NULL) | (ncells < NALT*NAZI/4)) { | 
| 306 | 
  | 
                ncells = 0; | 
| 307 | 
  | 
                goto done; | 
| 308 | 
  | 
        } | 
| 320 | 
  | 
                                                /* avg. reflected brightness */ | 
| 321 | 
  | 
        d = AVGREFL / (double)ncells;    | 
| 322 | 
  | 
        scalecolor(csum, d); | 
| 323 | 
< | 
        if (tmCvColors(&dlightsets->larb, TM_NOCHROM, &csum, 1) != TM_E_OK) | 
| 323 | 
> | 
        if (tmCvColors(tmGlobal, &dlightsets->larb, | 
| 324 | 
> | 
                        TM_NOCHROM, &csum, 1) != TM_E_OK) | 
| 325 | 
  | 
                error(CONSISTENCY, "tone mapping problem in ssph_compute"); | 
| 326 | 
  | 
                                        /* greedy light source clustering */ | 
| 327 | 
  | 
        while (dlightsets->nl < MAXLIGHTS) { | 
| 361 | 
  | 
        d = 1.0/ncells; | 
| 362 | 
  | 
        scalecolor(dlightsets->lamb, d); | 
| 363 | 
  | 
done:                                   /* clear sphere sample array */ | 
| 364 | 
< | 
        bzero((char *)ssamp, sizeof(ssamp)); | 
| 364 | 
> | 
        memset((void *)ssamp, '\0', sizeof(ssamp)); | 
| 365 | 
  | 
        return(ncells); | 
| 366 | 
  | 
} | 
| 367 | 
  | 
 | 
| 368 | 
  | 
 | 
| 369 | 
< | 
static | 
| 370 | 
< | 
getdlights(op, force)           /* get lights for display object */ | 
| 371 | 
< | 
register DOBJECT        *op; | 
| 372 | 
< | 
int     force; | 
| 369 | 
> | 
static int | 
| 370 | 
> | 
getdlights(             /* get lights for display object */ | 
| 371 | 
> | 
        DOBJECT *op, | 
| 372 | 
> | 
        int     force | 
| 373 | 
> | 
) | 
| 374 | 
  | 
{ | 
| 375 | 
  | 
        double  d2, mind2 = FHUGE*FHUGE; | 
| 376 | 
  | 
        FVECT   ocent; | 
| 377 | 
  | 
        VIEW    cvw; | 
| 378 | 
< | 
        register DLIGHTS        *dl; | 
| 378 | 
> | 
        DLIGHTS *dl; | 
| 379 | 
  | 
 | 
| 380 | 
  | 
        op->ol = NULL; | 
| 381 | 
  | 
        if (op->drawcode != DO_LIGHT) | 
| 395 | 
  | 
        if (!force) | 
| 396 | 
  | 
                return(0); | 
| 397 | 
  | 
                                        /* need to compute new light set */ | 
| 398 | 
< | 
        copystruct(&cvw, &stdview); | 
| 398 | 
> | 
        cvw = stdview; | 
| 399 | 
  | 
        cvw.type = VT_PER; | 
| 400 | 
  | 
        VCOPY(cvw.vp, ocent); | 
| 401 | 
  | 
        cvw.vup[0] = 1.; cvw.vup[1] = cvw.vup[2] = 0.; | 
| 436 | 
  | 
        return(1); | 
| 437 | 
  | 
memerr: | 
| 438 | 
  | 
        error(SYSTEM, "out of memory in getdlights"); | 
| 439 | 
+ | 
        return 0; /* pro forma return */ | 
| 440 | 
  | 
} | 
| 441 | 
  | 
 | 
| 442 | 
  | 
 | 
| 443 | 
< | 
static | 
| 444 | 
< | 
cmderror(cn, err)               /* report command error */ | 
| 445 | 
< | 
int     cn; | 
| 446 | 
< | 
char    *err; | 
| 443 | 
> | 
static void | 
| 444 | 
> | 
cmderror(               /* report command error */ | 
| 445 | 
> | 
        int     cn, | 
| 446 | 
> | 
        char    *err | 
| 447 | 
> | 
) | 
| 448 | 
  | 
{ | 
| 449 | 
  | 
        sprintf(errmsg, "%s: %s", rhdcmd[cn], err); | 
| 450 | 
  | 
        error(COMMAND, errmsg); | 
| 452 | 
  | 
 | 
| 453 | 
  | 
 | 
| 454 | 
  | 
int | 
| 455 | 
< | 
dobj_command(cmd, args)         /* run object display command */ | 
| 456 | 
< | 
char    *cmd; | 
| 457 | 
< | 
register char   *args; | 
| 455 | 
> | 
dobj_command(           /* run object display command */ | 
| 456 | 
> | 
        char    *cmd, | 
| 457 | 
> | 
        char    *args | 
| 458 | 
> | 
) | 
| 459 | 
  | 
{ | 
| 460 | 
  | 
        int     somechange = 0; | 
| 461 | 
< | 
        int     cn, na, doxfm; | 
| 462 | 
< | 
        register int    nn; | 
| 461 | 
> | 
        int     cn, na; | 
| 462 | 
> | 
        int     nn; | 
| 463 | 
  | 
        char    *alist[MAXAC+1], *nm; | 
| 464 | 
  | 
                                        /* find command */ | 
| 465 | 
  | 
        for (cn = 0; cn < DO_NCMDS; cn++) | 
| 556 | 
  | 
        } | 
| 557 | 
  | 
        return(somechange); | 
| 558 | 
  | 
toomany: | 
| 559 | 
< | 
        return(cmderror(cn, "too many arguments")); | 
| 559 | 
> | 
        cmderror(cn, "too many arguments"); | 
| 560 | 
> | 
        return(-1); | 
| 561 | 
  | 
} | 
| 562 | 
  | 
 | 
| 563 | 
  | 
 | 
| 564 | 
< | 
dobj_load(oct, nam)             /* create/load an octree object */ | 
| 565 | 
< | 
char    *oct, *nam; | 
| 564 | 
> | 
int | 
| 565 | 
> | 
dobj_load(              /* create/load an octree object */ | 
| 566 | 
> | 
        char    *oct, | 
| 567 | 
> | 
        char    *nam | 
| 568 | 
> | 
) | 
| 569 | 
  | 
{ | 
| 538 | 
– | 
        extern char     *getlibpath(), *getpath(); | 
| 570 | 
  | 
        char    *fpp, fpath[128]; | 
| 571 | 
< | 
        register DOBJECT        *op; | 
| 571 | 
> | 
        DOBJECT *op; | 
| 572 | 
  | 
                                        /* check arguments */ | 
| 573 | 
  | 
        if (oct == NULL) { | 
| 574 | 
  | 
                error(COMMAND, "missing octree"); | 
| 578 | 
  | 
                error(COMMAND, "missing name"); | 
| 579 | 
  | 
                return(0); | 
| 580 | 
  | 
        } | 
| 581 | 
< | 
        if (*nam == '*' | *nam == '-') { | 
| 581 | 
> | 
        if ((*nam == '*') | (*nam == '-')) { | 
| 582 | 
  | 
                error(COMMAND, "illegal name"); | 
| 583 | 
  | 
                return(0); | 
| 584 | 
  | 
        } | 
| 587 | 
  | 
                return(0); | 
| 588 | 
  | 
        } | 
| 589 | 
  | 
                                        /* get octree path */ | 
| 590 | 
< | 
        if ((fpp = getpath(oct, getlibpath(), R_OK)) == NULL) { | 
| 590 | 
> | 
        if ((fpp = getpath(oct, getrlibpath(), R_OK)) == NULL) { | 
| 591 | 
  | 
                sprintf(errmsg, "cannot find octree \"%s\"", oct); | 
| 592 | 
  | 
                error(COMMAND, errmsg); | 
| 593 | 
  | 
                return(0); | 
| 610 | 
  | 
                                        /* start rtrace */ | 
| 611 | 
  | 
        rtargv[RTARGC-1] = fpath; | 
| 612 | 
  | 
        rtargv[RTARGC] = NULL; | 
| 613 | 
< | 
        open_process(op->rtp, rtargv); | 
| 613 | 
> | 
        op->rtp = sp_inactive; | 
| 614 | 
> | 
        open_process(&op->rtp, rtargv); | 
| 615 | 
  | 
                                        /* insert into main list */ | 
| 616 | 
  | 
        op->next = dobjects; | 
| 617 | 
  | 
        curobj = dobjects = op; | 
| 620 | 
  | 
} | 
| 621 | 
  | 
 | 
| 622 | 
  | 
 | 
| 623 | 
< | 
dobj_unload(nam)                        /* free the named object */ | 
| 624 | 
< | 
char    *nam; | 
| 623 | 
> | 
int | 
| 624 | 
> | 
dobj_unload(                    /* free the named object */ | 
| 625 | 
> | 
        char    *nam | 
| 626 | 
> | 
) | 
| 627 | 
  | 
{ | 
| 628 | 
< | 
        register DOBJECT        *op; | 
| 628 | 
> | 
        DOBJECT *op; | 
| 629 | 
  | 
 | 
| 630 | 
  | 
        if ((op = getdobj(nam)) == NULL) { | 
| 631 | 
  | 
                error(COMMAND, "no object"); | 
| 637 | 
  | 
} | 
| 638 | 
  | 
 | 
| 639 | 
  | 
 | 
| 640 | 
< | 
dobj_cleanup()                          /* free all resources */ | 
| 640 | 
> | 
int | 
| 641 | 
> | 
dobj_cleanup(void)                              /* free all resources */ | 
| 642 | 
  | 
{ | 
| 643 | 
< | 
        register DLIGHTS        *lp; | 
| 643 | 
> | 
        DLIGHTS *lp; | 
| 644 | 
  | 
 | 
| 645 | 
  | 
        while (dobjects != NULL) | 
| 646 | 
  | 
                freedobj(dobjects); | 
| 653 | 
  | 
} | 
| 654 | 
  | 
 | 
| 655 | 
  | 
 | 
| 656 | 
< | 
dobj_xform(nam, rel, ac, av)            /* set/add transform for nam */ | 
| 657 | 
< | 
char    *nam; | 
| 658 | 
< | 
int     rel, ac; | 
| 659 | 
< | 
char    **av; | 
| 656 | 
> | 
int | 
| 657 | 
> | 
dobj_xform(             /* set/add transform for nam */ | 
| 658 | 
> | 
        char    *nam, | 
| 659 | 
> | 
        int     rel, | 
| 660 | 
> | 
        int     ac, | 
| 661 | 
> | 
        char    **av | 
| 662 | 
> | 
) | 
| 663 | 
  | 
{ | 
| 664 | 
< | 
        register DOBJECT        *op; | 
| 664 | 
> | 
        DOBJECT *op; | 
| 665 | 
  | 
        FVECT   cent; | 
| 666 | 
  | 
        double  rad; | 
| 667 | 
  | 
        char    scoord[16]; | 
| 718 | 
  | 
} | 
| 719 | 
  | 
 | 
| 720 | 
  | 
 | 
| 721 | 
< | 
dobj_putstats(nam, fp)                  /* put out statistics for nam */ | 
| 722 | 
< | 
char    *nam; | 
| 723 | 
< | 
FILE    *fp; | 
| 721 | 
> | 
int | 
| 722 | 
> | 
dobj_putstats(                  /* put out statistics for nam */ | 
| 723 | 
> | 
        char    *nam, | 
| 724 | 
> | 
        FILE    *fp | 
| 725 | 
> | 
) | 
| 726 | 
  | 
{ | 
| 727 | 
  | 
        FVECT   ocent; | 
| 728 | 
< | 
        register DOBJECT        *op; | 
| 729 | 
< | 
        register int    i; | 
| 728 | 
> | 
        DOBJECT *op; | 
| 729 | 
> | 
        int     i; | 
| 730 | 
  | 
 | 
| 731 | 
  | 
        if (nam == NULL) { | 
| 732 | 
  | 
                error(COMMAND, "no current object"); | 
| 761 | 
  | 
} | 
| 762 | 
  | 
 | 
| 763 | 
  | 
 | 
| 764 | 
< | 
dobj_unmove()                           /* undo last transform change */ | 
| 764 | 
> | 
int | 
| 765 | 
> | 
dobj_unmove(void)                               /* undo last transform change */ | 
| 766 | 
  | 
{ | 
| 767 | 
  | 
        int     txfac; | 
| 768 | 
  | 
        char    *txfav[MAXAC+1]; | 
| 772 | 
  | 
                return(0); | 
| 773 | 
  | 
        } | 
| 774 | 
  | 
                                        /* hold last transform */ | 
| 775 | 
< | 
        bcopy((char *)lastxfav, (char *)txfav, | 
| 775 | 
> | 
        memcpy((void *)txfav, (void *)lastxfav,  | 
| 776 | 
  | 
                        (txfac=lastxfac)*sizeof(char *)); | 
| 777 | 
  | 
                                        /* save this transform */ | 
| 778 | 
< | 
        bcopy((char *)curobj->xfav, (char *)lastxfav, | 
| 778 | 
> | 
        memcpy((void *)lastxfav, (void *)curobj->xfav,  | 
| 779 | 
  | 
                        (lastxfac=curobj->xfac)*sizeof(char *)); | 
| 780 | 
  | 
                                        /* copy back last transform */ | 
| 781 | 
< | 
        bcopy((char *)txfav, (char *)curobj->xfav, | 
| 781 | 
> | 
        memcpy((void *)curobj->xfav, (void *)txfav,  | 
| 782 | 
  | 
                        (curobj->xfac=txfac)*sizeof(char *)); | 
| 783 | 
  | 
                                        /* set matrices */ | 
| 784 | 
  | 
        fullxf(&curobj->xfb, curobj->xfac, curobj->xfav); | 
| 788 | 
  | 
} | 
| 789 | 
  | 
 | 
| 790 | 
  | 
 | 
| 791 | 
< | 
dobj_dup(oldnm, nam)                    /* duplicate object oldnm as nam */ | 
| 792 | 
< | 
char    *oldnm, *nam; | 
| 791 | 
> | 
int | 
| 792 | 
> | 
dobj_dup(                       /* duplicate object oldnm as nam */ | 
| 793 | 
> | 
        char    *oldnm, | 
| 794 | 
> | 
        char    *nam | 
| 795 | 
> | 
) | 
| 796 | 
  | 
{ | 
| 797 | 
< | 
        register DOBJECT        *op, *opdup; | 
| 797 | 
> | 
        DOBJECT *op, *opdup; | 
| 798 | 
  | 
                                        /* check arguments */ | 
| 799 | 
  | 
        if ((op = getdobj(oldnm)) == NULL) { | 
| 800 | 
  | 
                error(COMMAND, "no object"); | 
| 804 | 
  | 
                error(COMMAND, "missing name"); | 
| 805 | 
  | 
                return(0); | 
| 806 | 
  | 
        } | 
| 807 | 
< | 
        if (*nam == '*' | *nam == '-') { | 
| 807 | 
> | 
        if ((*nam == '*') | (*nam == '-')) { | 
| 808 | 
  | 
                error(COMMAND, "illegal name"); | 
| 809 | 
  | 
                return(0); | 
| 810 | 
  | 
        } | 
| 816 | 
  | 
        opdup = (DOBJECT *)malloc(sizeof(DOBJECT)); | 
| 817 | 
  | 
        if (opdup == NULL) | 
| 818 | 
  | 
                error(SYSTEM, "out of memory in dobj_dup"); | 
| 819 | 
< | 
        copystruct(opdup, op); | 
| 819 | 
> | 
        *opdup = *op; | 
| 820 | 
  | 
                                        /* rename */ | 
| 821 | 
  | 
        strcpy(opdup->name, nam); | 
| 822 | 
  | 
                                        /* get our own copy of transform */ | 
| 830 | 
  | 
} | 
| 831 | 
  | 
 | 
| 832 | 
  | 
 | 
| 833 | 
< | 
dobj_lighting(nam, cn)          /* set up lighting for display object */ | 
| 834 | 
< | 
char    *nam; | 
| 835 | 
< | 
int     cn; | 
| 833 | 
> | 
int | 
| 834 | 
> | 
dobj_lighting(          /* set up lighting for display object */ | 
| 835 | 
> | 
        char    *nam, | 
| 836 | 
> | 
        int     cn | 
| 837 | 
> | 
) | 
| 838 | 
  | 
{ | 
| 839 | 
  | 
        int     i, res[2]; | 
| 840 | 
  | 
        VIEW    *dv; | 
| 841 | 
< | 
        register DOBJECT        *op; | 
| 841 | 
> | 
        DOBJECT *op; | 
| 842 | 
  | 
 | 
| 843 | 
  | 
        if (nam == NULL) { | 
| 844 | 
  | 
                error(COMMAND, "no current object"); | 
| 866 | 
  | 
                        beam_view(dv, res[0], res[1]); | 
| 867 | 
  | 
                beam_sync(1);                   /* update server */ | 
| 868 | 
  | 
        } | 
| 869 | 
+ | 
        return 0; /* XXX not sure if this is the right value */ | 
| 870 | 
  | 
} | 
| 871 | 
  | 
 | 
| 872 | 
  | 
 | 
| 873 | 
  | 
double | 
| 874 | 
< | 
dobj_trace(nm, rorg, rdir)      /* check for ray intersection with object(s) */ | 
| 875 | 
< | 
char    nm[]; | 
| 876 | 
< | 
FVECT   rorg, rdir; | 
| 874 | 
> | 
dobj_trace(     /* check for ray intersection with object(s) */ | 
| 875 | 
> | 
        char    nm[], | 
| 876 | 
> | 
        FVECT  rorg, | 
| 877 | 
> | 
        FVECT  rdir | 
| 878 | 
> | 
) | 
| 879 | 
  | 
{ | 
| 880 | 
< | 
        register DOBJECT        *op; | 
| 880 | 
> | 
        DOBJECT *op; | 
| 881 | 
  | 
        FVECT   xorg, xdir; | 
| 882 | 
  | 
        double  darr[6]; | 
| 883 | 
  | 
                                        /* check each visible object? */ | 
| 909 | 
  | 
                VCOPY(darr, rorg); VCOPY(darr+3, rdir); | 
| 910 | 
  | 
        } | 
| 911 | 
  | 
                                /* trace it */ | 
| 912 | 
< | 
        if (process(op->rtp, (char *)darr, (char *)darr, sizeof(double), | 
| 912 | 
> | 
        if (process(&op->rtp, darr, darr, sizeof(double), | 
| 913 | 
  | 
                        6*sizeof(double)) != sizeof(double)) | 
| 914 | 
  | 
                error(SYSTEM, "rtrace communication error"); | 
| 915 | 
  | 
                                /* return distance */ | 
| 920 | 
  | 
 | 
| 921 | 
  | 
 | 
| 922 | 
  | 
int | 
| 923 | 
< | 
dobj_render()                   /* render our objects in OpenGL */ | 
| 923 | 
> | 
dobj_render(void)                       /* render our objects in OpenGL */ | 
| 924 | 
  | 
{ | 
| 925 | 
  | 
        int     nrendered = 0; | 
| 926 | 
  | 
        GLboolean       normalizing; | 
| 927 | 
  | 
        GLfloat vec[4]; | 
| 928 | 
  | 
        FVECT   v1; | 
| 929 | 
< | 
        register DOBJECT        *op; | 
| 930 | 
< | 
        register int    i; | 
| 929 | 
> | 
        DOBJECT *op; | 
| 930 | 
> | 
        int     i; | 
| 931 | 
  | 
                                        /* anything to render? */ | 
| 932 | 
  | 
        for (op = dobjects; op != NULL; op = op->next) | 
| 933 | 
  | 
                if (op->drawcode != DO_HIDE) | 
| 955 | 
  | 
                        continue; | 
| 956 | 
  | 
                                        /* set up lighting */ | 
| 957 | 
  | 
                if (op->drawcode == DO_LIGHT && op->ol != NULL) { | 
| 958 | 
< | 
                        BYTE    pval; | 
| 958 | 
> | 
                        uby8    pval; | 
| 959 | 
  | 
                        double  expval, d; | 
| 960 | 
  | 
                                                /* use computed sources */ | 
| 961 | 
< | 
                        if (tmMapPixels(&pval, &op->ol->larb, TM_NOCHROM, 1) | 
| 962 | 
< | 
                                        != TM_E_OK) | 
| 961 | 
> | 
                        if (tmMapPixels(tmGlobal, &pval, &op->ol->larb, | 
| 962 | 
> | 
                                        TM_NOCHROM, 1) != TM_E_OK) | 
| 963 | 
  | 
                                error(CONSISTENCY, "dobj_render w/o tone map"); | 
| 964 | 
  | 
                        expval = pval * (WHTEFFICACY/256.) / | 
| 965 | 
  | 
                                        tmLuminance(op->ol->larb); | 
| 1005 | 
  | 
                } | 
| 1006 | 
  | 
                                        /* set up object transform */ | 
| 1007 | 
  | 
                if (op->xfac) { | 
| 1008 | 
< | 
                        if (!normalizing && op->xfb.f.sca < 1.-FTINY | | 
| 1009 | 
< | 
                                                op->xfb.f.sca > 1.+FTINY) | 
| 1008 | 
> | 
                        if (!normalizing && (op->xfb.f.sca < 1.-FTINY) | | 
| 1009 | 
> | 
                                                (op->xfb.f.sca > 1.+FTINY)) | 
| 1010 | 
  | 
                                glEnable(GL_NORMALIZE); | 
| 1011 | 
  | 
                        glMatrixMode(GL_MODELVIEW); | 
| 1012 | 
  | 
                        glPushMatrix(); |