Back to index

radiance  4R0+20100331
Classes | Defines | Functions | Variables
rhd_geom.c File Reference
#include <string.h>
#include "rtio.h"
#include "radogl.h"
#include "rhdriver.h"
#include "rhd_odraw.h"

Go to the source code of this file.

Classes

struct  gmEntry

Defines

#define MAXGEO   8 /* maximum geometry list length */
#define MAXPORT   (MAXGEO*4) /* maximum number of portal files */
#define FORALLGEOM(ot, i)   for (i=0;i<MAXGEO&&ot[i].gfile!=NULL;i++)
#define FORALLPORT(pl, i)   for (i=0;i<MAXPORT&&pl[i]!=NULL;i++)

Functions

void gmNewGeom (char *file)
void gmEndGeom (void)
int gmDrawGeom (void)
void gmDrawPortals (int r, int g, int b, int a)
void gmDepthLimit (double dl[2], FVECT vorg, FVECT vdir)
void gmNewPortal (char *pflist)
static int sstrcmp (char **ss0, char **ss1)
int gmEndPortal (void)

Variables

static const char RCSid [] = "$Id: rhd_geom.c,v 3.14 2004/01/01 11:21:55 schorsch Exp $"
int gmPortals = 0
static int Nlists = 0
static char * curportlist [MAXPORT]
static char * newportlist [MAXPORT]
static struct gmEntry gmCurrent [MAXGEO]
static struct gmEntry gmNext [MAXGEO]

Class Documentation

struct gmEntry

Definition at line 27 of file rhd_geom.c.

Class Members
FVECT cent
char * gfile
int listid
int nlists
RREAL rad

Define Documentation

#define FORALLGEOM (   ot,
  i 
)    for (i=0;i<MAXGEO&&ot[i].gfile!=NULL;i++)

Definition at line 35 of file rhd_geom.c.

#define FORALLPORT (   pl,
  i 
)    for (i=0;i<MAXPORT&&pl[i]!=NULL;i++)

Definition at line 37 of file rhd_geom.c.

#define MAXGEO   8 /* maximum geometry list length */

Definition at line 16 of file rhd_geom.c.

#define MAXPORT   (MAXGEO*4) /* maximum number of portal files */

Definition at line 19 of file rhd_geom.c.


Function Documentation

void gmDepthLimit ( double  dl[2],
FVECT  vorg,
FVECT  vdir 
)

Definition at line 134 of file rhd_geom.c.

{
       FVECT  v;
       double dcent;
       register int  i;

       dl[0] = FHUGE; dl[1] = 0.;
       FORALLGEOM(gmCurrent, i) {
              VSUB(v, gmCurrent[i].cent, vorg);
              dcent = DOT(v, vdir);
              if (dl[0] > dcent-gmCurrent[i].rad)
                     dl[0] = dcent-gmCurrent[i].rad;
              if (dl[1] < dcent+gmCurrent[i].rad)
                     dl[1] = dcent+gmCurrent[i].rad;
       }
       if (dl[0] < 0.)
              dl[0] = 0.;
}

Here is the caller graph for this function:

int gmDrawGeom ( void  )

Definition at line 97 of file rhd_geom.c.

{
       register int  n;

       FORALLGEOM(gmCurrent, n)
              glCallList(gmCurrent[n].listid);
       return(n);
}

Here is the caller graph for this function:

void gmDrawPortals ( int  r,
int  g,
int  b,
int  a 
)

Definition at line 108 of file rhd_geom.c.

{
       if (!gmPortals || (r<0) & (g<0) & (b<0) & (a<0))
              return;
       glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|
                     GL_POLYGON_BIT|GL_LIGHTING_BIT);
       glDisable(GL_LIGHTING);
       glDisable(GL_DITHER);
       glShadeModel(GL_FLAT);
       glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                   /* don't actually write depth */
       glDepthMask(GL_FALSE);
                                   /* draw only selected channels */
       glColorMask(r>=0, g>=0, b>=0, a>=0);
       glColor4ub(r&0xff, g&0xff, b&0xff, a&0xff);
       glCallList(gmPortals);             /* draw them portals */
       glPopAttrib();
}

Here is the caller graph for this function:

void gmEndGeom ( void  )

Definition at line 77 of file rhd_geom.c.

