Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dparticlelineparticle_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DPARTICLELINEPARTICLE_H
7#define QQUICK3DPARTICLELINEPARTICLE_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3DParticles/private/qquick3dparticlespriteparticle_p.h>
21
23
24class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleLineParticle : public QQuick3DParticleSpriteParticle
25{
26 Q_OBJECT
27 Q_PROPERTY(int segmentCount READ segmentCount WRITE setSegmentCount NOTIFY segmentCountChanged)
28 Q_PROPERTY(float alphaFade READ alphaFade WRITE setAlphaFade NOTIFY alphaFadeChanged)
29 Q_PROPERTY(float scaleMultiplier READ scaleMultiplier WRITE setScaleMultiplier NOTIFY scaleMultiplierChanged)
30 Q_PROPERTY(float texcoordMultiplier READ texcoordMultiplier WRITE setTexcoordMultiplier NOTIFY texcoordMultiplierChanged)
31 Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged)
32 Q_PROPERTY(float lengthVariation READ lengthVariation WRITE setLengthVariation NOTIFY lengthVariationChanged)
33 Q_PROPERTY(float lengthDeltaMin READ lengthDeltaMin WRITE setLengthDeltaMin NOTIFY lengthDeltaMinChanged)
34 Q_PROPERTY(int eolFadeOutDuration READ eolFadeOutDuration WRITE setEolFadeOutDuration NOTIFY eolFadeOutDurationChanged)
35 Q_PROPERTY(TexcoordMode texcoordMode READ texcoordMode WRITE setTexcoordMode NOTIFY texcoordModeChanged)
36
37 QML_NAMED_ELEMENT(LineParticle3D)
38 QML_ADDED_IN_VERSION(6, 4)
39
40public:
41 enum TexcoordMode
42 {
43 Absolute,
44 Relative,
45 Fill,
46 };
47 Q_ENUM(TexcoordMode)
48
49 QQuick3DParticleLineParticle(QQuick3DNode *parent = nullptr);
50 ~QQuick3DParticleLineParticle() override;
51
52 int segmentCount() const;
53 float alphaFade() const;
54 float scaleMultiplier() const;
55 float texcoordMultiplier() const;
56 float length() const;
57 float lengthVariation() const;
58 float lengthDeltaMin() const;
59 int eolFadeOutDuration() const;
60 TexcoordMode texcoordMode() const;
61
62public Q_SLOTS:
63 void setSegmentCount(int count);
64 void setAlphaFade(float fade);
65 void setScaleMultiplier(float multiplier);
66 void setTexcoordMultiplier(float multiplier);
67 void setLength(float length);
68 void setLengthVariation(float length);
69 void setLengthDeltaMin(float min);
70 void setEolFadeOutDuration(int duration);
71 void setTexcoordMode(QQuick3DParticleLineParticle::TexcoordMode mode);
72
73Q_SIGNALS:
74 void segmentCountChanged();
75 void alphaFadeChanged();
76 void scaleMultiplierChanged();
77 void texcoordMultiplierChanged();
78 void lengthChanged();
79 void lengthVariationChanged();
80 void lengthDeltaMinChanged();
81 void eolFadeOutDurationChanged();
82 void texcoordModeChanged();
83
84private:
85
86 struct LineDataHeader
87 {
88 int emitterIndex = -1;
89 int pointCount = 0;
90 int currentIndex = 0;
91 float length = 0.0f;
92 };
93 struct LineData
94 {
95 QVector3D position;
96 QVector3D normal;
97 QVector4D color;
98 QVector3D tangent;
99 QVector3D binormal;
100 float size = 0.0f;
101 float length = 0.0f;
102 };
103 struct FadeOutLineData
104 {
105 int emitterIndex;
106 SpriteParticleData endPoint;
107 LineDataHeader header;
108 QVector<LineData> lineData;
109 float beginTime;
110 float endTime;
111 float timeFactor;
112 };
113
114 friend class QQuick3DParticleSystem;
115
116 class LineParticleUpdateNode : public ParticleUpdateNode
117 {
118 public:
119 LineParticleUpdateNode(QQuick3DNode *parent = nullptr)
120 : ParticleUpdateNode(parent)
121 {
122 }
123 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
124 };
125
126 void updateLineBuffer(LineParticleUpdateNode *updateNode, QSSGRenderGraphObject *node);
127 QSSGRenderGraphObject *updateLineNode(QSSGRenderGraphObject *node);
128 void handleSegmentCountChanged();
129 void updateLineSegment(int particleIndex);
130 void clearSegment(int particleIndex);
131 void handleMaxAmountChanged(int amount) override;
132 void handleSystemChanged(QQuick3DParticleSystem *system) override;
133 void reset() override;
134 void commitParticles(float time) override;
135 int nextCurrentIndex(const QQuick3DParticleEmitter *emitter) override;
136 void saveLineSegment(int particleIndex, float time);
137 void setParticleData(int particleIndex,
138 const QVector3D &position,
139 const QVector3D &rotation,
140 const QVector4D &color,
141 float size, float age,
142 float animationFrame) override;
143 void resetParticleData(int particleIndex) override;
144
145 QVector<LineDataHeader> m_lineHeaderData;
146 QVector<LineData> m_lineData;
147 QVector<FadeOutLineData> m_fadeOutData;
148
149 float m_alphaFade = 0.0f;
150 float m_scaleMultiplier = 1.0f;
151 float m_texcoordMultiplier = 1.0f;
152 float m_lengthDeltaMin = 10.0f;
153 float m_length = -1.0f;
154 float m_lengthVariation = 0.0f;
155 int m_segmentCount = 1;
156 int m_eolFadeOutDuration = 0;
157 TexcoordMode m_texcoordMode = TexcoordMode::Absolute;
158};
159
160QT_END_NAMESPACE
161
162#endif
QSSGRenderParticles::FeatureLevel lineFeatureLevel(QQuick3DParticleSpriteParticle::FeatureLevel in)
static QVector3D qt_normalFromRotation(const QVector3D &eulerRotation)