| 1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
< |
|
| 3 |
< |
/* SCCSid "$SunId$ SGI" */ |
| 4 |
< |
|
| 1 |
> |
/* RCSid: $Id$ */ |
| 2 |
|
/* |
| 3 |
|
* Header file for holodeck programs |
| 4 |
|
* |
| 5 |
|
* 9/29/97 GWLarson |
| 6 |
|
*/ |
| 7 |
+ |
#ifndef _RAD_HOLO_H_ |
| 8 |
+ |
#define _RAD_HOLO_H_ |
| 9 |
|
|
| 10 |
|
#include "standard.h" |
| 11 |
|
#include "color.h" |
| 12 |
|
|
| 13 |
+ |
#ifdef __cplusplus |
| 14 |
+ |
extern "C" { |
| 15 |
+ |
#endif |
| 16 |
+ |
|
| 17 |
|
#ifndef HDMAX |
| 18 |
|
#define HDMAX 128 /* maximum active holodeck sections */ |
| 19 |
|
#endif |
| 26 |
|
#define DCLIN (unsigned)(1L<<11) /* linear depth limit */ |
| 27 |
|
|
| 28 |
|
typedef struct { |
| 29 |
< |
BYTE r[2][2]; /* ray direction index */ |
| 29 |
> |
uby8 r[2][2]; /* ray direction index */ |
| 30 |
|
COLR v; /* color value */ |
| 31 |
< |
unsigned int2 d; /* depth code (from entry wall) */ |
| 31 |
> |
uint16 d; /* depth code (from entry wall) */ |
| 32 |
|
} RAYVAL; /* ray value */ |
| 33 |
|
|
| 34 |
|
/* |
| 49 |
|
} GCOORD; /* grid coordinates (two for beam) */ |
| 50 |
|
|
| 51 |
|
typedef struct { |
| 52 |
< |
unsigned int4 nrd; /* number of beam rays bundled on disk */ |
| 53 |
< |
long fo; /* position in file */ |
| 52 |
> |
uint32 nrd; /* number of beam rays bundled on disk */ |
| 53 |
> |
off_t fo; /* position in file */ |
| 54 |
|
} BEAMI; /* beam index */ |
| 55 |
|
|
| 56 |
|
typedef struct { |
| 57 |
< |
unsigned int4 nrm; /* number of beam rays bundled in memory */ |
| 58 |
< |
unsigned long tick; /* clock tick for LRU replacement */ |
| 57 |
> |
uint32 nrm; /* number of beam rays bundled in memory */ |
| 58 |
> |
uint32 tick; /* clock tick for LRU replacement */ |
| 59 |
|
} BEAM; /* followed by nrm RAYVAL's */ |
| 60 |
|
|
| 61 |
|
#define hdbray(bp) ((RAYVAL *)((bp)+1)) |
| 64 |
|
typedef struct { |
| 65 |
|
FVECT orig; /* prism origin (first) */ |
| 66 |
|
FVECT xv[3]; /* side vectors (second) */ |
| 67 |
< |
int2 grid[3]; /* grid resolution (third) */ |
| 67 |
> |
int16 grid[3]; /* grid resolution (third) */ |
| 68 |
|
} HDGRID; /* holodeck section grid (must match HOLO struct) */ |
| 69 |
|
|
| 70 |
|
typedef struct holo { |
| 71 |
|
FVECT orig; /* prism origin (first) */ |
| 72 |
|
FVECT xv[3]; /* side vectors (second) */ |
| 73 |
< |
int2 grid[3]; /* grid resolution (third) */ |
| 73 |
> |
int16 grid[3]; /* grid resolution (third) */ |
| 74 |
|
int fd; /* file descriptor */ |
| 75 |
|
struct { |
| 76 |
|
int s, n; /* dirty section start, length */ |
| 98 |
|
#define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0)) |
| 99 |
|
#define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0)) |
| 100 |
|
|
| 101 |
< |
extern HOLO *hdinit(), *hdalloc(); |
| 102 |
< |
extern BEAM *hdgetbeam(); |
| 103 |
< |
extern RAYVAL *hdnewrays(); |
| 104 |
< |
extern unsigned hdmemuse(); |
| 105 |
< |
extern long hdfiluse(), hdfilen(), hdallocfrag(); |
| 103 |
< |
extern double hdray(), hdinter(); |
| 104 |
< |
extern unsigned hdcode(); |
| 105 |
< |
extern int hdfilord(); |
| 101 |
> |
#define FF_NEVER 0 /* never free fragments */ |
| 102 |
> |
#define FF_WRITE 01 /* free fragment on write */ |
| 103 |
> |
#define FF_ALLOC 02 /* free fragment on ray alloc */ |
| 104 |
> |
#define FF_READ 04 /* free fragment on read */ |
| 105 |
> |
#define FF_KILL 010 /* free fragment on beam kill */ |
| 106 |
|
|
| 107 |
+ |
extern int hdfragflags; /* tells when to free fragments */ |
| 108 |
|
extern unsigned hdcachesize; /* target cache size (bytes) */ |
| 109 |
|
extern unsigned long hdclock; /* holodeck system clock */ |
| 110 |
|
extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */ |
| 121 |
|
|
| 122 |
|
#define HOLOFMT "Holodeck" /* file format identifier */ |
| 123 |
|
#define HOLOVERS 0 /* file format version number */ |
| 124 |
< |
#define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */ |
| 124 |
> |
#define HOLOMAGIC (324+sizeof(BEAMI)+16*HOLOVERS) /* file magic number */ |
| 125 |
|
|
| 126 |
|
/* |
| 127 |
|
* A holodeck file consists of an information header terminated by a |
| 128 |
|
* blank line, with "FORMAT=Holodeck" somewhere in it. |
| 129 |
|
* The first integer after the information header is the |
| 130 |
|
* above magic number, which includes the file format version number. |
| 131 |
< |
* The first longword after the magic number is a pointer to the pointer |
| 132 |
< |
* just before the SECOND holodeck section, or 0 if there is only one. |
| 131 |
> |
* The first longword (off_t) after the magic number is a pointer to the |
| 132 |
> |
* pointer just before the SECOND holodeck section, or 0 if there is only one. |
| 133 |
|
* This longword is immediately followed by the first holodeck |
| 134 |
|
* section header and directory. |
| 135 |
|
* Similarly, every holodeck section in the file is preceeded by |
| 141 |
|
* in future versions, but we thought this would be best for paging speed |
| 142 |
|
* in our initial implementation. |
| 143 |
|
*/ |
| 144 |
+ |
|
| 145 |
+ |
/* clumpbeams.c */ |
| 146 |
+ |
extern void clumpbeams(HOLO *hp, int maxcnt, int maxsiz, |
| 147 |
+ |
int (*cf)(HOLO *hp, int *bqueue, int bqlen)); |
| 148 |
+ |
/* holo.c */ |
| 149 |
+ |
extern void hdcompgrid(HOLO *hp); |
| 150 |
+ |
extern int hdbcoord(GCOORD gc[2], HOLO *hp, int i); |
| 151 |
+ |
extern int hdbindex(HOLO *hp, GCOORD gc[2]); |
| 152 |
+ |
extern void hdcell(FVECT cp[4], HOLO *hp, GCOORD *gc); |
| 153 |
+ |
extern int hdlseg(int lseg[2][3], HOLO *hp, GCOORD gc[2]); |
| 154 |
+ |
extern unsigned int hdcode(HOLO *hp, double d); |
| 155 |
+ |
extern void hdgrid( FVECT gp, HOLO *hp, FVECT wp); |
| 156 |
+ |
extern void hdworld(FVECT wp, HOLO *hp, FVECT gp); |
| 157 |
+ |
extern double hdray(FVECT ro, FVECT rd, HOLO *hp, GCOORD gc[2], uby8 r[2][2]); |
| 158 |
+ |
extern double hdinter(GCOORD gc[2], uby8 r[2][2], double *ed, HOLO *hp, |
| 159 |
+ |
FVECT ro, FVECT rd); |
| 160 |
+ |
/* holofile.c */ |
| 161 |
+ |
extern HOLO * hdinit(int fd, HDGRID *hproto); |
| 162 |
+ |
extern void hddone(HOLO *hp); |
| 163 |
+ |
extern int hdsync(HOLO *hp, int all); |
| 164 |
+ |
extern off_t hdfilen(int fd); |
| 165 |
+ |
extern off_t hdfiluse(int fd); |
| 166 |
+ |
extern RAYVAL * hdnewrays(HOLO *hp, int i, int nr); |
| 167 |
+ |
extern BEAM * hdgetbeam(HOLO *hp, int i); |
| 168 |
+ |
extern void hdloadbeams(HDBEAMI *hb, int n, void (*bf)(BEAM *bp, HDBEAMI *hb)); |
| 169 |
+ |
extern int hdfreebeam(HOLO *hp, int i); |
| 170 |
+ |
extern int hdfreefrag(HOLO *hp, int i); |
| 171 |
+ |
extern int hdfragOK(int fd, int *listlen, int32 *listsiz); |
| 172 |
+ |
extern int hdkillbeam(HOLO *hp, int i); |
| 173 |
+ |
|
| 174 |
+ |
|
| 175 |
+ |
#ifdef __cplusplus |
| 176 |
+ |
} |
| 177 |
+ |
#endif |
| 178 |
+ |
#endif /* _RAD_HOLO_H_ */ |
| 179 |
+ |
|