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