All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InteriorsModel.h
1 // Copyright eeGeo Ltd (2012-2015), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Interiors.h"
6 #include "InteriorsMaterials.h"
7 #include "IdTypes.h"
8 #include "Space.h"
9 #include "VectorMath.h"
10 #include "Rendering.h"
11 #include "EcefTangentBasis.h"
12 #include <string>
13 #include <vector>
14 #include "Bounds.h"
15 #include "InteriorsEntityMetadata.h"
16 #include "MortonKey.h"
17 #include "ICallback.h"
18 #include "CallbackCollection.h"
19 #include "InteriorRenderableCreationData.h"
20 #include "Types.h"
21 
22 namespace Eegeo
23 {
24  namespace Resources
25  {
26  namespace Interiors
27  {
28  typedef std::vector<InteriorsFloorModel*> TFloorModelVector;
29 
31  {
32  public:
33  InteriorsModel(const std::string& interiorIdString,
34  const std::string& displayName,
35  const std::string& associatedLandmarkMaterialName,
36  const std::string& sourceVendor,
37  const Space::EcefTangentBasis& tangentSpace,
38  const Geometry::Bounds3D& localEcefBounds,
39  const Geometry::Bounds3D& tangentSpaceBounds,
40  const Entities::TCategoryToEntitiesMetadata& entitiesMetadata,
41  const std::vector<InteriorsFloorModel*>& floorModels,
42  const std::vector<InteriorsFloorCells*>& interiorsFloorCells,
43  const int defaultFloorIndex,
44  const std::vector<Eegeo::Streaming::MortonKey>& intersectingCellKeys,
45  Materials::IInteriorRenderablesRepository& interiorRenderablesRepository);
46 
47  ~InteriorsModel();
48 
49  const InteriorId GetId() const;
50 
51  const std::string& GetName() const;
52  const std::string& GetDisplayName() const;
53  const std::string& GetAssociatedLandmarkMaterialName() const;
54  const std::string& GetSourceVendor() const;
55 
56  int GetMiddleFloorIndex() const;
57 
58  const TFloorModelVector& GetFloors() const;
59  const InteriorsFloorModel& GetFloorAtIndex(int floorIndex) const;
60  int GetFloorCount() const { return static_cast<int>(m_floorModels.size()); }
61 
62  const InteriorsFloorModel* GetBottomFloor() const;
63  const int GetDefaultFloorIndex() const;
64  int FindFloorIndexWithFloorNumber(int floorNumber) const;
65 
66  const Eegeo::Space::EcefTangentBasis& GetTangentBasis() const { return m_tangentBasis; }
67 
68  const Geometry::Bounds3D& GetLocalEcefBounds() const { return m_localEcefBounds; }
69  const Geometry::Bounds3D& GetTangentSpaceBounds() const { return m_tangentSpaceBounds; }
70  const std::vector<Eegeo::Streaming::MortonKey>& GetIntersectingCellKeys() const { return m_intersectingCellKeys; }
71 
72  float GetBaseAltitude() const;
73  float GetFloorAltitude(int floorIndex) const;
74 
75  const Entities::InteriorsEntityMetadata* GetMetadataForEntity(const std::string& entityId) const;
76  const Entities::InteriorsEntityMetadata* GetMetadataForEntityFromCategory(const std::string& category, const std::string& entityId) const;
77 
78  // Cell/View methods
79  const InteriorsFloorCells* GetFloorCells(int floorNumber) const;
80  InteriorsFloorCells* GetFloorCellsMutable(int floorNumber) const;
81  std::vector<const InteriorsFloorCell*> GetAllFloorCells() const;
82  std::vector<Eegeo::Streaming::MortonKey> GetCurrentlyLoadedFloorCellKeys() const;
83 
84  void IncrementCellInMemoryReferenceCount();
85  void DecrementCellInMemoryReferenceCount();
86  void IncrementCellVisibleReferenceCount();
87  void DecrementCellVisibleReferenceCount();
88  void SetShouldPreventEviction(bool preventEviction);
89 
90  const bool AnyCellsInMemory() const { return m_cellsInMemoryRefCount > 0; }
91  const bool AnyCellsVisible() const { return m_cellsVisibilityRefCount > 0; }
92  const bool ShouldPreventEviction() const { return m_preventEviction; }
93 
94  void RegisterCellsInMemoryChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
95  void UnregisterCellsInMemoryChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
96  void RegisterCellsVisibilityChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
97  void UnregisterCellsVisibilityChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
98  void RegisterPreventEvictionChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
99  void UnregisterPreventEvictionChangedCallback(Helpers::ICallback1<const InteriorsModel&>& callback);
100 
101 
102  private:
103  void RefreshFloorTransforms();
104 
105  std::string m_interiorIdString;
106  std::string m_displayName;
107  std::string m_associatedLandmarkMaterialName;
108  std::string m_sourceVendor;
109 
110  Eegeo::Space::EcefTangentBasis m_tangentBasis;
111 
112  Entities::TCategoryToEntitiesMetadata* m_pEntitiesMetadata;
113 
114  Geometry::Bounds3D m_localEcefBounds;
115  Geometry::Bounds3D m_tangentSpaceBounds;
116 
117  TFloorModelVector m_floorModels;
118  int m_defaultFloorIndex;
119  std::vector<Eegeo::Streaming::MortonKey> m_intersectingCellKeys;
120 
121  // Cell/View methods
122  std::vector<InteriorsFloorCells*> m_floorCellsPerFloor;
123  int m_cellsInMemoryRefCount;
124  int m_cellsVisibilityRefCount;
125  bool m_preventEviction;
126 
127  Materials::IInteriorRenderablesRepository& m_interiorRenderablesRepository;
128 
129  Helpers::CallbackCollection1<const InteriorsModel&> m_cellsInMemoryChangedCallbacks;
130  Helpers::CallbackCollection1<const InteriorsModel&> m_cellsVisibilityChangedCallbacks;
131  Helpers::CallbackCollection1<const InteriorsModel&> m_preventEvictionChangedCallbacks;
132  };
133  }
134  }
135 }