ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holo.h
Revision: 3.15
Committed: Wed Aug 12 17:54:15 1998 UTC (25 years, 7 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.14: +4 -10 lines
Log Message:
moved int2 and int4 definitions to standard.h

File Contents

# User Rev Content
1 gwlarson 3.15 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2 gregl 3.1
3     /* SCCSid "$SunId$ SGI" */
4    
5     /*
6     * Header file for holodeck programs
7     *
8     * 9/29/97 GWLarson
9     */
10    
11     #include "standard.h"
12     #include "color.h"
13    
14     #ifndef HDMAX
15     #define HDMAX 128 /* maximum active holodeck sections */
16     #endif
17    
18     #define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */
19     #define DCLIN (unsigned)(1L<<11) /* linear depth limit */
20    
21     typedef struct {
22     BYTE r[2][2]; /* ray direction index */
23 gwlarson 3.15 COLR v; /* color value */
24     unsigned int2 d; /* depth code (from entry wall) */
25     } RAYVAL; /* ray value */
26 gregl 3.1
27     /*
28     * Walls are ordered: X0 X1 X2 WN
29     * 0 ? ? 0
30     * 1 ? ? 1
31     * ? 0 ? 2
32     * ? 1 ? 3
33     * ? ? 0 4
34     * ? ? 1 5
35     *
36     * Grid on wall WN corresponds to X(WN/2+1)%3 and X(WN/2+2)%3, resp.
37     */
38    
39     typedef struct {
40     short w; /* wall number */
41     short i[2]; /* index on wall grid */
42 gregl 3.2 } GCOORD; /* grid coordinates (two for beam) */
43 gregl 3.1
44     typedef struct {
45     unsigned int4 nrd; /* number of beam rays bundled on disk */
46     long fo; /* position in file */
47     } BEAMI; /* beam index */
48    
49     typedef struct {
50     unsigned int4 nrm; /* number of beam rays bundled in memory */
51     unsigned long tick; /* clock tick for LRU replacement */
52     } BEAM; /* followed by nrm RAYVAL's */
53    
54 gregl 3.3 #define hdbray(bp) ((RAYVAL *)((bp)+1))
55 gregl 3.1 #define hdbsiz(nr) (sizeof(BEAM)+(nr)*sizeof(RAYVAL))
56    
57     typedef struct {
58     FVECT orig; /* prism origin (first) */
59     FVECT xv[3]; /* side vectors (second) */
60     int2 grid[3]; /* grid resolution (third) */
61     } HDGRID; /* holodeck section grid (must match HOLO struct) */
62    
63     typedef struct holo {
64     FVECT orig; /* prism origin (first) */
65     FVECT xv[3]; /* side vectors (second) */
66     int2 grid[3]; /* grid resolution (third) */
67     int fd; /* file descriptor */
68     short dirty; /* beam index needs update to file */
69     double tlin; /* linear range for depth encoding */
70 gregl 3.13 FVECT wg[3]; /* wall grid vectors (derived) */
71     double wo[6]; /* wall grid offsets (derived) */
72 gregl 3.1 int wi[6]; /* wall super-indices (derived) */
73     char *priv; /* pointer to private client data */
74     BEAM **bl; /* beam pointers (memory cache) */
75     BEAMI bi[1]; /* beam index (extends struct) */
76     } HOLO; /* holodeck section */
77    
78 gregl 3.9 typedef struct {
79     HOLO *h; /* pointer to holodeck */
80     int b; /* beam index */
81     } HDBEAMI; /* holodeck beam index */
82    
83 gregl 3.14 #define nbeams(hp) (((hp)->wi[5]-1)<<1)
84 gregl 3.1 #define biglob(hp) ((hp)->bi)
85     #define blglob(hp) (*(hp)->bl)
86    
87     #define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd)
88    
89 gregl 3.7 #define hdflush(hp) (hdfreebeam(hp,0) && hdsync(hp,0))
90     #define hdclobber(hp) (hdkillbeam(hp,0) && hdsync(hp,0))
91 gregl 3.1
92 gregl 3.4 extern HOLO *hdinit(), *hdalloc();
93 gregl 3.1 extern BEAM *hdgetbeam();
94     extern RAYVAL *hdnewrays();
95 gregl 3.9 extern unsigned hdmemuse();
96 gregl 3.12 extern long hdfiluse(), hdfilen(), hdallocfrag();
97 gregl 3.1 extern double hdray(), hdinter();
98     extern unsigned hdcode();
99 gregl 3.14 extern int hdfilord();
100 gregl 3.1
101 gregl 3.9 extern unsigned hdcachesize; /* target cache size (bytes) */
102 gregl 3.1 extern unsigned long hdclock; /* holodeck system clock */
103     extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */
104    
105     extern float hd_depthmap[]; /* depth conversion map */
106 gregl 3.13
107     extern int hdwg0[6]; /* wall grid 0 index */
108     extern int hdwg1[6]; /* wall grid 1 index */
109 gregl 3.1
110     #define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \
111     (hp)->tlin * ( (dc) >= DCLIN ? \
112     hd_depthmap[(dc)-DCLIN] : \
113     ((dc)+.5)/DCLIN ) )
114    
115     #define HOLOFMT "Holodeck" /* file format identifier */
116     #define HOLOVERS 0 /* file format version number */
117 gregl 3.11 #define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */
118 gregl 3.1
119     /*
120     * A holodeck file consists of an information header terminated by a
121     * blank line, with "FORMAT=Holodeck" somewhere in it.
122     * The first integer after the information header is the
123     * above magic number, which includes the file format version number.
124 gregl 3.6 * The first longword after the magic number is a pointer to the pointer
125     * just before the SECOND holodeck section, or 0 if there is only one.
126 gregl 3.1 * This longword is immediately followed by the first holodeck
127     * section header and directory.
128     * Similarly, every holodeck section in the file is preceeded by
129     * a pointer to the following section, or 0 for the final section.
130     * Since holodeck files consist of directly written C data structures,
131     * they are not generally portable between different machine architectures.
132     * In particular, different floating point formats or bit/byte ordering
133     * will make the data unusable. This is unfortunate, and may be changed
134     * in future versions, but we thought this would be best for paging speed
135     * in our initial implementation.
136     */