Overte C++ Documentation
PulsePropertyGroup.h
1 //
2 // PulsePropertyGroup.h
3 //
4 // Created by Sam Gondelman on 1/15/19
5 // Copyright 2019 High Fidelity, Inc.
6 // Copyright 2023 Overte e.V.
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 // SPDX-License-Identifier: Apache-2.0
11 //
12 
13 #ifndef hifi_PulsePropertyGroup_h
14 #define hifi_PulsePropertyGroup_h
15 
16 #include <stdint.h>
17 
18 #include <PulseMode.h>
19 
20 #include "PropertyGroup.h"
21 #include "EntityItemPropertiesMacros.h"
22 
24 class EncodeBitstreamParams;
25 class OctreePacketData;
26 class ReadBitstreamToTreeParams;
27 class ScriptEngine;
28 class ScriptValue;
29 
30 /*@jsdoc
31  * A color and alpha pulse that an entity may have.
32  * @typedef {object} Entities.Pulse
33  * @property {number} min=0 - The minimum value of the pulse multiplier.
34  * @property {number} max=1 - The maximum value of the pulse multiplier.
35  * @property {number} period=1 - The duration of the color and alpha pulse, in seconds. A pulse multiplier value goes from
36  * <code>min</code> to <code>max</code>, then <code>max</code> to <code>min</code> in one period.
37  * @property {Entities.PulseMode} colorMode="none" - If "in", the color is pulsed in phase with the pulse period; if "out"
38  * the color is pulsed out of phase with the pulse period.
39  * @property {Entities.PulseMode} alphaMode="none" - If "in", the alpha is pulsed in phase with the pulse period; if "out"
40  * the alpha is pulsed out of phase with the pulse period.
41  */
42 class PulsePropertyGroup : public PropertyGroup {
43 public:
44  // EntityItemProperty related helpers
45  virtual void copyToScriptValue(const EntityPropertyFlags& desiredProperties, ScriptValue& properties,
46  ScriptEngine* engine, bool skipDefaults,
47  EntityItemProperties& defaultEntityProperties, bool returnNothingOnEmptyPropertyFlags,
48  bool isMyOwnAvatarEntity) const override;
49  virtual void copyFromScriptValue(const ScriptValue& object, const QSet<QString> &namesSet, bool& _defaultSettings) override;
50 
51  void merge(const PulsePropertyGroup& other);
52 
53  virtual void debugDump() const override;
54  virtual void listChangedProperties(QList<QString>& out) override;
55 
56  virtual bool appendToEditPacket(OctreePacketData* packetData,
57  EntityPropertyFlags& requestedProperties,
58  EntityPropertyFlags& propertyFlags,
59  EntityPropertyFlags& propertiesDidntFit,
60  int& propertyCount,
61  OctreeElement::AppendState& appendState) const override;
62 
63  virtual bool decodeFromEditPacket(EntityPropertyFlags& propertyFlags,
64  const unsigned char*& dataAt, int& processedBytes) override;
65  virtual void markAllChanged() override;
66  virtual EntityPropertyFlags getChangedProperties() const override;
67 
68  // EntityItem related helpers
69  // methods for getting/setting all properties of an entity
70  virtual void getProperties(EntityItemProperties& propertiesOut) const override;
71 
72  // returns true if something changed
73  virtual bool setProperties(const EntityItemProperties& properties) override;
74 
75  virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
76 
77  virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
78  EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
79  EntityPropertyFlags& requestedProperties,
80  EntityPropertyFlags& propertyFlags,
81  EntityPropertyFlags& propertiesDidntFit,
82  int& propertyCount,
83  OctreeElement::AppendState& appendState) const override;
84 
85  virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
86  ReadBitstreamToTreeParams& args,
87  EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
88  bool& somethingChanged) override;
89 
90  bool operator==(const PulsePropertyGroup& a) const;
91  bool operator!=(const PulsePropertyGroup& a) const { return !(*this == a); }
92 
93  DEFINE_PROPERTY(PROP_PULSE_MIN, Min, min, float, 0.0f);
94  DEFINE_PROPERTY(PROP_PULSE_MAX, Max, max, float, 1.0f);
95  DEFINE_PROPERTY(PROP_PULSE_PERIOD, Period, period, float, 1.0f);
96  DEFINE_PROPERTY_REF_ENUM(PROP_PULSE_COLOR_MODE, ColorMode, colorMode, PulseMode, PulseMode::NONE);
97  DEFINE_PROPERTY_REF_ENUM(PROP_PULSE_ALPHA_MODE, AlphaMode, alphaMode, PulseMode, PulseMode::NONE);
98 };
99 
100 #endif // hifi_PulsePropertyGroup_h
Definition: EntityItemProperties.h:106
Handles packing of the data portion of PacketType_OCTREE_DATA messages.
Definition: OctreePacketData.h:93
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40