6 #include "CulledMeshRenderable.h"
10 #include "VectorMath.h"
11 #include "InteriorsStencilMirrorType.h"
12 #include "InteriorsRenderableLayer.h"
29 : m_cameraLocationEcef(dv3::Zero())
30 , m_positionUnpackTransform(m44::CreateIdentity())
31 , m_positionModelTransform(m44::CreateIdentity())
32 , m_normalModelTransform(m44::CreateIdentity())
33 , m_viewTransform(m44::CreateIdentity())
34 , m_projectionTransform(m44::CreateIdentity())
35 , m_worldToEcefTangentTransform(m44::CreateIdentity())
36 , m_cameraRelativeTransform(m44::CreateIdentity())
41 const m44& positionUnpackTransform,
42 const m44& positionModelTransform,
43 const m44& normalModelTransform,
44 const m44& viewTransform,
45 const m44& projectionTransform,
46 const m44& worldToEcefTangentTransform,
47 const m44& cameraRelativeTransform,
48 const v3& cameraRelativeSortOrigin)
49 : m_cameraLocationEcef(cameraLocationEcef)
50 , m_positionUnpackTransform(positionUnpackTransform)
51 , m_positionModelTransform(positionModelTransform)
52 , m_normalModelTransform(normalModelTransform)
53 , m_viewTransform(viewTransform)
54 , m_projectionTransform(projectionTransform)
55 , m_worldToEcefTangentTransform(worldToEcefTangentTransform)
56 , m_cameraRelativeTransform(cameraRelativeTransform)
57 , m_cameraRelativeSortOrigin(cameraRelativeSortOrigin)
60 dv3 CameraLocationEcef()
const {
return m_cameraLocationEcef; }
61 m44 PositionUnpackTransform()
const {
return m_positionUnpackTransform; }
62 m44 PositionModelTransform()
const {
return m_positionModelTransform; }
63 m44 NormalModelTransform()
const {
return m_normalModelTransform; }
64 m44 ViewTransform()
const {
return m_viewTransform; }
65 m44 ProjectionTransform()
const {
return m_projectionTransform; }
66 m44 WorldToEcefTangentTransform()
const {
return m_worldToEcefTangentTransform; }
67 m44 CameraRelativeTransform()
const {
return m_cameraRelativeTransform; }
68 const v3& CameraRelativeSortOrigin()
const {
return m_cameraRelativeSortOrigin; }
70 m44 UnpackModel()
const;
71 m44 UnpackMVP()
const;
72 v3 WorldViewDirection()
const;
75 dv3 m_cameraLocationEcef;
76 m44 m_positionUnpackTransform;
77 m44 m_positionModelTransform;
78 m44 m_normalModelTransform;
80 m44 m_projectionTransform;
81 m44 m_worldToEcefTangentTransform;
82 m44 m_cameraRelativeTransform;
83 v3 m_cameraRelativeSortOrigin;
98 const std::string& renderableId,
100 const float interiorTerrainHeight,
102 const std::string& interiorIdentifier);
108 const std::string& GetRenderableId()
const;
110 virtual void SetColor(
const v4& color);
111 const v4& GetColor()
const;
112 void SetSaturation(
float saturation);
113 float GetSaturation()
const {
return m_saturation; }
114 virtual bool NeedsStencilMirrorDuplicates()
const {
return m_stencilMirrorType == Resources::Interiors::StencilMirror_Mirror; }
115 bool IsStencilMirrorMask()
const {
return m_stencilMirrorType == Resources::Interiors::StencilMirror_Mask; }
116 Resources::Interiors::InteriorsStencilMirrorType GetStencilMirrorType()
const {
return m_stencilMirrorType; }
117 v4 GetStencilMirrorClearColor()
const;
118 bool NeedsBlend()
const;
119 float GetInteriorTerrainHeight()
const {
return m_interiorTerrainHeight; }
120 const std::string& GetInteriorId()
const;
122 int GetFloorIndex()
const {
return m_floorIndex; }
123 Resources::Interiors::InteriorsRenderableLayer::Type GetMaterialRenderableLayer()
const {
return m_materialRenderableLayer; }
125 const Eegeo::v2& GetUVBoundsMin()
const {
return m_uvBoundsMin; }
126 const Eegeo::v2& GetUVBoundsMax()
const {
return m_uvBoundsMax; }
127 const Eegeo::v4& GetPositionBoundsMin()
const {
return m_positionBoundsMin; }
128 const Eegeo::v4& GetPositionBoundsMax()
const {
return m_positionBoundsMax; }
130 RenderState CalcRenderState(
const Rendering::RenderContext& renderContext,
float environmentFlatteningScale)
const;
132 void SetRenderState(
const RenderState& renderState) { m_renderState = renderState; }
133 RenderState GetRenderState()
const {
return m_renderState; }
135 virtual void SetModelTransform(
const m44& modelToLocalEcefTransform);
137 void SetNormalModelTransform(
const m44& normalToLocalEcefTransform);
139 void SetMaterialIsTranslucent(
bool materialIsTranslucent);
141 void SetMaterialRenderableLayer(Eegeo::Resources::Interiors::InteriorsRenderableLayer::Type materialRenderableLayer);
143 void SetSortKeyTranslucency(
bool depthSorted);
145 void SetStencilMirrorType(Resources::Interiors::InteriorsStencilMirrorType stencilMirrorType);
147 void SetStencilMirrorClearColor(
const v3& stencilMirrorClearColor);
149 virtual bool UpdateVisibility(
const Eegeo::Geometry::Frustum& viewFrustum, Culling::CullingVolumeVisibilityUpdater& visibilityUpdater,
float environmentScale);
151 u32 CalcSortKeyDepthOpaque()
const;
153 static u32 CalcSortKeyDepthOpaque(
int floorIndex, Resources::Interiors::InteriorsStencilMirrorType stencilMirrorType);
155 u32 CalcSortKeyDepthBlended(
int drawOrderDepth)
const;
157 static u32 CalcSortKeyDepthBlended(
int floorIndex, Resources::Interiors::InteriorsRenderableLayer::Type renderableLayer, Resources::Interiors::InteriorsStencilMirrorType stencilMirrorType,
int drawOrderDepth);
159 bool IsMaterialTranslucent()
const {
return m_materialIsTranslucent; }
161 m44 GetModelTransform()
const {
return m_modelTransform; }
164 m44 CalcPositionUnpack()
const;
166 m44 GetNormalModelTransform()
const {
return m_normalModelTransform; }
170 m44 CalcCameraRelativeTransform(
const dv3& cameraLocationEcef)
const;
171 m44 CalcCameraRelativeModelTransform(
const m44& modelTransform,
const m44& cameraRelativeTransform)
const;
180 const std::string m_renderableId;
181 const Resources::Interiors::IInteriorsMaterialAssignmentObserver& m_materialAssignmentObserver;
182 const int m_floorIndex;
183 const float m_interiorTerrainHeight;
184 const bool m_ownsMesh;
187 m44 m_modelTransform;
188 m44 m_normalModelTransform;
189 v3 m_stencilMirrorClearColor;
192 Resources::Interiors::InteriorsStencilMirrorType m_stencilMirrorType;
193 bool m_materialIsTranslucent;
194 Resources::Interiors::InteriorsRenderableLayer::Type m_materialRenderableLayer;
195 std::string m_interiorIdentifier;
198 RenderState m_renderState;