BALL 1.5.0
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
18#endif
19
20#ifndef BALL_MATHS_VECTOR2_H
21# include <BALL/MATHS/vector2.h>
22#endif
23
24class QImage;
25
26namespace 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
85
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
122
124 virtual void updateBackgroundColor();
125
127 virtual void setupEnvironmentMap(const QImage& image);
128
134 virtual void setupStereo(float eye_separation, float focal_length);
135
138 virtual void useContinuousLoop(bool use_loop)
139 {
140 // TODO: mutex for use_continuous_loop_ just to be on the safe side
141 use_continuous_loop_ = use_loop;
142 };
143
146 bool isContinuous() { return use_continuous_loop_; }
147
150 virtual bool hasFPScounter() { return false; }
151
154 virtual double getFPS() { return 0; }
155
157 virtual bool finish();
158
163
167 virtual Vector2 map3DToViewport(const Vector3& vec);
168
171 virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
172 std::list<GeometricObject*>& objects);
173
176 virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f,
177 float& top_f, float& bottom_f);
178
180
183
186 virtual bool renderOneRepresentation(const Representation& representation);
187
188
191 virtual void bufferRepresentation(const Representation& /*rep*/) {};
192
195 virtual void removeRepresentation(const Representation& /*rep*/) {};
196
199 virtual const Stage& getStage() const
200 { return *stage_;}
201
204 virtual void setStage(const Stage& stage)
205 { stage_ = &stage;}
206
208 bool hasStage() const;
209
211 virtual void setSize(float width, float height) {width_ = width; height_ = height;}
212
214 virtual float getWidth() const { return width_;}
215
217 virtual float getHeight() const { return height_;}
218
223 virtual void setPreviewMode(bool show_preview) { show_preview_ = show_preview; }
224
229 virtual void showLightSources(bool show_light_sources) { show_light_sources_ = show_light_sources; }
230
238 virtual void renderRuler();
239
241 virtual void setStereoMode(StereoMode state);
242
244 virtual StereoMode getStereoMode() const;
245
247 virtual void setStereoFrustumConversion(int width_factor, int height_factor);
248
250
253
255 bool operator == (const Renderer& /*renderer*/) const
256 { return true; }
257
259 virtual void render_(const GeometricObject* object);
260
261 protected:
262
265 {Log.error() << "renderClippingPlane_ not implemented in derived Renderer class" << std::endl;}
266
267 // Render a text label
268 virtual void renderLabel_(const Label& /*label*/)
269 {Log.error() << "renderLabel_ not implemented in derived Renderer class" << std::endl;}
270
272 virtual void renderLine_(const Line& /*line*/)
273 {Log.error() << "renderLine_ not implemented in derived Renderer class" << std::endl;}
274
276 virtual void renderMultiLine_(const MultiLine& /*line*/)
277 {Log.error() << "renderMultiLine_ not implemented in derived Renderer class" << std::endl;}
278
280 virtual void renderMesh_(const Mesh& /*mesh*/)
281 {Log.error() << "renderMesh_ not implemented in derived Renderer class" << std::endl;}
282
284 virtual void renderPoint_(const Point& /*point*/)
285 {Log.error() << "renderPoint_ not implemented in derived Renderer class" << std::endl;}
286
288 virtual void renderBox_(const Box& /*box*/)
289 {Log.error() << "renderBox_ not implemented in derived Renderer class" << std::endl;}
290
292 virtual void renderSimpleBox_(const SimpleBox& /*box*/)
293 {Log.error() << "renderSimpleBox_ not implemented in derived Renderer class" << std::endl;}
294
296 virtual void renderSphere_(const Sphere& /*sphere*/)
297 {Log.error() << "renderSphere_ not implemented in derived Renderer class" << std::endl;}
298
300 virtual void renderDisc_(const Disc& /*disc*/)
301 {Log.error() << "renderDisc_ not implemented in derived Renderer class" << std::endl;}
302
304 virtual void renderTube_(const Tube& /*tube*/)
305 {Log.error() << "renderTube_ not implemented in derived Renderer class" << std::endl;}
306
308 virtual void renderTwoColoredLine_(const TwoColoredLine& /*two_colored_line*/)
309 {Log.error() << "renderTwoColoredLine_ not implemented in derived Renderer class" << std::endl;}
310
312 virtual void renderTwoColoredTube_(const TwoColoredTube& /*two_colored_tube*/)
313 {Log.error() << "renderTwoColoredTube_ not implemented in derived Renderer class" << std::endl;}
314
317 {Log.error() << "renderGridVisualisation_ not implemented in derived Renderer class" << std::endl;}
319 virtual void renderQuadMesh_(const QuadMesh&)
320 {Log.error() << "renderQuadMesh_ not implemented in derived Renderer class" << std::endl;}
322
323 //_
325
326 //_
327 const Stage* stage_;
328
329 //_The width of the render area
330 float width_;
331
332 //_The height of the render area
333 float height_;
334
335 //_
337
338 //_
340
341 //_
343
344 //_
346
347 // An offset added to camera position and look at
349
351
354
356 };
357
358 } // namespace VIEW
359} // namespace BALL
360
361#endif // BALL_VIEW_RENDERING_RENDERER_H
#define BALL_CREATE(name)
Definition: create.h:62
Definition: constants.h:13
BALL_EXPORT LogStream Log
BALL_EXPORT bool operator==(const String &s1, const String &s2)
LogStream & error(int n=0)
Size stereo_frustum_conversion_height_
Definition: renderer.h:353
virtual bool renderOneRepresentation(const Representation &representation)
virtual void renderMesh_(const Mesh &)
Render a surface mesh.
Definition: renderer.h:280
virtual Vector3 mapViewportTo3D(Position x, Position y)
virtual const Stage & getStage() const
Definition: renderer.h:199
virtual bool finish()
virtual void renderTwoColoredTube_(const TwoColoredTube &)
Render a tube with two colors.
Definition: renderer.h:312
virtual Vector2 map3DToViewport(const Vector3 &vec)
virtual void setStereoFrustumConversion(int width_factor, int height_factor)
virtual void renderSphere_(const Sphere &)
Render a sphere.
Definition: renderer.h:296
virtual void renderQuadMesh_(const QuadMesh &)
Render a quad mesh.
Definition: renderer.h:319
virtual void renderLabel_(const Label &)
Definition: renderer.h:268
virtual bool init(const Stage &stage, float height, float width)
virtual void renderBox_(const Box &)
Render a box.
Definition: renderer.h:288
virtual float getWidth() const
Definition: renderer.h:214
virtual void setSize(float width, float height)
Set the size of the display.
Definition: renderer.h:211
bool hasStage() const
Test if a Stage was assigned to the Renderer.
virtual void updateMaterialForRepresentation(Representation const *)
Definition: renderer.h:121
Size stereo_frustum_conversion_width_
Definition: renderer.h:352
Vector3 camera_offset_
Definition: renderer.h:348
virtual bool hasFPScounter()
Definition: renderer.h:150
virtual void setStereoMode(StereoMode state)
virtual float getHeight() const
Definition: renderer.h:217
virtual void updateBackgroundColor()
Update the background color from the stage.
virtual StereoMode getStereoMode() const
virtual double getFPS()
Definition: renderer.h:154
virtual void render_(const GeometricObject *object)
Wrapper for the renderering of special GeometricObjects.
virtual void setupEnvironmentMap(const QImage &image)
Setup an environment map.
@ DUAL_VIEW_STEREO
Stereo mode for output on two projectors.
Definition: renderer.h:67
@ DUAL_VIEW_DIFFERENT_DISPLAY_STEREO
Stereo mode for output on two projectors with one display per head.
Definition: renderer.h:70
@ TOP_BOTTOM_STEREO
Stereo mode for top bottom views.
Definition: renderer.h:73
@ ACTIVE_STEREO
Stereo mode for shutter glasses.
Definition: renderer.h:64
virtual void setupStereo(float eye_separation, float focal_length)
virtual void getFrustum(float &near_f, float &far_f, float &left_f, float &right_f, float &top_f, float &bottom_f)
const Stage * stage_
Definition: renderer.h:327
virtual void renderDisc_(const Disc &)
Render a disc.
Definition: renderer.h:300
virtual void showLightSources(bool show_light_sources)
Definition: renderer.h:229
virtual void renderMultiLine_(const MultiLine &)
Render an illuminated line.
Definition: renderer.h:276
virtual void renderClippingPlane_(const ClippingPlane &)
Definition: renderer.h:264
virtual void removeRepresentation(const Representation &)
Definition: renderer.h:195
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2, std::list< GeometricObject * > &objects)
virtual void clear()
Definition: renderer.h:99
virtual void updateCamera(const Camera *camera=0)
virtual void useContinuousLoop(bool use_loop)
Definition: renderer.h:138
virtual void setStage(const Stage &stage)
Definition: renderer.h:204
virtual void renderTwoColoredLine_(const TwoColoredLine &)
Render a line with two colors.
Definition: renderer.h:308
virtual bool init(Scene &scene)
virtual void setPreviewMode(bool show_preview)
Definition: renderer.h:223
virtual void renderRuler()
StereoMode stereo_
Definition: renderer.h:355
virtual void setLights(bool reset_all=false)
Set the light sources according to the stage.
virtual void renderGridVisualisation_(const GridVisualisation &)
Render a grid.
Definition: renderer.h:316
virtual void renderSimpleBox_(const SimpleBox &)
Render a simple box (parallel to the axes)
Definition: renderer.h:292
virtual void renderPoint_(const Point &)
Render a single point.
Definition: renderer.h:284
virtual void bufferRepresentation(const Representation &)
Definition: renderer.h:191
virtual void renderTube_(const Tube &)
Render a tube.
Definition: renderer.h:304
virtual void renderLine_(const Line &)
Render a line.
Definition: renderer.h:272
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52