All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PlaceNameView.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "PlaceNames.h"
7 #include "Geometry.h"
8 #include "Camera.h"
9 #include "VectorMathDecl.h"
10 #include "Bounds.h"
11 #include <vector>
12 
13 namespace Eegeo
14 {
15  namespace Resources
16  {
17  namespace PlaceNames
18  {
20  {
21  public:
22  PlaceNameView(const std::vector<PlaceNameRenderable*>& renderables,
23  const Geometry::Bounds2D& localBounds,
24  const dv3& positionEcef,
25  const v3& color,
26  const v3& outlineColor,
27  float scale,
28  float unflattenableHeightOffset);
29  ~PlaceNameView();
30 
31  const std::vector<PlaceNameRenderable*>& GetRenderables() const { return m_renderables; }
32 
33  void UpdateVisibility(const Camera::RenderCamera& renderCamera, const v3& cameraSurfaceNormal, float baseScale, float environmentScale);
34  void UpdateTransforms(const Camera::RenderCamera& renderCamera, const v3& cameraSurfaceNormal, float baseScale, float environmentScale);
35  void UpdateTransformsAndVisibility(const Camera::RenderCamera& renderCamera, const v3& cameraSurfaceNormal, float baseScale, float environmentScale);
36 
37  const Geometry::Bounds3D& GetScreenBounds() const { return m_screenBounds; }
38 
39  bool IsOccluded() const { return m_isOccluded; }
40 
41  bool IsOcclusionPending() const { return m_occlusionPending; }
42 
43  float GetAlpha() const { return m_alpha; }
44 
45  bool IsCompletelyTransparent() const { return m_alpha < (1.0f / 255.0f); }
46 
47  bool IsInFrustum() const { return m_isInFrustum; }
48 
49  bool IsInFrontOfCamera() const { return m_isInFrontOfCamera; }
50 
51  void CopyStateFrom(const PlaceNameView& placeNameView);
52  void SetOccluded(bool isOccluded) { m_isOccluded = isOccluded; }
53  void SetOcclusionPending(bool isPending) { m_occlusionPending = isPending; }
54  void SetAlpha(float alpha) { m_alpha = alpha; }
55  void SetIsInFrustum(bool isInFrustum) { m_isInFrustum = isInFrustum; }
56  void SetIsInFrontOfCamera(bool isInFrontOfCamera) { m_isInFrontOfCamera = isInFrontOfCamera; }
57 
58  float GetTransitionParam() const { return m_transitionParam; }
59  void SetTransitionParam(float t) { m_transitionParam = t; }
60 
61  void SetColor(const v3& color) { m_color = color; }
62  void SetOutlineColor(const v3& outlineColor) { m_outlineColor = outlineColor; }
63  void SetScale(float scale) { m_scale = scale; }
64 
65  void SetPositionTransform(const m44& transform);
66  const m44& GetPositionTransform() const;
67  void SetPositionTransformOrigin(const dv3& ecefTransformOrigin);
68  const dv3& GetPositionTransformOrigin() const;
69 
70  private:
71  const std::vector<PlaceNameRenderable*> m_renderables;
72  const Geometry::Bounds2D m_localBounds;
73  const dv3 m_positionEcef;
74  v3 m_color;
75  v3 m_outlineColor;
76  float m_scale;
77  const float m_unflattenableHeightOffset;
78 
79  Geometry::Bounds3D m_screenBounds;
80  bool m_isOccluded;
81  bool m_occlusionPending;
82  bool m_isInFrustum;
83  bool m_isInFrontOfCamera;
84  float m_alpha;
85  float m_transitionParam;
86 
87  dv3 m_positionTransformOrigin;
88  m44 m_positionTransform;
89 
90  void UpdatePerInstanceData(const m44& mvp);
91  void CalculateCullState(const Geometry::Bounds2D& localBounds, const m44& mvp, Geometry::Bounds3D& out_screenBounds, bool& out_isInFrustum, bool& out_isInFrontOfCamera) const;
92  dv3 GetTruePosition(const v3& cameraSurfaceNormal, float environmentScale) const;
93  };
94  }
95  }
96 }