All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InteriorViewModel.h
1 // Copyright eeGeo Ltd (2012-2016), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IImmutableInteriorViewModel.h"
7 #include "Interiors.h"
8 #include "CallbackCollection.h"
9 #include "ICallback.h"
10 #include "VectorMath.h"
11 #include "Rendering.h"
12 #include "ICallback.h"
13 #include "CallbackCollection.h"
14 
15 #include <vector>
16 
17 #include "PropModel.h"
18 
19 
20 namespace Eegeo
21 {
22  namespace Resources
23  {
24  namespace Interiors
25  {
26  struct InteriorFloorAnimationState;
27 
29  {
30  public:
32 
33  virtual ~IInteriorViewModelObserver() {;}
34 
35  virtual void RegisterChangedCallback(CallbackType& callback) = 0;
36 
37  virtual void UnregisterChangedCallback(CallbackType& callback) = 0;
38  };
39 
41  {
42  public:
43 
44  InteriorViewModel(const IInteriorFloorAnimator& interiorFloorAnimator,
45  PropRenderableRepository& propRenderableRepository,
46  const Rendering::EnvironmentFlatteningService& environmentFlatteningService);
47 
48  void SetInterior(const InteriorsModel* pCurrentInteriorModel);
49 
50  void SetSelectedFloorIndex(int selectedFloorIndex);
51 
52  int GetSelectedFloorIndex() const;
53 
54  void SetAlpha(float alpha);
55 
56  void Update(float dt);
57 
58  void SetNeedsRefresh();
59 
60  bool IsVisible() const;
61 
62  float GetLookAtHeightAboveBase() const;
63 
64  float GetBaseAltitude() const;
65 
66  v3 GetFloorCenteredTangentSpaceLookAt() const;
67 
68  m44 GetFloorTransformWithTerrainFlattenedToScale(int floorIndex, float flatteningScale) const;
69 
70  m44 GetFloorTransform(int floorIndex) const;
71 
72  dv3 GetFloorTransformOrigin(int floorIndex) const;
73 
74  bool IsInteriorSelected() const;
75 
76  InteriorId GetSelectedInteriorId() const;
77 
78  bool IsValidFloorIndex(int floorIndex) const;
79 
80  Space::EcefTangentBasis GetTangentBasis() const;
81 
82  Geometry::Bounds3D GetTangentSpaceBounds() const;
83 
84  Geometry::Bounds3D GetFloorTangentSpaceBounds() const;
85 
86  std::vector<const InteriorsFloorCell*> GetFloorCellsForRendering() const;
87 
88  std::vector<Rendering::Renderables::InstancedInteriorFloorRenderable*> GetPropInstancesForRendering() const;
89 
90  void RegisterChangedCallback(Helpers::ICallback0& callback);
91 
92  void UnregisterChangedCallback(Helpers::ICallback0& callback);
93 
94  private:
95 
96  m44 GetFloorTransformWithScale(int floorIndex, float environmentScale) const;
97 
98  void NotifyChanged() const;
99 
100  void ClearCurrentInterior();
101 
102  void Refresh();
103 
104  void RefreshRenderablesForFloor(int floorIndex, const float flatteningScale, const float interiorTerrainHeight, const m44& normalTransform);
105 
106  void RefreshFloorCell(const InteriorsFloorCell& floorCell, const InteriorFloorAnimationState &floorViewState, const InteriorsFloorModel &floorModel, const float flatteningScale, const float interiorTerrainHeight, const v4& floorColor, const v4& detailColor, const m44& normalTransform);
107 
108  void RefreshPropsForFloor(const InteriorsFloorModel& floorModel, const InteriorFloorAnimationState& floorViewState, const float flatteningScale, const float interiorTerrainHeight, const m44& normalTransform, const v4& detailColor);
109 
110  PropRenderableRepository& m_propRenderableRepository;
111  const Rendering::EnvironmentFlatteningService& m_environmentFlatteningService;
112 
113  const IInteriorFloorAnimator& m_interiorFloorAnimator;
114  std::vector<CallbackType*> m_callbacks;
115 
116  const InteriorsModel* m_pCurrentModel;
117  int m_selectedFloorIndex;
118  float m_alpha;
119  float m_lookAtHeight;
120  bool m_isDirty;
121  };
122  }
123  }
124 }