{
       register int  i, j;

       FORALLGEOM(gmCurrent, i) {
              FORALLGEOM(gmNext, j)
                     if (gmNext[j].listid == gmCurrent[i].listid)
                            break;
              if (j >= MAXGEO || gmNext[j].gfile == NULL) {
                     glDeleteLists(gmCurrent[i].listid, /* not found */
                                   gmCurrent[i].nlists);
                     freestr(gmCurrent[i].gfile);
              }
       }
       memcpy((void *)gmCurrent, (void *)gmNext, sizeof(gmNext));
       memset((void *)gmNext, '\0', sizeof(gmNext));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gmEndPortal ( void  )

Definition at line 191 of file rhd_geom.c.

{
       register int  n;

       FORALLPORT(newportlist, n);
       if (!n) {                   /* free old GL list */
              if (gmPortals)
                     glDeleteLists(gmPortals, Nlists);
              gmPortals = 0;
       } else
              qsort(newportlist, n, sizeof(char *), sstrcmp);
       FORALLPORT(newportlist, n)         /* compare sorted lists */
              if (curportlist[n] == NULL ||
                            strcmp(curportlist[n],newportlist[n])) {
                                          /* load new list */
                     if (gmPortals)
                            glDeleteLists(gmPortals, 1);
                     FORALLPORT(newportlist, n);
                     dolights = 0;
                     domats = 0;
                     gmPortals = rgl_filelist(n, newportlist, &Nlists);
                     break;
              }
       FORALLPORT(curportlist, n)         /* free old file list */
              freestr(curportlist[n]);
       memcpy((void *)curportlist, (void *)newportlist, sizeof(newportlist));
       memset((void *)newportlist, '\0', sizeof(newportlist));
       return(gmPortals);                 /* return GL list id */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gmNewGeom ( char *  file)

Definition at line 43 of file rhd_geom.c.

{
       register int  i, j;
                                   /* check if already in next list */
       FORALLGEOM(gmNext, i)
              if (!strcmp(file, gmNext[i].gfile))
                     return;
       if (i >= MAXGEO) {
              error(WARNING, "too many section octrees -- ignoring extra");
              return;
       }
                                   /* check if copy in current list */
       FORALLGEOM(gmCurrent, j)
              if (!strcmp(file, gmCurrent[j].gfile)) {
                     gmNext[i] = gmCurrent[j];
                     return;
              }
                                   /* else load new octree */
       gmNext[i].gfile = savestr(file);
       dolights = 0;
       domats = 1;
       gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad,
                                   &gmNext[i].nlists);
       gmNext[i].rad *= 1.732;            /* go to corners */
#ifdef DEBUG
       fprintf(stderr, "Loaded octree \"%s\" into listID %d with radius %f\n",
                     file, gmNext[i].listid, gmNext[i].rad);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gmNewPortal ( char *  pflist)

Definition at line 159 of file rhd_geom.c.

{
       register int  i;
       char   newfile[128];

       if (pflist == NULL)
              return;
       while ((pflist = nextword(newfile, sizeof(newfile), pflist)) != NULL) {
              FORALLPORT(newportlist,i)
                     if (!strcmp(newportlist[i], newfile))
                            goto endloop; /* in list already */
              if (i >= MAXPORT) {
                     error(WARNING, "too many portals -- ignoring extra");
                     return;
              }
              newportlist[i] = savestr(newfile);
       endloop:;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int sstrcmp ( char **  ss0,
char **  ss1 
) [static]

Definition at line 183 of file rhd_geom.c.

{
       return(strcmp(*ss0, *ss1));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* curportlist[MAXPORT] [static]

Definition at line 24 of file rhd_geom.c.

struct gmEntry gmCurrent[MAXGEO] [static]
struct gmEntry gmNext[MAXGEO] [static]
int gmPortals = 0

Definition at line 22 of file rhd_geom.c.

char* newportlist[MAXPORT] [static]

Definition at line 25 of file rhd_geom.c.

int Nlists = 0 [static]

Definition at line 23 of file rhd_geom.c.

const char RCSid[] = "$Id: rhd_geom.c,v 3.14 2004/01/01 11:21:55 schorsch Exp $" [static]

Definition at line 2 of file rhd_geom.c.