BALL  1.4.79
rtfactRenderer.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_RTFACTRENDERER_H
6 #define BALL_VIEW_RENDERING_RENDERERS_RTFACTRENDERER_H
7 
8 #define BALLVIEW_RTFACTRENDERER_THROW(exceptionName, message) (throw BALL::Exception::##exceptionName##(__FILE__, __LINE__, message))
10 
12 #include <BALL/VIEW/KERNEL/stage.h>
16 #include <BALL/MATHS/surface.h>
17 #include <BALL/MATHS/vector3.h>
18 #include <BALL/DATATYPE/hashMap.h>
19 
20 //RTRemote proxy to RTfact
21 #include <RTremote/Renderer.hpp>
22 #include <RTremote/Picking.hpp>
23 
24 namespace BALL
25 {
26  namespace VIEW
27  {
33  : public RaytracingRenderer
34  {
35  public:
36 
39  class RTfactData
40  {
41  public:
43  std::vector<RTfact::Remote::GroupHandle> top_group_handles;
44 
46  std::vector<RTfact::Remote::GeoHandle> object_handles;
47 
49  std::vector<RTfact::Remote::RTAppearanceHandle> material_handles;
50 
53  };
54 
58  rtfact_needs_update_(false)
59  {
60  }
61 
63  virtual ~RTfactRenderer()
64  {
65  }
66 
67  /************************************************************************/
68  /* RaytracingRenderer methods */
69  /************************************************************************/
70  virtual bool init(Scene& scene);
71 
72  virtual String getRenderer()
73  {
74  return "RTfact-RTRemote Ray Tracer";
75  }
76 
77  virtual void formatUpdated()
78  {
79  }
80 
81  virtual GeometricObject* pickObject(Position x, Position y);
82  virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
83  std::list<GeometricObject*>& objects);
84 
85  virtual void setSize(float width, float height);
86 
87  virtual void setupStereo(float eye_separation, float focal_length);
88 
89  virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f, float& top_f, float& bottom_f);
90  virtual void setFrustum(float near_f, float far_f, float left_f, float right_f, float top_f, float bottom_f);
91 
92  virtual void prepareBufferedRendering(const Stage& stage);
93  virtual void renderToBufferImpl(FrameBufferPtr buffer);
94 
95  virtual void useContinuousLoop(bool use_loop);
96 
97  void bufferRepresentation(const Representation& rep);
98  void removeRepresentation(const Representation& rep);
99 
100  void setLights(bool reset_all = false);
101 
102  void updateCamera(const Camera* camera = 0);
103 
104  void updateBackgroundColor();
105 
106  void setupEnvironmentMap(const QImage& image);
107 
108  void updateMaterialForRepresentation(Representation const* rep);
109 
110  RTfact::Remote::GroupHandle transformTube(const TwoColoredTube& tube);
111  RTfact::Remote::GroupHandle transformLine(const TwoColoredLine& line);
112  void updateMaterialFromStage(RTfact::Remote::RTAppearanceHandle& material);
113  void convertMaterial(Stage::RaytracingMaterial const& rt_material, RTfact::Remote::RTAppearanceHandle& material);
114 
125  virtual std::vector<float> intersectRaysWithGeometry(const std::vector<Vector3>& origins,
126  const std::vector<Vector3>& directions);
127 
129 
130  private:
131 
132  std::vector<RTfact::Remote::RTLightHandle> lights_;
133 
134  RTfact::Remote::Renderer m_renderer;
135 
136  boost::shared_ptr<RTfact::Remote::Picking> m_picking;
137 
140 
141  Surface sphere_template_;
142  Surface tube_template_;
143 
144  template<typename taPixelType>
145  void renderImpl(taPixelType* buffer, const unsigned int width, const unsigned int height, const unsigned int pitch);
146 
147  void renderImpl(float* buffer, const unsigned int width, const unsigned int height, const unsigned int pitch)
148  {
149  }
150 
151  bool rtfact_needs_update_;
152 
153  Vector3 last_camera_position;
154  Vector3 last_camera_view_vec;
155  Vector3 last_camera_lookup;
156 
157  float x_scale_;
158  float y_scale_;
159  };
160 
161 
162  } // namespace VIEW
163 } // namespace BALL
164 
165 #endif // BALL_VIEW_RENDERING_RTFACTRENDERER_H
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: renderTarget.h:222
virtual ~RTfactRenderer()
Destructor.
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
RTfactRenderer()
Default Constructor.
std::vector< RTfact::Remote::GroupHandle > top_group_handles
The top-level group handles this object was assigned to.
bool has_been_disabled
Mark previously disabled representations.
std::vector< RTfact::Remote::RTAppearanceHandle > material_handles
The materials.
-*- Mode: C++; tab-width: 2; -*-
Definition: constants.h:12
virtual String getRenderer()
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:73
virtual void formatUpdated()
std::vector< RTfact::Remote::GeoHandle > object_handles
The object handles.