Overte C++ Documentation
ZoneEntityItem.h
1 //
2 // ZoneEntityItem.h
3 // libraries/entities/src
4 //
5 // Created by Brad Hefta-Gaub on 12/4/13.
6 // Copyright 2013 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_ZoneEntityItem_h
13 #define hifi_ZoneEntityItem_h
14 
15 #include <ComponentMode.h>
16 #include <model-networking/ModelCache.h>
17 
18 #include "KeyLightPropertyGroup.h"
19 #include "AmbientLightPropertyGroup.h"
20 #include "EntityItem.h"
21 #include "EntityTree.h"
22 #include "SkyboxPropertyGroup.h"
23 #include "HazePropertyGroup.h"
24 #include "BloomPropertyGroup.h"
25 
26 class ZoneEntityItem : public EntityItem {
27 public:
28  static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
29 
30  ZoneEntityItem(const EntityItemID& entityItemID);
31 
32  ALLOW_INSTANTIATION // This class can be instantiated
33 
34  // methods for getting/setting all properties of an entity
35  virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override;
36  virtual bool setSubClassProperties(const EntityItemProperties& properties) override;
37 
38  virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
39 
40  virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
41  EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
42  EntityPropertyFlags& requestedProperties,
43  EntityPropertyFlags& propertyFlags,
44  EntityPropertyFlags& propertiesDidntFit,
45  int& propertyCount,
46  OctreeElement::AppendState& appendState) const override;
47 
48  virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
49  ReadBitstreamToTreeParams& args,
50  EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
51  bool& somethingChanged) override;
52 
53 
54 
55  static bool getZonesArePickable() { return _zonesArePickable; }
56  static void setZonesArePickable(bool value) { _zonesArePickable = value; }
57 
58  static bool getDrawZoneBoundaries() { return _drawZoneBoundaries; }
59  static void setDrawZoneBoundaries(bool value) { _drawZoneBoundaries = value; }
60 
61  virtual bool isReadyToComputeShape() const override { return false; }
62  virtual void setShapeType(ShapeType type) override;
63  virtual ShapeType getShapeType() const override;
64  bool shouldBePhysical() const override { return false; }
65 
66  QString getCompoundShapeURL() const;
67  virtual void setCompoundShapeURL(const QString& url);
68 
69  virtual bool matchesJSONFilters(const QJsonObject& jsonFilters) const override;
70 
71  KeyLightPropertyGroup getKeyLightProperties() const { return resultWithReadLock<KeyLightPropertyGroup>([&] { return _keyLightProperties; }); }
72  AmbientLightPropertyGroup getAmbientLightProperties() const { return resultWithReadLock<AmbientLightPropertyGroup>([&] { return _ambientLightProperties; }); }
73 
74  void setHazeMode(const uint32_t value);
75  uint32_t getHazeMode() const;
76 
77  void setKeyLightMode(uint32_t value);
78  uint32_t getKeyLightMode() const;
79 
80  void setAmbientLightMode(uint32_t value);
81  uint32_t getAmbientLightMode() const;
82 
83  void setSkyboxMode(uint32_t value);
84  uint32_t getSkyboxMode() const;
85 
86  void setBloomMode(const uint32_t value);
87  uint32_t getBloomMode() const;
88 
89  SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock<SkyboxPropertyGroup>([&] { return _skyboxProperties; }); }
90 
91  const HazePropertyGroup& getHazeProperties() const { return _hazeProperties; }
92  const BloomPropertyGroup& getBloomProperties() const { return _bloomProperties; }
93 
94  bool getFlyingAllowed() const { return _flyingAllowed; }
95  void setFlyingAllowed(bool value) { _flyingAllowed = value; }
96  bool getGhostingAllowed() const { return _ghostingAllowed; }
97  void setGhostingAllowed(bool value) { _ghostingAllowed = value; }
98  QString getFilterURL() const;
99  void setFilterURL(const QString url);
100 
101  uint32_t getAvatarPriority() const { return _avatarPriority; }
102  void setAvatarPriority(uint32_t value) { _avatarPriority = value; }
103 
104  uint32_t getScreenshare() const { return _screenshare; }
105  void setScreenshare(uint32_t value) { _screenshare = value; }
106 
107  void setUserData(const QString& value) override;
108 
109  bool keyLightPropertiesChanged() const { return _keyLightPropertiesChanged; }
110  bool ambientLightPropertiesChanged() const { return _ambientLightPropertiesChanged; }
111  bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; }
112  bool hazePropertiesChanged() const { return _hazePropertiesChanged; }
113  bool bloomPropertiesChanged() const { return _bloomPropertiesChanged; }
114 
115  void resetRenderingPropertiesChanged();
116 
117  virtual bool supportsDetailedIntersection() const override { return true; }
118  virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
119  const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
120  BoxFace& face, glm::vec3& surfaceNormal,
121  QVariantMap& extraInfo, bool precisionPicking) const override;
122  virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
123  const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
124  float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
125  QVariantMap& extraInfo, bool precisionPicking) const override;
126 
127  bool contains(const glm::vec3& point) const override;
128 
129  virtual void debugDump() const override;
130 
131  static const ShapeType DEFAULT_SHAPE_TYPE;
132  static const QString DEFAULT_COMPOUND_SHAPE_URL;
133  static const bool DEFAULT_FLYING_ALLOWED;
134  static const bool DEFAULT_GHOSTING_ALLOWED;
135  static const QString DEFAULT_FILTER_URL;
136 
137 protected:
138  KeyLightPropertyGroup _keyLightProperties;
139  AmbientLightPropertyGroup _ambientLightProperties;
140 
141  ShapeType _shapeType { DEFAULT_SHAPE_TYPE };
142  QString _compoundShapeURL;
143 
144  // The following 3 values are the defaults for zone creation
145  uint32_t _keyLightMode { COMPONENT_MODE_INHERIT };
146  uint32_t _skyboxMode { COMPONENT_MODE_INHERIT };
147  uint32_t _ambientLightMode { COMPONENT_MODE_INHERIT };
148 
149  uint32_t _hazeMode { COMPONENT_MODE_INHERIT };
150  uint32_t _bloomMode { COMPONENT_MODE_INHERIT };
151 
152  SkyboxPropertyGroup _skyboxProperties;
153  HazePropertyGroup _hazeProperties;
154  BloomPropertyGroup _bloomProperties;
155 
156  bool _flyingAllowed { DEFAULT_FLYING_ALLOWED };
157  bool _ghostingAllowed { DEFAULT_GHOSTING_ALLOWED };
158  QString _filterURL { DEFAULT_FILTER_URL };
159 
160  // Avatar-updates priority
161  uint32_t _avatarPriority { COMPONENT_MODE_INHERIT };
162 
163  // Screen-sharing zone
164  uint32_t _screenshare { COMPONENT_MODE_INHERIT };
165 
166  // Dirty flags turn true when either keylight properties is changing values.
167  bool _keyLightPropertiesChanged { false };
168  bool _ambientLightPropertiesChanged { false };
169  bool _skyboxPropertiesChanged { false };
170  bool _hazePropertiesChanged{ false };
171  bool _bloomPropertiesChanged { false };
172 
173  static bool _drawZoneBoundaries;
174  static bool _zonesArePickable;
175 
176  void fetchCollisionGeometryResource();
177  GeometryResource::Pointer _shapeResource;
178 
179 };
180 
181 #endif // hifi_ZoneEntityItem_h
Definition: EntityItem.h:82
virtual ShapeType getShapeType() const
return preferred shape type (actual physical shape may differ)
Definition: EntityItem.h:390
Abstract ID for editing model items. Used in EntityItem JS API.
Definition: EntityItemID.h:28
Definition: EntityItemProperties.h:106
Handles packing of the data portion of PacketType_OCTREE_DATA messages.
Definition: OctreePacketData.h:93