-
Notifications
You must be signed in to change notification settings - Fork 0
/
point_based_renderer.h
214 lines (171 loc) · 4.82 KB
/
point_based_renderer.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
** point_based_renderer.h Point Based Render header.
**
**
** history: created 02-Jul-07
*/
#ifndef __POINT_BASED_RENDERER_H__
#define __POINT_BASED_RENDERER_H__
#include <iostream>
#include "surfel.hpp"
#include "materials.h"
#include "object.h"
/**
* Base class for rendering algorithms.
**/
class PointBasedRenderer
{
private:
public:
/**
* Default constructor, creates an 1024x1024 screen size.
**/
PointBasedRenderer() :
canvas_width(1024), canvas_height(1024), scale_factor(1.0),
material_id(0), depth_test(1), back_face_culling(1), elliptical_weight(0),
reconstruction_filter_size(1.0), prefilter_size(1.0), minimum_radius_size(0.0)
{}
/**
* Constructor for given screen size.
* @param w Screen width.
* @param h Screen height.
**/
PointBasedRenderer(int w, int h) :
canvas_width(w), canvas_height(h), scale_factor(1.0),
material_id(0), depth_test(1), back_face_culling(1), elliptical_weight(0),
reconstruction_filter_size(1.0), prefilter_size(1.0), minimum_radius_size(0.0)
{}
virtual ~PointBasedRenderer() {}
virtual void init ( void ) {}
/**
* Render point based model using deferred shading (per pixel shading).
**/
virtual void draw( void ) {}
/**
* Interpolate samples in screen space using pyramid method.
**/
virtual void interpolate( void ) {}
/**
* Projects samples to screen space.
* @param p Point to primitives instance containing samples.
**/
virtual void projectSamples(Object* ) {}
/**
* Clears all buffers, including those of the framebuffer object.
**/
virtual void clearBuffers( void ) {}
/**
**/
virtual void setMinimumRadiusSize(double s) { minimum_radius_size = s; }
/**
* Sets the size of the prefilter (default = 1.0).
* This filter works as an increment of the radius size in screen space.
* @param s Prefilter size.
**/
virtual void setPrefilterSize(double s) { prefilter_size = s; }
/**
* Sets the size of the reconstruction filter (default = 1.0).
* This filter works as a multiplier of the radius size in screen space.
* @param s Reconstruction filter size.
**/
virtual void setReconstructionFilterSize(double s) { reconstruction_filter_size = s; }
/**
* Sets the size of the reconstruction filter (default = 1.0).
* This filter works as a multiplier of the radius size in screen space.
* @param s Reconstruction filter size.
**/
virtual double getReconstructionFilterSize(void) { return reconstruction_filter_size; }
/**
* Sets the kernel size, for templates rendering only.
* @param Kernel size.
**/
virtual void setGpuMaskSize ( int ) {}
/**
* Sets eye vector used mainly for backface culling.
* @param e Given eye vector.
**/
void setEye (Point3f e) {
eye = e;
}
/**
* Sets scale factor for zooming, scales sample's radius size.
* @param s Given scale factor.
**/
void setScaleFactor (double s) {
scale_factor = s;
}
/**
* Sets the material id number for rendering.
* @param m Material id.
**/
void setMaterial (const int m) {
if (m < NUM_MATERIALS)
material_id = m;
}
/**
* Gets the material id number for rendering.
* @return Current material id.
**/
const int getMaterial ( void ) {
return material_id;
}
void upMaterial ( void ) {
++material_id;
if (material_id == NUM_MATERIALS)
material_id = 0;
}
void downMaterial ( void ) {
--material_id;
if (material_id < 0)
material_id = NUM_MATERIALS - 1;
}
/**
* Sets the depth test flag on/off.
* @param d Given depth test state.
**/
void setDepthTest( const bool d ) {
depth_test = d;
}
/**
* Sets the backface culling flag on/off.
* @param b Given backface culling state.
**/
void setBackFaceCulling( const bool b ) {
back_face_culling = b;
}
void setEllipticalWeight( const bool w ) {
elliptical_weight = w;
}
protected:
/// Canvas width.
int canvas_width;
/// Canvas height.
int canvas_height;
/// Eye position.
Point3f eye;
/// Scale factor (camera zooming)
double scale_factor;
/// Identification of the material from materials.h table.
int material_id;
/// Flag to turn on/off depth test
bool depth_test;
/// Flag to turn on/off back_face_culling
bool back_face_culling;
/// Flag to turn on/off elliptical weight
bool elliptical_weight;
/// Size of reconstruction filter.
double reconstruction_filter_size;
/// Size of antialising filter.
double prefilter_size;
/// Minimum smallest radius size.
double minimum_radius_size;
};
//inline void check_for_ogl_error( char * from = 0) {
inline void check_for_ogl_error( string from = "") {
GLenum err = glGetError();
if (err != GL_NO_ERROR) {
cerr << from << endl;
cerr << __FILE__ << " (" << __LINE__ << ") " << gluErrorString(err) << endl;
}
}
#endif