1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ SGI" */ |
4 |
< |
|
1 |
> |
/* RCSid: $Id$ */ |
2 |
|
/* |
3 |
|
* Sample data structures for holodeck display drivers. |
4 |
|
*/ |
5 |
|
#include "color.h" |
6 |
|
#include "tonemap.h" |
7 |
|
#include "rhdriver.h" |
8 |
+ |
#include "object.h" |
9 |
|
|
10 |
|
#ifndef int2 |
11 |
|
#define int2 short |
13 |
|
#ifndef int4 |
14 |
|
#define int4 int |
15 |
|
#endif |
16 |
< |
/* child ordering */ |
17 |
< |
typedef struct rsamp { |
18 |
< |
float (*wp)[3]; /* world intersection point array */ |
16 |
> |
|
17 |
> |
#ifndef INVALID |
18 |
> |
#define INVALID -1 |
19 |
> |
#endif |
20 |
> |
|
21 |
> |
#define SFLOAT float |
22 |
> |
|
23 |
> |
typedef OBJECT S_ID; |
24 |
> |
|
25 |
> |
#define S_ID_MAX ((1 << ((sizeof(S_ID)<<3)-1))-1) |
26 |
> |
|
27 |
> |
typedef struct samp { |
28 |
> |
SFLOAT (*wp)[3]; /* world intersection point array */ |
29 |
|
int4 *wd; /* world direction array */ |
30 |
|
TMbright *brt; /* encoded brightness array */ |
31 |
|
BYTE (*chr)[3]; /* encoded chrominance array */ |
32 |
|
BYTE (*rgb)[3]; /* tone-mapped color array */ |
33 |
+ |
int *info; /* Extra sample info */ |
34 |
+ |
int *info1; /* Extra sample info */ |
35 |
|
int max_samp; /* maximum number of samples */ |
36 |
< |
int max_aux_pt; /* maximum number of aux points */ |
37 |
< |
int next_aux_pt; /* next auxilliary point to add */ |
38 |
< |
int replace_samp; /* next sample to free */ |
39 |
< |
int num_samp; /* reached end of list? */ |
40 |
< |
int tone_map; /* pointer to next value(s) to tonemap*/ |
41 |
< |
int free_samp; /* list of freed samples */ |
36 |
> |
int max_base_pt; /* maximum number of aux points */ |
37 |
> |
S_ID next_base_pt; /* next auxilliary point to add */ |
38 |
> |
S_ID replace_samp; /* next sample to free */ |
39 |
> |
int num_samp; /* current number of samples */ |
40 |
> |
S_ID tone_map; /* pointer to next value(s)t tonemap*/ |
41 |
> |
S_ID free_samp; /* next free sample */ |
42 |
|
char *base; /* base of allocated memory */ |
43 |
< |
} RSAMP; |
43 |
> |
} SAMP; |
44 |
|
|
45 |
< |
#define RS_W_PT(s) ((s)->wp) |
46 |
< |
#define RS_W_DIR(s) ((s)->wd) |
47 |
< |
#define RS_BRT(s) ((s)->brt) |
48 |
< |
#define RS_CHR(s) ((s)->chr) |
49 |
< |
#define RS_RGB(s) ((s)->rgb) |
50 |
< |
#define RS_MAX_SAMP(s) ((s)->max_samp) |
51 |
< |
#define RS_TONE_MAP(s) ((s)->tone_map) |
52 |
< |
#define RS_MAX_POINTS(s) ((s)->max_aux_pt) |
53 |
< |
#define RS_REPLACE_SAMP(s) ((s)->replace_samp) |
54 |
< |
#define RS_NEXT_AUX_PT(s) ((s)->next_aux_pt) |
55 |
< |
#define RS_MAX_AUX_PT(s) ((s)->max_aux_pt) |
56 |
< |
#define RS_BASE(s) ((s)->base) |
57 |
< |
#define RS_NUM_SAMP(s) ((s)->num_samp) |
58 |
< |
#define RS_FREE_SAMP(s) ((s)->free_samp) |
59 |
< |
#define RS_NTH_W_PT(s,n) (RS_W_PT(s)[(n)]) |
60 |
< |
#define RS_NTH_W_DIR(s,n) (RS_W_DIR(s)[(n)]) |
51 |
< |
#define RS_NTH_RGB(s,n) (RS_RGB(s)[(n)]) |
52 |
< |
#define RS_NTH_CHR(s,n) (RS_CHR(s)[(n)]) |
53 |
< |
#define RS_NTH_BRT(s,n) (RS_BRT(s)[(n)]) |
54 |
< |
#define RS_EOL(s) (RS_NUM_SAMP(s) >= RS_MAX_SAMP(s)) |
55 |
< |
extern RSAMP rsL; |
45 |
> |
/* Sample field access macros */ |
46 |
> |
#define S_W_PT(s) ((s)->wp) |
47 |
> |
#define S_W_DIR(s) ((s)->wd) |
48 |
> |
#define S_BRT(s) ((s)->brt) |
49 |
> |
#define S_CHR(s) ((s)->chr) |
50 |
> |
#define S_RGB(s) ((s)->rgb) |
51 |
> |
#define S_INFO(s) ((s)->info) |
52 |
> |
#define S_INFO1(s) ((s)->info1) |
53 |
> |
#define S_MAX_SAMP(s) ((s)->max_samp) |
54 |
> |
#define S_MAX_BASE_PT(s) ((s)->max_base_pt) |
55 |
> |
#define S_NEXT_BASE_PT(s) ((s)->next_base_pt) |
56 |
> |
#define S_REPLACE_SAMP(s) ((s)->replace_samp) |
57 |
> |
#define S_NUM_SAMP(s) ((s)->num_samp) |
58 |
> |
#define S_TONE_MAP(s) ((s)->tone_map) |
59 |
> |
#define S_FREE_SAMP(s) ((s)->free_samp) |
60 |
> |
#define S_BASE(s) ((s)->base) |
61 |
|
|
62 |
< |
extern double rsDepthEps; /* epsilon to compare depths (z fraction) */ |
62 |
> |
#define S_MAX_POINTS(s) ((s)->max_base_pt) |
63 |
> |
#define S_NTH_W_PT(s,n) (S_W_PT(s)[(n)]) |
64 |
> |
#define S_NTH_W_DIR(s,n) (S_W_DIR(s)[(n)]) |
65 |
> |
#define S_NTH_RGB(s,n) (S_RGB(s)[(n)]) |
66 |
> |
#define S_NTH_CHR(s,n) (S_CHR(s)[(n)]) |
67 |
> |
#define S_NTH_INFO(s,n) (S_INFO(s)[(n)]) |
68 |
> |
#define S_NTH_INFO1(s,n) (S_INFO1(s)[(n)]) |
69 |
> |
#define S_NTH_BRT(s,n) (S_BRT(s)[(n)]) |
70 |
|
|
71 |
< |
extern int4 encodedir(); |
72 |
< |
extern double fdir2diff(), dir2diff(); |
73 |
< |
extern void decodedir(); |
71 |
> |
/* Sample Flag macros */ |
72 |
> |
#define S_IS_FLAG(s) IS_FLAG(samp_flag,s) |
73 |
> |
#define S_SET_FLAG(s) SET_FLAG(samp_flag,s) |
74 |
> |
#define S_CLR_FLAG(s) CLR_FLAG(samp_flag,s) |
75 |
> |
|
76 |
> |
#define S_NTH_NEXT(s,n) S_NTH_W_DIR(s,n) |
77 |
> |
#define sUnalloc_samp(s,n) (S_NTH_NEXT(s,n)=S_FREE_SAMP(s),S_FREE_SAMP(s)=n) |
78 |
> |
#define sClear_base_points(s) (S_NEXT_BASE_PT(s) = S_MAX_SAMP(s)) |
79 |
> |
#define sClear(s) sInit(s) |
80 |
> |
/* MAXDIFF2 Max allowed cos angle squared of sample dir from current view */ |
81 |
> |
/* In terms of cos: if angle is 30: MAXDIFF2 = cos(30)^2, if difference |
82 |
> |
is greater than this point not accepted on rebuild |
83 |
> |
*/ |
84 |
> |
#define MAXDIFF2 0.75 |
85 |
> |
/* Max difference in direction for points at infinity: if over 45degrees |
86 |
> |
not accepted on rebuild cos(45) |
87 |
> |
*/ |
88 |
> |
#define MAXDIR 0.70710678 |
89 |
> |
#define MAXQUALITY 10000 /* Maximum quality for rendering rep */ |
90 |
> |
|
91 |
> |
extern SAMP rsL; |
92 |
> |
extern double sDepthEps; /* epsilon to compare depths (z fraction) */ |
93 |
> |
extern int4 encodedir(); /* Encodes FVECT direction */ |
94 |
> |
extern void decodedir(); /* Decodes dir-> FVECT */ |
95 |
> |
extern double fdir2diff(), dir2diff(); /* Compare dir and FVECT */ |
96 |
> |
extern int4 *samp_flag; /* Per/sample flags s */ |
97 |
> |
|
98 |
> |
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
99 |
> |
extern double dev_zmin,dev_zmax; |
100 |
> |
extern S_ID sAdd_base_point(); |
101 |
> |
extern SAMP *sAlloc(); |
102 |
> |
extern S_ID sAlloc_samp(); |
103 |
|
/* |
104 |
|
* int |
105 |
|
* smInit(n) : Initialize/clear data structures for n entries |
140 |
|
* view has already been set up and the correct frame buffer has been |
141 |
|
* selected for drawing. The quality level is on a linear scale, where 100% |
142 |
|
* is full (final) quality. It is not necessary to redraw geometry that has |
143 |
< |
* been output since the last call to smClean(). |
143 |
> |
* been output since the last call to smClean(). (The last view drawn will |
144 |
> |
* be vp==&odev.v each time.) |
145 |
|
*/ |
104 |
– |
|
105 |
– |
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
106 |
– |
extern double dev_zmin,dev_zmax; |
107 |
– |
|
146 |
|
|
147 |
|
|
148 |
|
|