Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QQUICK3DPARTICLELINEPARTICLE_H
5#define QQUICK3DPARTICLELINEPARTICLE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DParticles/private/qquick3dparticlespriteparticle_p.h>
19
21
22class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleLineParticle : public QQuick3DParticleSpriteParticle
23{
25 Q_PROPERTY(int segmentCount READ segmentCount WRITE setSegmentCount NOTIFY segmentCountChanged)
26 Q_PROPERTY(float alphaFade READ alphaFade WRITE setAlphaFade NOTIFY alphaFadeChanged)
27 Q_PROPERTY(float scaleMultiplier READ scaleMultiplier WRITE setScaleMultiplier NOTIFY scaleMultiplierChanged)
28 Q_PROPERTY(float texcoordMultiplier READ texcoordMultiplier WRITE setTexcoordMultiplier NOTIFY texcoordMultiplierChanged)
29 Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged)
30 Q_PROPERTY(float lengthVariation READ lengthVariation WRITE setLengthVariation NOTIFY lengthVariationChanged)
31 Q_PROPERTY(float lengthDeltaMin READ lengthDeltaMin WRITE setLengthDeltaMin NOTIFY lengthDeltaMinChanged)
32 Q_PROPERTY(int eolFadeOutDuration READ eolFadeOutDuration WRITE setEolFadeOutDuration NOTIFY eolFadeOutDurationChanged)
33 Q_PROPERTY(TexcoordMode texcoordMode READ texcoordMode WRITE setTexcoordMode NOTIFY texcoordModeChanged)
34
35 QML_NAMED_ELEMENT(LineParticle3D)
37
38public:
45 Q_ENUM(TexcoordMode)
46
49
50 int segmentCount() const;
51 float alphaFade() const;
52 float scaleMultiplier() const;
53 float texcoordMultiplier() const;
54 float length() const;
55 float lengthVariation() const;
56 float lengthDeltaMin() const;
57 int eolFadeOutDuration() const;
58 TexcoordMode texcoordMode() const;
59
60public Q_SLOTS:
61 void setSegmentCount(int count);
62 void setAlphaFade(float fade);
63 void setScaleMultiplier(float multiplier);
64 void setTexcoordMultiplier(float multiplier);
65 void setLength(float length);
66 void setLengthVariation(float length);
67 void setLengthDeltaMin(float min);
68 void setEolFadeOutDuration(int duration);
70
81
82private:
83
84 struct LineDataHeader
85 {
86 int emitterIndex = -1;
87 int pointCount = 0;
88 int currentIndex = 0;
89 float length = 0.0f;
90 };
91 struct LineData
92 {
94 QVector3D normal;
96 QVector3D tangent;
97 QVector3D binormal;
98 float size = 0.0f;
99 float length = 0.0f;
100 };
101 struct FadeOutLineData
102 {
103 int emitterIndex;
104 SpriteParticleData endPoint;
105 LineDataHeader header;
106 QVector<LineData> lineData;
107 float beginTime;
108 float endTime;
109 float timeFactor;
110 };
111
113
114 class LineParticleUpdateNode : public ParticleUpdateNode
115 {
116 public:
117 LineParticleUpdateNode(QQuick3DNode *parent = nullptr)
118 : ParticleUpdateNode(parent)
119 {
120 }
121 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
122 };
123
124 void updateLineBuffer(LineParticleUpdateNode *updateNode, QSSGRenderGraphObject *node);
125 QSSGRenderGraphObject *updateLineNode(QSSGRenderGraphObject *node);
126 void handleSegmentCountChanged();
127 void updateLineSegment(int particleIndex);
128 void clearSegment(int particleIndex);
129 void handleMaxAmountChanged(int amount) override;
130 void handleSystemChanged(QQuick3DParticleSystem *system) override;
131 void reset() override;
132 void commitParticles(float time) override;
133 int nextCurrentIndex(const QQuick3DParticleEmitter *emitter) override;
134 void saveLineSegment(int particleIndex, float time);
135 void setParticleData(int particleIndex,
136 const QVector3D &position,
137 const QVector3D &rotation,
138 const QVector4D &color,
139 float size, float age,
140 float animationFrame) override;
141 void resetParticleData(int particleIndex) override;
142
143 QVector<LineDataHeader> m_lineHeaderData;
144 QVector<LineData> m_lineData;
145 QVector<FadeOutLineData> m_fadeOutData;
146
147 float m_alphaFade = 0.0f;
148 float m_scaleMultiplier = 1.0f;
149 float m_texcoordMultiplier = 1.0f;
150 float m_lengthDeltaMin = 10.0f;
151 float m_length = -1.0f;
152 float m_lengthVariation = 0.0f;
153 int m_segmentCount = 1;
154 int m_eolFadeOutDuration = 0;
155 TexcoordMode m_texcoordMode = TexcoordMode::Absolute;
156};
157
159
160#endif
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
The QVector4D class represents a vector or vertex in 4D space.
Definition qvectornd.h:330
Combined button and popup list for selecting options.
static QString header(const QString &name)
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLuint color
[2]
GLboolean reset
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static int segmentCount(const QPainterPath &path, qreal pathLength)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS