Overte C++ Documentation
RenderableZoneEntityItem.h
1 //
2 // RenderableZoneEntityItem.h
3 //
4 // Created by Clement on 4/22/15.
5 // Copyright 2015 High Fidelity, Inc.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_RenderableZoneEntityItem_h
12 #define hifi_RenderableZoneEntityItem_h
13 
14 #include <ZoneEntityItem.h>
15 #include <graphics/Skybox.h>
16 #include <graphics/Haze.h>
17 #include <graphics/Bloom.h>
18 #include <graphics/Stage.h>
19 #include <LightStage.h>
20 #include <BackgroundStage.h>
21 #include <HazeStage.h>
22 #include <BloomStage.h>
23 #include <TextureCache.h>
24 #include "RenderableEntityItem.h"
25 #include <ComponentMode.h>
26 
27 namespace render { namespace entities {
28 
29 class ZoneEntityRenderer : public TypedEntityRenderer<ZoneEntityItem> {
30  using Parent = TypedEntityRenderer<ZoneEntityItem>;
31  friend class EntityRenderer;
32 
33 public:
34  ZoneEntityRenderer(const EntityItemPointer& entity);
35 
36 protected:
37  virtual void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
38  virtual ItemKey getKey() override;
39  virtual void doRender(RenderArgs* args) override;
40  virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
41  virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
42 
43 private:
44  void updateKeyZoneItemFromEntity(const TypedEntityPointer& entity);
45  void updateKeySunFromEntity(const TypedEntityPointer& entity);
46  void updateAmbientLightFromEntity(const TypedEntityPointer& entity);
47  void updateHazeFromEntity(const TypedEntityPointer& entity);
48  void updateKeyBackgroundFromEntity(const TypedEntityPointer& entity);
49  void updateBloomFromEntity(const TypedEntityPointer& entity);
50  void updateAmbientMap();
51  void updateSkyboxMap();
52  void setAmbientURL(const QString& ambientUrl);
53  void setSkyboxURL(const QString& skyboxUrl);
54 
55  void setSkyboxColor(const glm::vec3& color);
56  void setProceduralUserData(const QString& userData);
57 
58  graphics::LightPointer editSunLight() { _needSunUpdate = true; return _sunLight; }
59  graphics::LightPointer editAmbientLight() { _needAmbientUpdate = true; return _ambientLight; }
60  graphics::SunSkyStagePointer editBackground() { _needBackgroundUpdate = true; return _background; }
61  graphics::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); }
62  graphics::HazePointer editHaze() { _needHazeUpdate = true; return _haze; }
63  graphics::BloomPointer editBloom() { _needBloomUpdate = true; return _bloom; }
64 
65  glm::vec3 _lastPosition;
66  glm::vec3 _lastDimensions;
67  glm::quat _lastRotation;
68  bool _lastVisible;
69 
70  LightStagePointer _stage;
71  const graphics::LightPointer _sunLight { std::make_shared<graphics::Light>() };
72  const graphics::LightPointer _ambientLight { std::make_shared<graphics::Light>() };
73  const graphics::SunSkyStagePointer _background { std::make_shared<graphics::SunSkyStage>() };
74  const graphics::HazePointer _haze { std::make_shared<graphics::Haze>() };
75  const graphics::BloomPointer _bloom { std::make_shared<graphics::Bloom>() };
76 
77  ComponentMode _keyLightMode { COMPONENT_MODE_INHERIT };
78  ComponentMode _ambientLightMode { COMPONENT_MODE_INHERIT };
79  ComponentMode _skyboxMode { COMPONENT_MODE_INHERIT };
80  ComponentMode _hazeMode { COMPONENT_MODE_INHERIT };
81  ComponentMode _bloomMode { COMPONENT_MODE_INHERIT };
82 
83  indexed_container::Index _sunIndex { LightStage::INVALID_INDEX };
84  indexed_container::Index _ambientIndex { LightStage::INVALID_INDEX };
85 
86  BackgroundStagePointer _backgroundStage;
87  BackgroundStage::Index _backgroundIndex { BackgroundStage::INVALID_INDEX };
88 
89  HazeStagePointer _hazeStage;
90  HazeStage::Index _hazeIndex { HazeStage::INVALID_INDEX };
91 
92  BloomStagePointer _bloomStage;
93  BloomStage::Index _bloomIndex { BloomStage::INVALID_INDEX };
94 
95  bool _needUpdate{ true };
96  bool _needSunUpdate{ true };
97  bool _needAmbientUpdate{ true };
98  bool _needBackgroundUpdate{ true };
99  bool _needHazeUpdate{ true };
100  bool _needBloomUpdate { true };
101 
102  KeyLightPropertyGroup _keyLightProperties;
103  AmbientLightPropertyGroup _ambientLightProperties;
104  HazePropertyGroup _hazeProperties;
105  SkyboxPropertyGroup _skyboxProperties;
106  BloomPropertyGroup _bloomProperties;
107 
108  // More attributes used for rendering:
109  QString _ambientTextureURL;
110  NetworkTexturePointer _ambientTexture;
111  bool _pendingAmbientTexture{ false };
112 
113  QString _skyboxTextureURL;
114  NetworkTexturePointer _skyboxTexture;
115  bool _pendingSkyboxTexture{ false };
116 
117  QString _proceduralUserData;
118 };
119 
120 } } // namespace
121 
122 #endif // hifi_RenderableZoneEntityItem_h