Overte C++ Documentation
LightEntityItem.h
1 //
2 // LightEntityItem.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_LightEntityItem_h
13 #define hifi_LightEntityItem_h
14 
15 #include "EntityItem.h"
16 
17 class LightEntityItem : public EntityItem {
18 public:
19  static const bool DEFAULT_IS_SPOTLIGHT;
20  static const float DEFAULT_INTENSITY;
21  static const float DEFAULT_FALLOFF_RADIUS;
22  static const float DEFAULT_EXPONENT;
23  static const float MIN_CUTOFF;
24  static const float MAX_CUTOFF;
25  static const float DEFAULT_CUTOFF;
26 
27  static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
28 
29  LightEntityItem(const EntityItemID& entityItemID);
30 
31  ALLOW_INSTANTIATION // This class can be instantiated
32 
34  virtual void setUnscaledDimensions(const glm::vec3& value) override;
35 
36  // methods for getting/setting all properties of an entity
37  virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override;
38  virtual bool setSubClassProperties(const EntityItemProperties& properties) override;
39 
40  virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
41 
42  virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
43  EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
44  EntityPropertyFlags& requestedProperties,
45  EntityPropertyFlags& propertyFlags,
46  EntityPropertyFlags& propertiesDidntFit,
47  int& propertyCount,
48  OctreeElement::AppendState& appendState) const override;
49 
50  virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
51  ReadBitstreamToTreeParams& args,
52  EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
53  bool& somethingChanged) override;
54 
55  glm::u8vec3 getColor() const;
56  void setColor(const glm::u8vec3& value);
57 
58  bool getIsSpotlight() const;
59  void setIsSpotlight(bool value);
60 
61  float getIntensity() const;
62  void setIntensity(float value);
63  float getFalloffRadius() const;
64  void setFalloffRadius(float value);
65 
66  float getExponent() const;
67  void setExponent(float value);
68 
69  float getCutoff() const;
70  void setCutoff(float value);
71 
72  static bool getLightsArePickable() { return _lightsArePickable; }
73  static void setLightsArePickable(bool value) { _lightsArePickable = value; }
74 
75  virtual bool supportsDetailedIntersection() const override { return true; }
76  virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
77  const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
78  BoxFace& face, glm::vec3& surfaceNormal,
79  QVariantMap& extraInfo, bool precisionPicking) const override;
80  virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
81  const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
82  float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
83  QVariantMap& extraInfo, bool precisionPicking) const override;
84 
85 private:
86  // properties of a light
87  glm::u8vec3 _color;
88  bool _isSpotlight { DEFAULT_IS_SPOTLIGHT };
89  float _intensity { DEFAULT_INTENSITY };
90  float _falloffRadius { DEFAULT_FALLOFF_RADIUS };
91  float _exponent { DEFAULT_EXPONENT };
92  float _cutoff { DEFAULT_CUTOFF };
93 
94  static bool _lightsArePickable;
95 };
96 
97 #endif // hifi_LightEntityItem_h
Definition: EntityItem.h:82
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