All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PinsModule.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "DiffuseMeshFactory.h"
7 #include "PinViewFactory.h"
8 #include "PinRepository.h"
9 #include "PinController.h"
10 #include "RenderableFilters.h"
11 #include "Modules.h"
12 #include "Helpers.h"
13 #include "Rendering.h"
14 #include "AtlasTexturePageLayout.h"
15 
16 namespace Eegeo
17 {
18  namespace Pins
19  {
28  class PinsModule : protected Eegeo::NonCopyable
29  {
30  public:
32  /* \param iconsTexturePageId The GL of the the texture containing the icons that will be used to display the Pins.
33  * \param iconsTexturePageLayout The layout of the icon images within the texture page.
34  * \param pPinViewFactory The factory used to create views based on the page layout - Created for you when using the Create() methods.
35  * \param glBufferPool reference to GLBufferPool component
36  * \param shaderIdGenerator reference to the shader ID generator.
37  * \param materialIdGenerator reference to the material ID generator.
38  * \param vertexBindingPool reference to the vertex binding pool.
39  * \param vertexLayoutPool reference to the vertex layout pool.
40  * \param renderFilters reference to the RenderFilters component.
41  * \param terrainHeightProvider reference to TerrainHeightProvider component
42  * \param layerId The ID of the layer that the sprites are to be rendered in.
43  * \param environmentFlatteningService reference to EnvironmentFlatteningService
44  * \param screen properties for correctly rendering pins depending on dimensions & dpi
45  * \param useLegacyScaling Legacy scaling sizes pins based on a fixed value rather than screen size & density.
46  * \return A PinModule object.
47  */
48  PinsModule(const Eegeo::Rendering::TTextureId iconsTexturePageId,
49  const Eegeo::Rendering::ITexturePageLayout& texturePageLayout,
50  Eegeo::Pins::IPinViewFactory* pPinViewFactory,
51  Rendering::GlBufferPool& glBufferPool,
52  Rendering::Shaders::ShaderIdGenerator& shaderIdGenerator,
53  Rendering::Materials::MaterialIdGenerator& materialIdGenerator,
56  Rendering::RenderableFilters& renderableFilters,
58  const Rendering::LayerIds::Values layerId,
59  const Rendering::EnvironmentFlatteningService& environmentFlatteningService,
60  const Rendering::ScreenProperties& screenProperties,
61  const bool useLegacyScaling)
62  : m_renderableFilters(renderableFilters)
63  {
64  Eegeo_ASSERT(pPinViewFactory != NULL, "Cannot instantiate PinsModule with null PinViewFactory");
65  m_pViewFactory = pPinViewFactory;
66 
67  m_pRepository = Eegeo_NEW(PinRepository)();
68 
69  m_pViewRenderer = PinViewRenderer::Create(
70  environmentFlatteningService,
71  renderableFilters,
72  shaderIdGenerator,
73  materialIdGenerator,
74  vertexLayoutPool,
75  vertexBindingPool,
76  glBufferPool,
77  texturePageLayout,
78  iconsTexturePageId,
79  layerId,
80  screenProperties,
81  useLegacyScaling);
82 
83  m_pController = Eegeo_NEW(PinController)(*m_pRepository, terrainHeightProvider, *m_pViewFactory, *m_pViewRenderer);
84  }
85 
89  {
90  m_renderableFilters.RemoveRenderableFilter(*m_pViewRenderer);
91 
92  Eegeo_DELETE m_pController;
93  Eegeo_DELETE m_pViewRenderer;
94  Eegeo_DELETE m_pRepository;
95 
96  Eegeo_DELETE m_pViewFactory;
97  }
98 
100  /* \param renderingModule reference to RenderingModule
101  * \param platformAbstractonModule reference to PlatformAbstractionModule
102  * \param mapModule reference to MapModule.
103  * \param pinIconsTextureId the pin icons texture id for the texture to be used for the pin sprites.
104  * \param texturePageLayout the ITexturePageLayout instance that will provide the pin sprite uvs.
105  * \param layerId The rendering layer to draw the pins to
106  * \param spriteWidth width of the pin view sprites.
107  * \param spriteHeigh height of the pin view sprites.
108  * \param screenProperties Screen properties defining dimensions and density of screen
109  * \param useLegacyScaling Legacy scaling sizes pins based on a fixed value rather than screen size & density.
110  * \return A PinModule object.
111  */
112  static PinsModule* Create(
113  Eegeo::Modules::Core::RenderingModule& renderingModule,
114  Eegeo::Modules::IPlatformAbstractionModule& platformAbstractonModule,
116  const Eegeo::Rendering::TTextureId pinIconsTextureId,
117  const Eegeo::Rendering::ITexturePageLayout& texturePageLayout,
118  const Eegeo::Rendering::LayerIds::Values layerId,
119  const float spriteWidth,
120  const float spriteHeight,
121  const Rendering::ScreenProperties& screenProperties,
122  const bool useLegacyScaling
123  );
124 
126  /* \param renderingModule reference to RenderingModule
127  * \param platformAbstractonModule reference to PlatformAbstractionModule
128  * \param mapModule reference to MapModule.
129  * \param pinIconsTextureId the pin icons texture id for the texture to be used for the pin sprites.
130  * \param texturePageLayout the AtlasTexturePageLayout instance that will provide the pin sprite uvs + dimensions.
131  * \param screenProperties Screen properties defining dimensions and density of screen
132  * \param layerId The rendering layer to draw the pins to
133  * \return A PinModule object.
134  */
136  Eegeo::Modules::IPlatformAbstractionModule& platformAbstractonModule,
138  const Eegeo::Rendering::TTextureId pinIconsTextureId,
139  const Eegeo::Rendering::AtlasTexturePageLayout& texturePageLayout,
140  const Eegeo::Rendering::LayerIds::Values layerId,
141  const Rendering::ScreenProperties& screenProperties);
142 
147  void Update(float dt, const Camera::RenderCamera& renderCamera)
148  {
149  m_pController->Update(dt, renderCamera);
150  }
151 
156  {
157  m_pViewRenderer->UpdateScreenProperties(screenProperties);
158  }
159 
163  PinRepository& GetRepository() const { return *m_pRepository; }
164 
168  PinController& GetController() const { return *m_pController; }
169 
170  private:
171  Rendering::RenderableFilters& m_renderableFilters;
172  IPinViewFactory* m_pViewFactory;
173  PinRepository* m_pRepository;
174  PinViewRenderer* m_pViewRenderer;
175  PinController* m_pController;
176  };
177  }
178 }