-
Notifications
You must be signed in to change notification settings - Fork 74
/
viewer.h
168 lines (135 loc) · 3.84 KB
/
viewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* viewer.h
*
* $Id: viewer.h,v 1.2 2001/07/14 00:41:27 xue Exp $
* $Log: viewer.h,v $
* Revision 1.2 2001/07/14 00:41:27 xue
* complete basic functions for splatter
*
* Revision 1.1 2001/07/08 21:49:34 xue
* Initial version
*
*/
#ifndef __VIEWER_H
#define __VIEWER_H
#include "Datatype.h"
#include "OSUmatrix.h"
#include "volume.h"
#include "tsplat.h"
enum PROJECTION_TYPE {
PERSPECTIVE,
PARALLEL
};
// 3D view structure to hold observer information
typedef struct {
PROJECTION_TYPE type;// projection type, either PERSPECTIVE or PARALLEL
REAL view_angle; // angle between line of sight and
// top of view pyramid
REAL hither; // distance from eye to near plane
REAL yon; // distance from eye to far plane
REAL image_plane; // distance from eye to image plane
REAL aspect_ratio; // width/height of view pyramid
REAL head_tilt; // (CCW) angle of head tilt in degrees
VECTOR3 eye; // eye position
VECTOR3 coi; // center of interest
REAL left; // for parallel
REAL right;
REAL bottom;
REAL top;
} VIEW3D_INFO;
typedef struct {
double kernel_radius;
INT tsplat_size;
REAL sigma;
REAL slice_depth;
} SPLAT_INFO;
class CRect {
public:
CRect() {left=right=top=bottom=0;}
CRect(INT l, INT t, INT r, INT b) {left=l;right=r;top=t;bottom=b;}
INT Width() { return right-left+1; }
INT Height() { return bottom-top+1; }
void Set(INT l, INT t, INT r, INT b) {left=l;right=r;top=t;bottom=b;}
public:
INT left;
INT right;
INT top;
INT bottom;
};
class CLight {
public:
CLight() {}
~CLight() {}
void SetPosition(VECTOR3 pos) { position = pos; }
VECTOR3 GetPosition() { return position; }
void SetIntensity(REAL intens) { intensity = intens; }
inline REAL GetIntensity(const VECTOR3 & pt_to_illuminate) { return intensity; }
protected:
VECTOR3 position;
REAL intensity;
};
typedef struct _VoxelEntry {
int index;
struct _VoxelEntry *next;
}VoxelEntry;
typedef struct _SliceEntry {
REAL a, b;
VoxelEntry *voxel;
}SliceEntry;
typedef struct _Vertex{
GLfloat x, y, z;
GLfloat r, g, b, a;
GLfloat index; // For vertex program, the vertex index on the billboard, from 0 to 3
} Vertex;
class CViewer
{
public:
CViewer();
~CViewer();
void Load(char* file_name);
void SetDefaultViewInfo();
void SetViewInfo(VIEW3D_INFO *info);
void GetViewInfo(VIEW3D_INFO *info);
void SetViewport(INT l, INT t, INT r, INT b);
void Clear();
void Z_MinMax(REAL *min, REAL *max);
// without nVidia vertex program
void RealizeImm(); // render immediate mode with presorted voxel list
void RealizeList(); // render with display list
void RealizeStream(); // rednder vertex stream
void RealizeConvolution();
// with nVidia vertex program
void RealizeImm_NV(); // render immediate mode with presorted voxel list by nVidia vertex program ext
void RealizeList_NV(); // render display list with nVidia vertex program ext
void RealizeStream_NV(); // rednder vertex stream with nVidia vertex program
void RealizeConvolution_NV();
void InitVoxelList();
void InitConvolutionVoxelList();
void InitSortedLists();
private:
void Sort(VECTOR3 eye, GLuint* index_list);
void Sort2(int order, GLuint* index_list, GLuint vertices);
void InitEyes();
int width, height;
public:
GLfloat slice_depth;
int slice_num;
SliceEntry* slice;
Vertex *vertex_list;
//BB_Vertex *current_vertex_list;
//C_Vertex *convolution_vertex_list;
GLuint *current_vertex_indices;
GLuint vertex_num;
GLuint *index_lut;
#define SORTED_LIST_NUM 6
GLuint* vertex_indices[SORTED_LIST_NUM];
VECTOR3 eyes[SORTED_LIST_NUM];
VIEW3D_INFO view_info;
SPLAT_INFO splat_info;
VECTOR3 background;
CLight *light;
REAL ambient;
CRect viewport;
CVolume *volume;
char output_file[1024];
};
#endif /* __VIEWER_H */