Overte C++ Documentation
LightPayload.h
1 //
2 // LightPayload.h
3 //
4 // Created by Sam Gateau on 9/6/16.
5 // Copyright 2016 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_LightPayload_h
12 #define hifi_LightPayload_h
13 
14 
15 #include <graphics/Light.h>
16 #include <render/Item.h>
17 #include "LightStage.h"
18 #include "TextureCache.h"
19 
20 class LightPayload {
21 public:
22  using Payload = render::Payload<LightPayload>;
23  using Pointer = Payload::DataPointer;
24 
25  LightPayload();
26  ~LightPayload();
27  void render(RenderArgs* args);
28 
29  graphics::LightPointer editLight() { _needUpdate = true; return _light; }
30  render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
31 
32  void setVisible(bool visible) { _isVisible = visible; }
33  bool isVisible() const { return _isVisible; }
34 
35 protected:
36  graphics::LightPointer _light;
37  render::Item::Bound _bound;
38  LightStagePointer _stage;
39  LightStage::Index _index { LightStage::INVALID_INDEX };
40  bool _needUpdate { true };
41  bool _isVisible{ true };
42 };
43 
44 namespace render {
45  template <> const ItemKey payloadGetKey(const LightPayload::Pointer& payload);
46  template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload, RenderArgs* args);
47  template <> void payloadRender(const LightPayload::Pointer& payload, RenderArgs* args);
48 }
49 
50 class KeyLightPayload {
51 public:
52  using Payload = render::Payload<KeyLightPayload>;
53  using Pointer = Payload::DataPointer;
54 
55  KeyLightPayload();
56  ~KeyLightPayload();
57  void render(RenderArgs* args);
58 
59  graphics::LightPointer editLight() { _needUpdate = true; return _light; }
60  render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
61 
62  void setVisible(bool visible) { _isVisible = visible; }
63  bool isVisible() const { return _isVisible; }
64 
65 
66  // More attributes used for rendering:
67  NetworkTexturePointer _ambientTexture;
68  QString _ambientTextureURL;
69  bool _pendingAmbientTexture { false };
70 
71 protected:
72  graphics::LightPointer _light;
73  render::Item::Bound _bound;
74  LightStagePointer _stage;
75  LightStage::Index _index { LightStage::INVALID_INDEX };
76  bool _needUpdate { true };
77  bool _isVisible { true };
78 };
79 
80 namespace render {
81  template <> const ItemKey payloadGetKey(const KeyLightPayload::Pointer& payload);
82  template <> const Item::Bound payloadGetBound(const KeyLightPayload::Pointer& payload, RenderArgs* args);
83  template <> void payloadRender(const KeyLightPayload::Pointer& payload, RenderArgs* args);
84 }
85 
86 #endif