All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RenderableBase.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 "Rendering.h"
8 #include "LayerIds.h"
9 #include "SortKey.h"
10 
11 namespace Eegeo
12 {
13  namespace Rendering
14  {
21  {
22  public:
24  const m44& modelViewProjection,
25  const dv3& ecefPosition,
26  const Rendering::Materials::IMaterial* pMaterial,
27  const VertexLayouts::VertexBinding* pVertexBinding,
28  const SortKey& sortKey
29  );
30 
32  LayerIds::Values layerId,
33  const dv3& ecefPosition,
34  const Rendering::Materials::IMaterial* material,
35  const VertexLayouts::VertexBinding& vertexBinding
36  );
37 
39  LayerIds::Values layerId,
40  const dv3& ecefPosition,
41  const Rendering::Materials::IMaterial* material
42  );
43 
44  virtual ~RenderableBase() { };
45 
46  inline const SortKey GetSortKey() const { return m_sortKey; }
47 
48  void SetLayer(LayerIds::Values layerId);
49 
50  inline LayerIds::Values GetLayer() const
51  {
52  return (LayerIds::Values) m_sortKey.GetLayer();
53  }
54 
55  void SetUserDefined(u64 userDefined);
56 
57  inline u64 GetUserDefined() const
58  {
59  return m_sortKey.GetUserDefined();
60  }
61 
62  void SetDepth(u64 depth);
63 
64  inline u64 GetDepth() const
65  {
66  return m_sortKey.GetDepth();
67  }
68 
69  virtual void SetMaterial(const Rendering::Materials::IMaterial* pMaterial, Rendering::VertexLayouts::VertexBindingPool& vertexBindingPool);
70 
71  inline const Materials::IMaterial* GetMaterial() const
72  {
73  return m_material;
74  }
75 
76  virtual bool ShouldRender() const { return true; }
77 
78  virtual void Render(Rendering::GLState& glState) const = 0;
79 
80  inline void SetEcefPosition(const dv3& ecefPosition) { m_ecefPosition = ecefPosition; }
81  inline const dv3& GetEcefPosition() const { return m_ecefPosition; }
82 
83  inline void SetModelViewProjection(const m44& modelViewProjection)
84  {
85  m_modelViewProjection = modelViewProjection;
86  }
87 
88  inline const m44& GetModelViewProjection() const
89  {
90  return m_modelViewProjection;
91  }
92 
93  protected:
94  virtual void UpdateSortKeyForMaterial(const Materials::IMaterial* material);
95 
96  virtual void OnMaterialChanged(const Rendering::Materials::IMaterial* pMaterial, Rendering::VertexLayouts::VertexBindingPool& vertexBindingPool)
97  {
98  }
99 
100  void SetVertexBinding(const VertexLayouts::VertexBinding& binding);
101 
102  inline const VertexLayouts::VertexBinding* GetVertexBinding() const
103  {
104  return m_pVertexBinding;
105  }
106 
107  m44 m_modelViewProjection;
108  dv3 m_ecefPosition;
109  const Rendering::Materials::IMaterial* m_material;
110  const VertexLayouts::VertexBinding* m_pVertexBinding;
111  SortKey m_sortKey;
112  };
113  }
114 }