ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_sample.h
Revision: 3.9
Committed: Fri Jun 20 00:25:49 2003 UTC (20 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 3.8: +6 -11 lines
Log Message:
Changed instances of "int4" to "int32" and "int2" to "int16"

File Contents

# User Rev Content
1 greg 3.9 /* RCSid: $Id: rhd_sample.h,v 3.8 2003/02/22 02:07:24 greg Exp $ */
2 gwlarson 3.1 /*
3     * Sample data structures for holodeck display drivers.
4 greg 3.9 *
5     * Include after "standard.h"
6 gwlarson 3.1 */
7     #include "color.h"
8     #include "tonemap.h"
9     #include "rhdriver.h"
10 greg 3.8 #include "object.h"
11 gwlarson 3.1
12 gwlarson 3.3 #ifndef INVALID
13     #define INVALID -1
14     #endif
15    
16 simmons 3.7 #define SFLOAT float
17 greg 3.8
18     typedef OBJECT S_ID;
19    
20     #define S_ID_MAX ((1 << ((sizeof(S_ID)<<3)-1))-1)
21 gwlarson 3.6
22 gwlarson 3.3 typedef struct samp {
23 simmons 3.7 SFLOAT (*wp)[3]; /* world intersection point array */
24 greg 3.9 int32 *wd; /* world direction array */
25 gwlarson 3.1 TMbright *brt; /* encoded brightness array */
26     BYTE (*chr)[3]; /* encoded chrominance array */
27     BYTE (*rgb)[3]; /* tone-mapped color array */
28 gwlarson 3.6 int *info; /* Extra sample info */
29 greg 3.8 int *info1; /* Extra sample info */
30 gwlarson 3.1 int max_samp; /* maximum number of samples */
31 greg 3.8 int max_base_pt; /* maximum number of aux points */
32     S_ID next_base_pt; /* next auxilliary point to add */
33     S_ID replace_samp; /* next sample to free */
34 gwlarson 3.3 int num_samp; /* current number of samples */
35 greg 3.8 S_ID tone_map; /* pointer to next value(s)t tonemap*/
36     S_ID free_samp; /* next free sample */
37 gwlarson 3.1 char *base; /* base of allocated memory */
38 gwlarson 3.3 } SAMP;
39 gwlarson 3.1
40 gwlarson 3.3 /* Sample field access macros */
41     #define S_W_PT(s) ((s)->wp)
42     #define S_W_DIR(s) ((s)->wd)
43     #define S_BRT(s) ((s)->brt)
44     #define S_CHR(s) ((s)->chr)
45     #define S_RGB(s) ((s)->rgb)
46 gwlarson 3.6 #define S_INFO(s) ((s)->info)
47 greg 3.8 #define S_INFO1(s) ((s)->info1)
48 gwlarson 3.3 #define S_MAX_SAMP(s) ((s)->max_samp)
49     #define S_MAX_BASE_PT(s) ((s)->max_base_pt)
50     #define S_NEXT_BASE_PT(s) ((s)->next_base_pt)
51     #define S_REPLACE_SAMP(s) ((s)->replace_samp)
52     #define S_NUM_SAMP(s) ((s)->num_samp)
53     #define S_TONE_MAP(s) ((s)->tone_map)
54 gwlarson 3.6 #define S_FREE_SAMP(s) ((s)->free_samp)
55 gwlarson 3.3 #define S_BASE(s) ((s)->base)
56 gwlarson 3.1
57 gwlarson 3.3 #define S_MAX_POINTS(s) ((s)->max_base_pt)
58     #define S_NTH_W_PT(s,n) (S_W_PT(s)[(n)])
59     #define S_NTH_W_DIR(s,n) (S_W_DIR(s)[(n)])
60     #define S_NTH_RGB(s,n) (S_RGB(s)[(n)])
61     #define S_NTH_CHR(s,n) (S_CHR(s)[(n)])
62 gwlarson 3.6 #define S_NTH_INFO(s,n) (S_INFO(s)[(n)])
63 greg 3.8 #define S_NTH_INFO1(s,n) (S_INFO1(s)[(n)])
64 gwlarson 3.3 #define S_NTH_BRT(s,n) (S_BRT(s)[(n)])
65 gwlarson 3.6
66 gwlarson 3.3 /* Sample Flag macros */
67     #define S_IS_FLAG(s) IS_FLAG(samp_flag,s)
68     #define S_SET_FLAG(s) SET_FLAG(samp_flag,s)
69     #define S_CLR_FLAG(s) CLR_FLAG(samp_flag,s)
70 gwlarson 3.1
71 gwlarson 3.4 #define S_NTH_NEXT(s,n) S_NTH_W_DIR(s,n)
72 gwlarson 3.6 #define sUnalloc_samp(s,n) (S_NTH_NEXT(s,n)=S_FREE_SAMP(s),S_FREE_SAMP(s)=n)
73 gwlarson 3.3 #define sClear_base_points(s) (S_NEXT_BASE_PT(s) = S_MAX_SAMP(s))
74     #define sClear(s) sInit(s)
75 gwlarson 3.6 /* MAXDIFF2 Max allowed cos angle squared of sample dir from current view */
76     /* In terms of cos: if angle is 30: MAXDIFF2 = cos(30)^2, if difference
77     is greater than this point not accepted on rebuild
78     */
79     #define MAXDIFF2 0.75
80     /* Max difference in direction for points at infinity: if over 45degrees
81     not accepted on rebuild cos(45)
82     */
83     #define MAXDIR 0.70710678
84 gwlarson 3.5 #define MAXQUALITY 10000 /* Maximum quality for rendering rep */
85 gwlarson 3.1
86 gwlarson 3.3 extern SAMP rsL;
87     extern double sDepthEps; /* epsilon to compare depths (z fraction) */
88 greg 3.9 extern int32 encodedir(); /* Encodes FVECT direction */
89 gwlarson 3.3 extern void decodedir(); /* Decodes dir-> FVECT */
90     extern double fdir2diff(), dir2diff(); /* Compare dir and FVECT */
91 greg 3.9 extern int32 *samp_flag; /* Per/sample flags s */
92 gwlarson 3.3
93 gwlarson 3.1 /* These values are set by the driver, and used in the OGL call for glFrustum*/
94     extern double dev_zmin,dev_zmax;
95 greg 3.8 extern S_ID sAdd_base_point();
96 gwlarson 3.3 extern SAMP *sAlloc();
97 greg 3.8 extern S_ID sAlloc_samp();
98     /*
99     * int
100     * smInit(n) : Initialize/clear data structures for n entries
101     * int n;
102     *
103     * Initialize sampL and other data structures for at least n samples.
104     * If n is 0, then free data structures. Return number actually allocated.
105     *
106     *
107     * int
108     * smNewSamp(c, p, v) : register new sample point and return index
109     * COLR c; : pixel color (RGBE)
110     * FVECT p; : world intersection point
111     * FVECT v; : ray direction vector
112     *
113     * Add new sample point to data structures, removing old values as necessary.
114     * New sample representation will be output in next call to smUpdate().
115     *
116     *
117     * int
118     * smFindSamp(orig, dir): intersect ray with 3D rep. and find closest sample
119     * FVECT orig, dir;
120     *
121     * Find the closest sample to the given ray. Return -1 on failure.
122     *
123     *
124     * smClean() : display has been wiped clean
125     *
126     * Called after display has been effectively cleared, meaning that all
127     * geometry must be resent down the pipeline in the next call to smUpdate().
128     *
129     *
130     * smUpdate(vp, qua) : update OpenGL output geometry for view vp
131     * VIEW *vp; : desired view
132     * int qua; : quality level (percentage on linear time scale)
133     *
134     * Draw new geometric representation using OpenGL calls. Assume that the
135     * view has already been set up and the correct frame buffer has been
136     * selected for drawing. The quality level is on a linear scale, where 100%
137     * is full (final) quality. It is not necessary to redraw geometry that has
138     * been output since the last call to smClean(). (The last view drawn will
139     * be vp==&odev.v each time.)
140     */
141 gwlarson 3.1
142    
143    
144    
145    
146