voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
renderer.hpp
1 #ifndef BLUB_PROCEDURAL_VOXEL_TERRAIN_RENDERER_HPP
2 #define BLUB_PROCEDURAL_VOXEL_TERRAIN_RENDERER_HPP
3 
4 #include "blub/core/vector.hpp"
5 #include "blub/procedural/voxel/terrain/base.hpp"
6 
7 #include <boost/function/function_fwd.hpp>
8 
9 
10 namespace blub
11 {
12 namespace procedural
13 {
14 namespace voxel
15 {
16 namespace terrain
17 {
18 
19 
23 template <class configType>
24 class renderer : public base<typename configType::t_renderer::t_simple>
25 {
26 public:
27  typedef configType t_config;
28  typedef typename t_config::t_renderer::t_simple t_simple;
29  typedef base<t_simple> t_base;
30  typedef sharedPointer<sync::identifier> t_cameraPtr;
31 
32  typedef vector<real> t_syncRadiusList;
33 
34  typedef typename t_config::t_surface::t_terrain t_rendererSurface;
35 
36 
44  t_rendererSurface &renderer_,
45  const t_syncRadiusList& syncRadien)
46  : m_worker(worker)
47  , m_terrain(renderer_)
48  , m_syncRadien(syncRadien)
49  {
50  BASSERT(m_terrain.getNumLod() <= (int32)m_syncRadien.size());
51 
52  for (uint32 indLod = 0; indLod < (uint32)m_terrain.getNumLod(); ++indLod)
53  {
54  if (indLod == 0)
55  {
56  t_base::m_lods.emplace_back(new t_simple(m_worker, m_terrain.getLod(indLod), indLod, 0., syncRadien[0]));
57  }
58  else
59  {
60  t_base::m_lods.emplace_back(new t_simple(m_worker, m_terrain.getLod(indLod), indLod, syncRadien[indLod-1], syncRadien[indLod]));
61  }
62  }
63  }
64 
69  {
70  }
71 
77  void addCamera(t_cameraPtr toAdd, const blub::vector3& position)
78  {
79  for (uint32 indLod = 0; indLod < t_base::m_lods.size(); ++indLod)
80  {
81  t_base::m_lods[indLod]->addCamera(toAdd, position);
82  }
83  }
89  void updateCamera(t_cameraPtr toUpdate, const blub::vector3& position)
90  {
91  for (uint32 indLod = 0; indLod < t_base::m_lods.size(); ++indLod)
92  {
93  t_base::m_lods[indLod]->updateCamera(toUpdate, position);
94  }
95  }
100  void removeCamera(t_cameraPtr toRemove)
101  {
102  for (uint32 indLod = 0; indLod < t_base::m_lods.size(); ++indLod)
103  {
104  t_base::m_lods[indLod]->removeCamera(toRemove);
105  }
106  }
107 
108 protected:
109 
110 
111 private:
112  blub::async::dispatcher &m_worker;
113  t_rendererSurface &m_terrain;
114 
115  t_syncRadiusList m_syncRadien;
116 
117 };
118 
119 
120 
121 }
122 }
123 }
124 }
125 
126 #endif // BLUB_PROCEDURAL_VOXEL_TERRAIN_RENDERER_HPP
void updateCamera(t_cameraPtr toUpdate, const blub::vector3 &position)
updateCamera updates the position of a camera you have to add before by using addCamera() ...
Definition: renderer.hpp:89
void removeCamera(t_cameraPtr toRemove)
removeCamera removes a camera.
Definition: renderer.hpp:100
Definition: customVertexInformation.cpp:193
renderer(blub::async::dispatcher &worker, t_rendererSurface &renderer_, const t_syncRadiusList &syncRadien)
renderer constructor
Definition: renderer.hpp:43
t_lodList m_lods
m_lods container for the lods.
Definition: base.hpp:78
void addCamera(t_cameraPtr toAdd, const blub::vector3 &position)
addCamera adds an camera.
Definition: renderer.hpp:77
Definition: dispatcher.hpp:29
~renderer()
~renderer destructor
Definition: renderer.hpp:68
Definition: vector3.hpp:26
Definition: deadlineTimer.hpp:10