All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ChunkedRoadBuilder.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Roads.h"
6 #include "Rendering.h"
7 #include "Navigation.h"
8 #include "Types.h"
9 #include "IResourceBuilder.h"
10 #include "Fonts.h"
11 #include "TextMeshes.h"
12 #include "ChunkedFileFormat.h"
13 #include "RoadNamesChunkReader.h"
14 #include "Space.h"
15 #include "VectorMathDecl.h"
16 #include "ParsedNavGraph.h"
17 #include "CollisionBvhFactory.h"
18 #include "TextRenderableConfiguration.h"
19 #include "Labels.h"
20 #include "ISceneElementInGraphObserver.h"
21 #include "Config.h"
22 #include "TransportLayerType.h"
23 
24 #include <vector>
25 
26 namespace Eegeo
27 {
28  namespace Resources
29  {
30  namespace Roads
31  {
33  {
35  : renderRoad(false)
36  , roadNavGraph(NULL)
37  , railNavGraph(NULL)
38  , tramNavGraph(NULL)
39  , pRoadsCollisionBvh(NULL)
40  , pRailCollisionBvh(NULL)
41  , pTramlinesCollisionBvh(NULL)
42  {
43  };
44 
45  bool renderRoad;
46  std::vector<Rendering::Renderables::PackedRenderable*> newGeometryRenderables;
47  std::vector<std::string> newGeometryRenderablesNames;
48  std::vector<Rendering::Renderables::PackedShadowRenderable*> newShadowRenderables;
49  std::vector<Rendering::Renderables::TextRenderable*> roadNameRenderables;
50  std::vector<const Labels::LabelCellModel*> labelCellModels;
51 
52  Navigation::NavigationGraph* roadNavGraph;
53  Navigation::NavigationGraph* railNavGraph;
54  Navigation::NavigationGraph* tramNavGraph;
55  Eegeo::Collision::CollisionBvh* pRoadsCollisionBvh;
56  Eegeo::Collision::CollisionBvh* pRailCollisionBvh;
57  Eegeo::Collision::CollisionBvh* pTramlinesCollisionBvh;
58 
59 
61 
62  void RelinquishOwnership();
63  };
64 
66  {
68  : pCollisionBvh(NULL)
69  {}
70 
71  std::vector<Rendering::Renderables::PackedRenderable*> geometryRenderables;
72  std::vector<std::string> geometryRenderableNames;
73 
74  std::vector<Rendering::Renderables::PackedShadowRenderable*> shadowRenderables;
75  Collision::CollisionBvh* pCollisionBvh;
76  };
77 
78 
80  {
82  Rendering::IMaterialProvider& m_materialProvider;
85 
86  Navigation::NavigationGraphBuilder& m_roadNavGraphBuilder;
87  Navigation::NavigationGraphBuilder& m_railNavGraphBuilder;
88  Navigation::NavigationGraphBuilder& m_tramNavGraphBuilder;
89 
90  const Fonts::FontInstance& m_roadNameFont;
92  RoadNameGeometryBuilder& m_roadNameGeometryBuilder;
93 
94  const int m_maxCharsPerRoadName;
96 
97  NavGraphData m_navGraphDtoScratch;
98 
99  Eegeo::Collision::CollisionBvhFactory m_roadsCollisionBvhFactory;
100  Eegeo::Collision::CollisionBvhFactory m_railCollisionBvhFactory;
101  Eegeo::Collision::CollisionBvhFactory m_tramlinesCollisionBvhFactory;
102 
103  Eegeo::Collision::CollisionMeshResourceRepository& m_roadsCollisionMeshRepository;
104  Eegeo::Collision::CollisionMeshResourceRepository& m_railCollisionMeshRepository;
105  Eegeo::Collision::CollisionMeshResourceRepository& m_tramlinesCollisionMeshRepository;
106 
107  IRoadNameClassificationPatcher& m_roadNameFunctionalRoadClassPatcher;
108  IRoadLabelBuilder& m_roadLabelBuilder;
109  Labels::ILabelCellResourceObserver& m_labelCellResourceObserver;
110 
111  const int m_maxRoadNamesLevel;
112  const bool m_bGenerateCollision;
113  const bool m_buildLabels;
114 
115  const Config::ResourceBuilderConfigSection& m_resourceBuilderConfig;
116 
117  public:
120  Rendering::IMeshUploadService* pMeshUploadService,
122  Rendering::IMaterialProvider& materialProvider,
125  Navigation::NavigationGraphBuilder& roadNavGraphBuilder,
126  Navigation::NavigationGraphBuilder& railNavGraphBuilder,
127  Navigation::NavigationGraphBuilder& tramNavGraphBuilder,
128  Eegeo::Collision::CollisionMeshResourceRepository& roadsCollisionMeshRepository,
129  Eegeo::Collision::CollisionMeshResourceRepository& railCollisionMeshRepository,
130  Eegeo::Collision::CollisionMeshResourceRepository& tramlinesCollisionMeshRepository,
131  bool generateCollision,
132  bool buildLabels,
133  RoadNameGeometryBuilder& roadNameGeometryBuilder,
134  const Fonts::FontInstance& roadNameFont,
135  const int maxCharsPerRoadName,
137  IRoadNameClassificationPatcher& roadNameFunctionalRoadClassPatcher,
138  IRoadLabelBuilder& roadLabelBuilder,
139  Labels::ILabelCellResourceObserver& labelCellResourceObserver,
140  const Config::ResourceBuilderConfigSection& resourceBuilder,
143  );
144  virtual ~ChunkedRoadBuilder();
145 
146  virtual bool Flush(const Streaming::MortonKey& key, void* input, TBuiltResources& result);
147  virtual void DestroyBuiltResource(const Streaming::MortonKey& key, void* input);
148  virtual void* BuildResource(const Streaming::MortonKey& key, const Byte* data, size_t length);
149  virtual bool AcceptsErroredRequests()
150  {
151  return true;
152  }
153 
154  private:
156  Rendering::IMeshUploadService* m_pMeshUploadService;
158 
159  bool ShouldBuildRoadNamesFor(const Eegeo::Space::CubeMap::CubeMapCellInfo& cellInfo) const;
160 
161  void BuildRoadNames(const Eegeo::Space::CubeMap::CubeMapCellInfo& cellInfo, const NavGraphData& navGraphDto, IO::ChunkedFileFormat::ChunkStream& chunkStream, RoadBuilderOutput& builderOutput);
162 
163 
164  QCMSChunkBuiltResources BuildResourcesFromQuantizedMeshSet(
166  BinaryParsing::membuf& streamBuf,
167  const Space::CubeMap::CubeMapCellInfo& cellInfo,
168  const Eegeo::dv3& ecefOrigin,
169  Collision::ICollisionBvhFactory& collisionBvhFactory);
170 
172  };
173  }
174  }
175 }