BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
renderer.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: renderer.h,v 1.11.16.1 2007/03/25 21:26:16 oliver Exp $
5 
6 #ifndef BALL_VIEW_RENDERING_RENDERER_H
7 #define BALL_VIEW_RENDERING_RENDERER_H
8 
9 #ifndef BALL_VIEW_KERNEL_REPRESENTATION_H
11 #endif
12 
13 #ifndef BALL_CONCEPT_OBJECT_H
14 # include <BALL/CONCEPT/object.h>
15 #endif
16 
17 #ifndef BALL_VIEW_KERNEL_STAGE_H
18 # include <BALL/VIEW/KERNEL/stage.h>
19 #endif
20 
21 #ifndef BALL_MATHS_VECTOR2_H
22 # include <BALL/MATHS/vector2.h>
23 #endif
24 
25 namespace BALL
26 {
27  namespace VIEW
28  {
29  class Scene;
30  class Line;
31  class MultiLine;
32  class Tube;
33  class Mesh;
34  class Label;
35  class Point;
36  class Sphere;
37  class Disc;
38  class Box;
39  class SimpleBox;
40  class TwoColoredLine;
41  class TwoColoredTube;
42  class ClippingPlane;
43  class GridVisualisation;
44  class QuadMesh;
45 
54  : public Object
55  {
56  public:
57 
59 
60 
63 
66  Renderer();
67 
70  Renderer(const Renderer& renderer);
71 
74  virtual ~Renderer() {}
75 
78  virtual void clear(){}
79 
83  virtual bool init(Scene& scene);
84 
88  virtual bool init(const Stage& stage, float height, float width);
89 
91  virtual void setLights(bool reset_all = false);
92 
95  virtual void updateCamera(const Camera* camera = 0);
96 
98  virtual void updateBackgroundColor();
99 
105  virtual void setupStereo(float eye_separation, float focal_length);
106 
109  virtual void useContinuousLoop(bool use_loop)
110  {
111  // TODO: mutex for use_continuous_loop_ just to be on the safe side
112  use_continuous_loop_ = use_loop;
113  };
114 
117  bool isContinuous() { return use_continuous_loop_; }
118 
120  virtual bool finish();
121 
125  virtual Vector3 mapViewportTo3D(Position x, Position y);
126 
130  virtual Vector2 map3DToViewport(const Vector3& vec);
131 
133 
136 
139  virtual bool renderOneRepresentation(const Representation& representation);
140 
141 
144  virtual void bufferRepresentation(const Representation& /*rep*/) {};
145 
148  virtual void removeRepresentation(const Representation& /*rep*/) {};
149 
152  virtual const Stage& getStage() const
153  { return *stage_;}
154 
157  virtual void setStage(const Stage& stage)
158  { stage_ = &stage;}
159 
161  bool hasStage() const;
162 
164  virtual void setSize(float width, float height) { width_ = width; height_ = height;}
165 
167  virtual float getWidth() const { return width_;}
168 
170  virtual float getHeight() const { return height_;}
171 
176  virtual void setPreviewMode(bool show_preview) { show_preview_ = show_preview; }
177 
182  virtual void showLightSources(bool show_light_sources) { show_light_sources_ = show_light_sources; }
183 
191  virtual void renderRuler();
192 
194 
197 
199  bool operator == (const Renderer& /*renderer*/) const
200  { return true; }
201 
203  virtual void render_(const GeometricObject* object);
204 
205  protected:
206 
208  virtual void renderClippingPlane_(const ClippingPlane&)
209  {Log.error() << "renderClippingPlane_ not implemented in derived Renderer class" << std::endl;}
210 
211  // Render a text label
212  virtual void renderLabel_(const Label& /*label*/)
213  {Log.error() << "renderLabel_ not implemented in derived Renderer class" << std::endl;}
214 
216  virtual void renderLine_(const Line& /*line*/)
217  {Log.error() << "renderLine_ not implemented in derived Renderer class" << std::endl;}
218 
220  virtual void renderMultiLine_(const MultiLine& /*line*/)
221  {Log.error() << "renderMultiLine_ not implemented in derived Renderer class" << std::endl;}
222 
224  virtual void renderMesh_(const Mesh& /*mesh*/)
225  {Log.error() << "renderMesh_ not implemented in derived Renderer class" << std::endl;}
226 
228  virtual void renderPoint_(const Point& /*point*/)
229  {Log.error() << "renderPoint_ not implemented in derived Renderer class" << std::endl;}
230 
232  virtual void renderBox_(const Box& /*box*/)
233  {Log.error() << "renderBox_ not implemented in derived Renderer class" << std::endl;}
234 
236  virtual void renderSimpleBox_(const SimpleBox& /*box*/)
237  {Log.error() << "renderSimpleBox_ not implemented in derived Renderer class" << std::endl;}
238 
240  virtual void renderSphere_(const Sphere& /*sphere*/)
241  {Log.error() << "renderSphere_ not implemented in derived Renderer class" << std::endl;}
242 
244  virtual void renderDisc_(const Disc& /*disc*/)
245  {Log.error() << "renderDisc_ not implemented in derived Renderer class" << std::endl;}
246 
248  virtual void renderTube_(const Tube& /*tube*/)
249  {Log.error() << "renderTube_ not implemented in derived Renderer class" << std::endl;}
250 
252  virtual void renderTwoColoredLine_(const TwoColoredLine& /*two_colored_line*/)
253  {Log.error() << "renderTwoColoredLine_ not implemented in derived Renderer class" << std::endl;}
254 
256  virtual void renderTwoColoredTube_(const TwoColoredTube& /*two_colored_tube*/)
257  {Log.error() << "renderTwoColoredTube_ not implemented in derived Renderer class" << std::endl;}
258 
260  virtual void renderGridVisualisation_(const GridVisualisation&)
261  {Log.error() << "renderGridVisualisation_ not implemented in derived Renderer class" << std::endl;}
263  virtual void renderQuadMesh_(const QuadMesh&)
264  {Log.error() << "renderQuadMesh_ not implemented in derived Renderer class" << std::endl;}
266 
267  //_
269 
270  //_
271  const Stage* stage_;
272 
273  //_
274  float width_;
275 
276  //_
277  float height_;
278 
279  //_
281 
282  //_
284 
285  //_
287 
288  //_
290 
291  // An offset added to camera position and look at
293 
295  };
296 
297  } // namespace VIEW
298 } // namespace BALL
299 
300 #endif // BALL_VIEW_RENDERING_RENDERER_H