All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
QuantizedMeshSetChunkReader.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMath.h"
7 #include "AllVertexTypes.h"
8 #include "LayerIds.h"
9 #include "CullingVolume.h"
10 #include "CubeMap.h"
11 #include "ChunkedFileFormat.h"
12 #include "BinaryParsing.h"
13 #include "Rendering.h"
14 #include "Collision.h"
15 #include "IQuantizedMeshSetChunkReaderMeshFactory.h"
16 #include "CollisionGroup.h"
17 #include "QuantizedMeshInfo.h"
18 #include "Culling.h"
19 
20 #include <string>
21 #include <vector>
22 
23 namespace Eegeo
24 {
25  namespace IO
26  {
27  namespace ChunkedFileFormat
28  {
29  namespace QuantizedMeshSetChunkReader
30  {
32  {
33  QuantizedMeshInfo meshInfo;
34  Eegeo::Rendering::Mesh* pNewMesh;
35  Culling::CullingVolumeTree* pCullingVolumeTree;
36  std::string debugName;
37 
39  : pNewMesh(NULL)
40  , pCullingVolumeTree(NULL)
41  {}
42  };
43 
44 
45 
47  {
48  v3 quantizationOrigin;
49  float quantizationScale;
50  float minAltitude;
51  float maxAltitude;
52  bool collisionNeedsLegacyFixup;
53  std::vector<Eegeo::Collision::CollisionBvhNode>* collisionNodes;
54  std::vector<u16>* collisionTriListIndices;
55  std::vector<Eegeo::Rendering::VertexTypes::ShortPositionVertex>* collisionPoints;
56  std::vector<Eegeo::Collision::CollisionMaterialIndexLookupPair>* materialIndexLookupPairs;
57 
59  : quantizationOrigin(v3::Zero())
60  , quantizationScale(0.f)
61  , minAltitude(0.f)
62  , maxAltitude(0.f)
63  , collisionNeedsLegacyFixup(false)
64  , collisionNodes(NULL)
65  , collisionTriListIndices(NULL)
66  , collisionPoints(NULL)
67  , materialIndexLookupPairs(NULL)
68  {}
69 
70  };
71 
72  struct ReaderResult
73  {
74  std::vector<ReaderMeshResult> meshResults;
75  std::vector<ReaderCollisionResult> collisionResults;
76  };
77 
78 
79  typedef void (PreGeometryReadCallback)(const Space::CubeMap::CubeMapCellInfo& cellInfo, QuantizedMeshSetChunkReader::QuantizedMeshInfo& meshInfo);
80  typedef void (PreMeshCreateCallback)(const Space::CubeMap::CubeMapCellInfo& cellInfo, const QuantizedMeshSetChunkReader::QuantizedMeshInfo& meshInfo, void* pVertexBuffer);
81 
82  void ReadMeshInfo(Eegeo::IO::ChunkedFileFormat::ChunkStream& chunkStream,
84  std::vector<QuantizedMeshInfo>& results);
85 
86 
88  {
89  public:
90 
92  : m_context(context)
93  {
94 
95  }
96 
97  void Read(
100  const Space::CubeMap::CubeMapCellInfo& cellInfo,
101  void* userData,
102  PreGeometryReadCallback* preGeometryReadCallback,
103  PreMeshCreateCallback* preMeshCreateCallback,
104  const std::string& debugNamePrefix,
106  Rendering::IMeshUploadService* pMeshUploadService,
107  bool generateCollision,
108  ReaderResult& result);
109 
110  private:
111 
112  QCMSReaderContext& m_context;
113  };
114 
115 
116 
117  Rendering::Renderables::PackedRenderable* CreatePackedRenderable(
118  const Rendering::LayerIds::Values layerId,
119  const Eegeo::dv3& ecefOrigin,
120  const QuantizedMeshSetChunkReader::ReaderMeshResult& readerMeshResult,
123  bool renderableItemOwnsMaterial);
124 
125  Rendering::Renderables::PackedShadowRenderable* CreatePackedShadowRenderable(
126  const Eegeo::dv3& ecefOrigin,
127  const QuantizedMeshSetChunkReader::ReaderMeshResult& readerMeshResult,
130  bool renderableItemOwnsMaterial);
131 
132  Rendering::Renderables::LightmappedRenderable* CreateLightmappedRenderable(
133  const Rendering::LayerIds::Values layerId,
134  const Eegeo::dv3& ecefOrigin,
135  const QuantizedMeshSetChunkReader::ReaderMeshResult& readerMeshResult,
138  bool renderableItemOwnsMaterial);
139 
140  Rendering::Renderables::WaterRenderable* CreateWaterRenderable(
141  const Rendering::LayerIds::Values layerId,
142  const Eegeo::dv3& ecefOrigin,
143  const QuantizedMeshSetChunkReader::ReaderMeshResult& readerMeshResult,
146  bool renderableItemOwnsMaterial);
147 
148 
149  }
150  }
151  }
152 }