Overte C++ Documentation
PolyLineEntityItem.h
1 //
2 // PolyLineEntityItem.h
3 // libraries/entities/src
4 //
5 // Created by Eric Levin on 8/3/15.
6 // Copyright 2015 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
14 #ifndef hifi_PolyLineEntityItem_h
15 #define hifi_PolyLineEntityItem_h
16 
17 #include "EntityItem.h"
18 
19 class PolyLineEntityItem : public EntityItem {
20 public:
21  static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
22 
23  PolyLineEntityItem(const EntityItemID& entityItemID);
24 
25  ALLOW_INSTANTIATION // This class can be instantiated
26 
27  // methods for getting/setting all properties of an entity
28  virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override;
29  virtual bool setSubClassProperties(const EntityItemProperties& properties) override;
30 
31  virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
32 
33  virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
34  EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
35  EntityPropertyFlags& requestedProperties,
36  EntityPropertyFlags& propertyFlags,
37  EntityPropertyFlags& propertiesDidntFit,
38  int& propertyCount,
39  OctreeElement::AppendState& appendState) const override;
40 
41  virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
42  ReadBitstreamToTreeParams& args,
43  EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
44  bool& somethingChanged) override;
45 
46  glm::u8vec3 getColor() const;
47  void setColor(const glm::u8vec3& value);
48 
49  static const int MAX_POINTS_PER_LINE;
50  void setLinePoints(const QVector<glm::vec3>& points);
51  QVector<glm::vec3> getLinePoints() const;
52 
53  static const float DEFAULT_LINE_WIDTH;
54  void setStrokeWidths(const QVector<float>& strokeWidths);
55  QVector<float> getStrokeWidths() const;
56 
57  void setNormals(const QVector<glm::vec3>& normals);
58  QVector<glm::vec3> getNormals() const;
59 
60  void setStrokeColors(const QVector<glm::vec3>& strokeColors);
61  QVector<glm::vec3> getStrokeColors() const;
62 
63  void setIsUVModeStretch(bool isUVModeStretch);
64  bool getIsUVModeStretch() const{ return _isUVModeStretch; }
65 
66  QString getTextures() const;
67  void setTextures(const QString& textures);
68 
69  void setGlow(bool glow);
70  bool getGlow() const { return _glow; }
71 
72  void setFaceCamera(bool faceCamera);
73  bool getFaceCamera() const { return _faceCamera; }
74 
75  bool pointsChanged() const { return _pointsChanged; }
76  bool normalsChanged() const { return _normalsChanged; }
77  bool colorsChanged() const { return _colorsChanged; }
78  bool widthsChanged() const { return _widthsChanged; }
79  bool texturesChanged() const { return _texturesChanged; }
80 
81  void resetTexturesChanged() { _texturesChanged = false; }
82  void resetPolyLineChanged() { _colorsChanged = _widthsChanged = _normalsChanged = _pointsChanged = false; }
83 
84  // never have a ray intersection pick a PolyLineEntityItem.
85  virtual bool supportsDetailedIntersection() const override { return true; }
86  virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
87  const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
88  BoxFace& face, glm::vec3& surfaceNormal,
89  QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
90  virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
91  const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
92  float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
93  QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
94 
95  void computeTightLocalBoundingBox(AABox& box) const;
96 
97  virtual void debugDump() const override;
98 private:
99  void computeAndUpdateDimensions();
100 
101  protected:
102  glm::u8vec3 _color;
103  QVector<glm::vec3> _points;
104  QVector<glm::vec3> _normals;
105  QVector<glm::vec3> _colors;
106  QVector<float> _widths;
107  QString _textures;
108  bool _isUVModeStretch { false };
109  bool _glow { false };
110  bool _faceCamera { false };
111 
112  bool _pointsChanged { false };
113  bool _normalsChanged { false };
114  bool _colorsChanged { false };
115  bool _widthsChanged { false };
116  bool _texturesChanged { false };
117 };
118 
119 #endif // hifi_PolyLineEntityItem_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