~ubuntu-branches/ubuntu/lucid/meshlab/lucid

« back to all changes in this revision

Viewing changes to meshlab/src/meshlabplugins/render_splatpyramid/point_based_renderer.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-10-08 16:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091008164041-0c2ealqv8b8uc20c
Tags: 1.2.2-1
* New upstream version
* Do not build filter_isoparametrization because liblevmar dependency
  is not (yet) in Debian
* Fix compilation with gcc-4.4, thanks to Jonathan Liu for the patch
  (closes: #539544)
* rules: Add compiler variables to the qmake call (for testing with new
  GCC versions)
* io_3ds.pro: Make LIBS and INCLUDEPATH point to Debian version of lib3ds
* io_epoch.pro: Make LIBS point to Debian version of libbz2
* control:
  - Move Homepage URL to the source package section
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** point_based_renderer.h Point Based Render header.
 
3
**
 
4
**
 
5
**   history:   created  02-Jul-07
 
6
*/
 
7
 
 
8
 
 
9
#ifndef __POINT_BASED_RENDERER_H__
 
10
#define __POINT_BASED_RENDERER_H__
 
11
 
 
12
#include <iostream>
 
13
 
 
14
#include "surfel.hpp"
 
15
#include "materials.h"
 
16
#include "object.h"
 
17
 
 
18
/**
 
19
 * Base class for rendering algorithms.
 
20
 **/
 
21
class PointBasedRenderer
 
22
{
 
23
 private:
 
24
 
 
25
 public:
 
26
  /**
 
27
   * Default constructor, creates an 1024x1024 screen size.
 
28
   **/
 
29
  PointBasedRenderer() :
 
30
    canvas_width(1024), canvas_height(1024), scale_factor(1.0),
 
31
    material_id(0), depth_test(1), back_face_culling(1), elliptical_weight(0),
 
32
    reconstruction_filter_size(1.0), prefilter_size(1.0)
 
33
    {}
 
34
 
 
35
  /**
 
36
   * Constructor for given screen size.
 
37
   * @param w Screen width.
 
38
   * @param h Screen height.
 
39
   **/
 
40
  PointBasedRenderer(int w, int h) :
 
41
    canvas_width(w), canvas_height(h), scale_factor(1.0),
 
42
    material_id(0), depth_test(1), back_face_culling(1), elliptical_weight(0),
 
43
    reconstruction_filter_size(1.0), prefilter_size(1.0)
 
44
    {}
 
45
  
 
46
  virtual ~PointBasedRenderer() {}
 
47
 
 
48
  virtual void init ( void ) {}
 
49
 
 
50
   /**
 
51
    * Render point based model using deferred shading (per pixel shading).
 
52
    **/
 
53
  virtual void draw( void ) {}
 
54
 
 
55
   /**
 
56
    * Intepolate samples in screen space using pyramid method.
 
57
    **/
 
58
   virtual void interpolate( void ) {}
 
59
 
 
60
   /**
 
61
    * Projects samples to screen space.
 
62
    * @param p Point to primitives instance containing samples.
 
63
    **/
 
64
   virtual void projectSamples(Object* ) {}
 
65
 
 
66
   /**
 
67
    * Clears all buffers, including those of the framebuffer object.
 
68
    **/
 
69
   virtual void clearBuffers( void ) {}
 
70
 
 
71
   /**
 
72
    **/
 
73
   virtual void setMinimumRadiusSize(double s) { minimum_radius_size = s; }
 
74
 
 
75
 
 
76
   /**
 
77
    * Sets the size of the prefilter (default = 1.0).
 
78
    * This filter works as an increment of the radius size in screen space.
 
79
    * @param s Prefilter size.
 
80
    **/
 
81
   virtual void setPrefilterSize(double s) { prefilter_size = s; }
 
82
 
 
83
   /**
 
84
    * Sets the size of the reconstruction filter (default = 1.0).
 
85
    * This filter works as a multiplier of the radius size in screen space.
 
86
    * @param s Reconstruction filter size.
 
87
    **/
 
88
   virtual void setReconstructionFilterSize(double s) { reconstruction_filter_size = s; }
 
89
 
 
90
   /**
 
91
    * Sets the size of the reconstruction filter (default = 1.0).
 
92
    * This filter works as a multiplier of the radius size in screen space.
 
93
    * @param s Reconstruction filter size.
 
94
    **/
 
95
   virtual double getReconstructionFilterSize(void) { return reconstruction_filter_size; }
 
96
 
 
97
   /**
 
98
    * Sets the quality threshold for interpolating samples.
 
99
    * @param q Quality threshold.
 
100
    **/
 
101
   virtual void setQualityThreshold(double q) { quality_threshold = q; }
 
102
 
 
103
   /**
 
104
    * Sets the quality per vertex flag.
 
105
    * @param q Quality flag.
 
106
    **/
 
107
   virtual void setQualityPerVertex(bool q) { quality_per_vertex = q; }
 
108
 
 
109
   /** 
 
110
    * Sets the kernel size, for templates rendering only.
 
111
    * @param Kernel size.
 
112
    **/
 
113
   virtual void setGpuMaskSize ( int ) {}
 
114
 
 
115
   /** 
 
116
    * Sets eye vector used mainly for backface culling.
 
117
    * @param e Given eye vector.
 
118
    **/
 
119
   void setEye (Point3f e) {
 
120
     eye = e;
 
121
   }
 
122
 
 
123
   /** 
 
124
    * Sets scale factor for zooming, scales sample's radius size.
 
125
    * @param s Given scale factor.
 
126
    **/
 
127
   void setScaleFactor (double s) {
 
128
     scale_factor = s;
 
129
   }
 
130
 
 
131
   /**
 
132
    * Sets the material id number for rendering.
 
133
    * @param m Material id.
 
134
    **/
 
135
   void setMaterial (const int m) {
 
136
     if (m < NUM_MATERIALS)
 
137
       material_id = m;
 
138
   }
 
139
 
 
140
   /**
 
141
    * Gets the material id number for rendering.
 
142
    * @return Current material id.
 
143
    **/
 
144
   const int getMaterial ( void ) {
 
145
     return material_id;
 
146
   }
 
147
 
 
148
   void upMaterial ( void ) {
 
149
     ++material_id;
 
150
     if (material_id == NUM_MATERIALS)
 
151
       material_id = 0;
 
152
 
 
153
   }
 
154
   void downMaterial ( void ) {
 
155
     --material_id;
 
156
     if (material_id < 0)
 
157
       material_id = NUM_MATERIALS - 1;
 
158
   }
 
159
 
 
160
   /**
 
161
    * Sets the depth test flag on/off.
 
162
    * @param d Given depth test state.
 
163
    **/
 
164
   void setDepthTest( const bool d ) {
 
165
     depth_test = d;
 
166
   }
 
167
 
 
168
   /**
 
169
    * Sets the backface culling flag on/off.
 
170
    * @param b Given backface culling state.
 
171
    **/
 
172
   void setBackFaceCulling( const bool b ) {
 
173
     back_face_culling = b;
 
174
   }
 
175
 
 
176
   void setEllipticalWeight( const bool w ) {
 
177
     elliptical_weight = w;
 
178
   }
 
179
 
 
180
 protected:
 
181
 
 
182
   /// Canvas width.
 
183
   int canvas_width;
 
184
   /// Canvas height.
 
185
   int canvas_height;
 
186
 
 
187
   /// Eye position.
 
188
   Point3f eye;
 
189
 
 
190
   /// Scale factor (camera zooming)
 
191
   double scale_factor;
 
192
 
 
193
   /// Identification of the material from materials.h table.
 
194
   int material_id;
 
195
 
 
196
   /// Flag to turn on/off depth test
 
197
   bool depth_test;
 
198
 
 
199
   /// Flag to turn on/off back_face_culling
 
200
   bool back_face_culling;
 
201
 
 
202
   /// Flag to turn on/off elliptical weight
 
203
   bool elliptical_weight;
 
204
 
 
205
   /// Flag to turn on/off quality per vertex interpolation.
 
206
   bool quality_per_vertex;
 
207
 
 
208
   /// Size of quality threshold for interpolation.
 
209
   double quality_threshold;
 
210
 
 
211
   /// Size of reconstruction filter.
 
212
   double reconstruction_filter_size;
 
213
   /// Size of antialising filter.
 
214
   double prefilter_size;
 
215
   /// Minimum smallest radius size.
 
216
   double minimum_radius_size;
 
217
 
 
218
};
 
219
 
 
220
//inline void check_for_ogl_error( char * from = 0) {
 
221
inline void check_for_ogl_error( string from = "") {
 
222
  GLenum err = glGetError();
 
223
  if (err != GL_NO_ERROR) {
 
224
        cerr << from << endl;
 
225
        cerr << __FILE__ << " (" << __LINE__ << ") " << gluErrorString(err) << endl;
 
226
  }
 
227
}
 
228
 
 
229
#endif