BALL  1.4.79
renderer.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
6 #define BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
7 
8 #ifndef BALL_VIEW_KERNEL_REPRESENTATION_H
10 #endif
11 
12 #ifndef BALL_CONCEPT_OBJECT_H
13 # include <BALL/CONCEPT/object.h>
14 #endif
15 
16 #ifndef BALL_VIEW_KERNEL_STAGE_H
17 # include <BALL/VIEW/KERNEL/stage.h>
18 #endif
19 
20 #ifndef BALL_MATHS_VECTOR2_H
21 # include <BALL/MATHS/vector2.h>
22 #endif
23 
24 class QImage;
25 
26 namespace BALL
27 {
28  namespace VIEW
29  {
30  class Scene;
31  class Line;
32  class MultiLine;
33  class Tube;
34  class Mesh;
35  class Label;
36  class Point;
37  class Sphere;
38  class Disc;
39  class Box;
40  class SimpleBox;
41  class TwoColoredLine;
42  class TwoColoredTube;
43  class ClippingPlane;
44  class GridVisualisation;
45  class QuadMesh;
46 
55  {
56  public:
57 
60  {
61  NO_STEREO = 0,
62 
65 
68 
71 
74 
76  INTERLACED_STEREO
77  };
78 
80 
81 
84 
87  Renderer();
88 
91  Renderer(const Renderer& renderer);
92 
95  virtual ~Renderer() {}
96 
99  virtual void clear(){}
100 
104  virtual bool init(Scene& scene);
105 
109  virtual bool init(const Stage& stage, float height, float width);
110 
112  virtual void setLights(bool reset_all = false);
113 
116  virtual void updateCamera(const Camera* camera = 0);
117 
119  virtual void updateBackgroundColor();
120 
122  virtual void setupEnvironmentMap(const QImage& image);
123 
129  virtual void setupStereo(float eye_separation, float focal_length);
130 
133  virtual void useContinuousLoop(bool use_loop)
134  {
135  // TODO: mutex for use_continuous_loop_ just to be on the safe side
136  use_continuous_loop_ = use_loop;
137  };
138 
141  bool isContinuous() { return use_continuous_loop_; }
142 
144  virtual bool finish();
145 
149  virtual Vector3 mapViewportTo3D(Position x, Position y);
150 
154  virtual Vector2 map3DToViewport(const Vector3& vec);
155 
158  virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
159  std::list<GeometricObject*>& objects);
160 
163  virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f,
164  float& top_f, float& bottom_f);
165 
167 
170 
173  virtual bool renderOneRepresentation(const Representation& representation);
174 
175 
178  virtual void bufferRepresentation(const Representation& /*rep*/) {};
179 
182  virtual void removeRepresentation(const Representation& /*rep*/) {};
183 
186  virtual const Stage& getStage() const
187  { return *stage_;}
188 
191  virtual void setStage(const Stage& stage)
192  { stage_ = &stage;}
193 
195  bool hasStage() const;
196 
198  virtual void setSize(float width, float height) {width_ = width; height_ = height;}
199 
201  virtual float getWidth() const { return width_;}
202 
204  virtual float getHeight() const { return height_;}
205 
210  virtual void setPreviewMode(bool show_preview) { show_preview_ = show_preview; }
211 
216  virtual void showLightSources(bool show_light_sources) { show_light_sources_ = show_light_sources; }
217 
225  virtual void renderRuler();
226 
228  virtual void setStereoMode(StereoMode state);
229 
231  virtual StereoMode getStereoMode() const;
232 
234  virtual void setStereoFrustumConversion(int width_factor, int height_factor);
235 
237 
240 
242  bool operator == (const Renderer& /*renderer*/) const
243  { return true; }
244 
246  virtual void render_(const GeometricObject* object);
247 
248  protected:
249 
251  virtual void renderClippingPlane_(const ClippingPlane&)
252  {Log.error() << "renderClippingPlane_ not implemented in derived Renderer class" << std::endl;}
253 
254  // Render a text label
255  virtual void renderLabel_(const Label& /*label*/)
256  {Log.error() << "renderLabel_ not implemented in derived Renderer class" << std::endl;}
257 
259  virtual void renderLine_(const Line& /*line*/)
260  {Log.error() << "renderLine_ not implemented in derived Renderer class" << std::endl;}
261 
263  virtual void renderMultiLine_(const MultiLine& /*line*/)
264  {Log.error() << "renderMultiLine_ not implemented in derived Renderer class" << std::endl;}
265 
267  virtual void renderMesh_(const Mesh& /*mesh*/)
268  {Log.error() << "renderMesh_ not implemented in derived Renderer class" << std::endl;}
269 
271  virtual void renderPoint_(const Point& /*point*/)
272  {Log.error() << "renderPoint_ not implemented in derived Renderer class" << std::endl;}
273 
275  virtual void renderBox_(const Box& /*box*/)
276  {Log.error() << "renderBox_ not implemented in derived Renderer class" << std::endl;}
277 
279  virtual void renderSimpleBox_(const SimpleBox& /*box*/)
280  {Log.error() << "renderSimpleBox_ not implemented in derived Renderer class" << std::endl;}
281 
283  virtual void renderSphere_(const Sphere& /*sphere*/)
284  {Log.error() << "renderSphere_ not implemented in derived Renderer class" << std::endl;}
285 
287  virtual void renderDisc_(const Disc& /*disc*/)
288  {Log.error() << "renderDisc_ not implemented in derived Renderer class" << std::endl;}
289 
291  virtual void renderTube_(const Tube& /*tube*/)
292  {Log.error() << "renderTube_ not implemented in derived Renderer class" << std::endl;}
293 
295  virtual void renderTwoColoredLine_(const TwoColoredLine& /*two_colored_line*/)
296  {Log.error() << "renderTwoColoredLine_ not implemented in derived Renderer class" << std::endl;}
297 
299  virtual void renderTwoColoredTube_(const TwoColoredTube& /*two_colored_tube*/)
300  {Log.error() << "renderTwoColoredTube_ not implemented in derived Renderer class" << std::endl;}
301 
304  {Log.error() << "renderGridVisualisation_ not implemented in derived Renderer class" << std::endl;}
306  virtual void renderQuadMesh_(const QuadMesh&)
307  {Log.error() << "renderQuadMesh_ not implemented in derived Renderer class" << std::endl;}
309 
310  //_
312 
313  //_
314  const Stage* stage_;
315 
316  //_The width of the render area
317  float width_;
318 
319  //_The height of the render area
320  float height_;
321 
322  //_
324 
325  //_
327 
328  //_
330 
331  //_
333 
334  // An offset added to camera position and look at
336 
338 
341 
343  };
344 
345  } // namespace VIEW
346 } // namespace BALL
347 
348 #endif // BALL_VIEW_RENDERING_RENDERER_H
virtual void renderTwoColoredTube_(const TwoColoredTube &)
Render a tube with two colors.
Definition: renderer.h:299
virtual void renderGridVisualisation_(const GridVisualisation &)
Render a grid.
Definition: renderer.h:303
virtual void renderDisc_(const Disc &)
Render a disc.
Definition: renderer.h:287
#define BALL_CREATE(name)
Definition: create.h:62
virtual void renderClippingPlane_(const ClippingPlane &)
Definition: renderer.h:251
Stereo mode for output on two projectors.
Definition: renderer.h:67
virtual void clear()
Definition: renderer.h:99
virtual void setStage(const Stage &stage)
Definition: renderer.h:191
virtual void setSize(float width, float height)
Set the size of the display.
Definition: renderer.h:198
virtual const Stage & getStage() const
Definition: renderer.h:186
virtual void useContinuousLoop(bool use_loop)
Definition: renderer.h:133
BALL_EXPORT LogStream Log
virtual void renderTube_(const Tube &)
Render a tube.
Definition: renderer.h:291
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
Stereo mode for shutter glasses.
Definition: renderer.h:64
virtual void renderPoint_(const Point &)
Render a single point.
Definition: renderer.h:271
virtual void renderQuadMesh_(const QuadMesh &)
Render a quad mesh.
Definition: renderer.h:306
virtual void renderMesh_(const Mesh &)
Render a surface mesh.
Definition: renderer.h:267
virtual void renderBox_(const Box &)
Render a box.
Definition: renderer.h:275
Size stereo_frustum_conversion_width_
Definition: renderer.h:339
virtual void renderMultiLine_(const MultiLine &)
Render an illuminated line.
Definition: renderer.h:263
virtual void renderTwoColoredLine_(const TwoColoredLine &)
Render a line with two colors.
Definition: renderer.h:295
virtual void bufferRepresentation(const Representation &)
Definition: renderer.h:178
Stereo mode for output on two projectors with one display per head.
Definition: renderer.h:70
LogStream & error(int n=0)
virtual void setPreviewMode(bool show_preview)
Definition: renderer.h:210
virtual void renderLine_(const Line &)
Render a line.
Definition: renderer.h:259
Stereo mode for top bottom views.
Definition: renderer.h:73
const Stage * stage_
Definition: renderer.h:314
-*- Mode: C++; tab-width: 2; -*-
Definition: constants.h:12
virtual void renderSimpleBox_(const SimpleBox &)
Render a simple box (parallel to the axes)
Definition: renderer.h:279
virtual float getWidth() const
Definition: renderer.h:201
Vector3 camera_offset_
Definition: renderer.h:335
virtual void removeRepresentation(const Representation &)
Definition: renderer.h:182
Size stereo_frustum_conversion_height_
Definition: renderer.h:340
virtual void showLightSources(bool show_light_sources)
Definition: renderer.h:216
StereoMode stereo_
Definition: renderer.h:342
virtual void renderSphere_(const Sphere &)
Render a sphere.
Definition: renderer.h:283
virtual void renderLabel_(const Label &)
Definition: renderer.h:255
virtual float getHeight() const
Definition: renderer.h:204