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
qquick3dparticlemodelblendparticle_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QQUICK3DMODELBLENDPARTICLE_H
7#define QQUICK3DMODELBLENDPARTICLE_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 <QColor>
21#include <QVector4D>
22#include <QMatrix4x4>
23
24#include <QtQuick3DParticles/private/qquick3dparticle_p.h>
25#include <QtQuick3DParticles/private/qquick3dparticlesystem_p.h>
26#include <QtQuick3DParticles/private/qquick3dparticledata_p.h>
27#include <QtQuick3D/private/qquick3dmodel_p.h>
28#include <QtQuick3D/private/qquick3dgeometry_p.h>
29
31
32struct QSSGParticleBuffer;
33class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleModelBlendParticle : public QQuick3DParticle
34{
35 Q_OBJECT
36 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
37 Q_PROPERTY(QQuick3DNode *endNode READ endNode WRITE setEndNode NOTIFY endNodeChanged)
38 Q_PROPERTY(ModelBlendMode modelBlendMode READ modelBlendMode WRITE setModelBlendMode NOTIFY modelBlendModeChanged)
39 Q_PROPERTY(int endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
40 Q_PROPERTY(QQuick3DNode *activationNode READ activationNode WRITE setActivationNode NOTIFY activationNodeChanged)
41 Q_PROPERTY(ModelBlendEmitMode emitMode READ emitMode WRITE setEmitMode NOTIFY emitModeChanged)
42 QML_NAMED_ELEMENT(ModelBlendParticle3D)
43 QML_ADDED_IN_VERSION(6, 2)
44
45public:
46 QQuick3DParticleModelBlendParticle(QQuick3DNode *parent = nullptr);
47 ~QQuick3DParticleModelBlendParticle() override;
48
49 enum ModelBlendMode
50 {
51 Explode,
52 Construct,
53 Transfer
54 };
55 Q_ENUM(ModelBlendMode)
56
57 enum ModelBlendEmitMode
58 {
59 Sequential,
60 Random,
61 Activation
62 };
63 Q_ENUM(ModelBlendEmitMode)
64
65 QQmlComponent *delegate() const;
66 QQuick3DNode *endNode() const;
67 ModelBlendMode modelBlendMode() const;
68 int endTime() const;
69 QQuick3DNode *activationNode() const;
70 ModelBlendEmitMode emitMode() const;
71
72public Q_SLOTS:
73 void setDelegate(QQmlComponent *setDelegate);
74 void setEndNode(QQuick3DNode *endNode);
75 void setEndTime(int endTime);
76 void setModelBlendMode(ModelBlendMode mode);
77 void setActivationNode(QQuick3DNode *activationNode);
78 void setEmitMode(ModelBlendEmitMode emitMode);
79
80Q_SIGNALS:
81 void delegateChanged();
82 void blendFactorChanged();
83 void endNodeChanged();
84 void modelBlendModeChanged();
85 void endTimeChanged();
86 void activationNodeChanged();
87 void emitModeChanged();
88
89protected:
90 void itemChange(ItemChange, const ItemChangeData &) override;
91 void reset() override;
92 bool lastParticle() const;
93 void doSetMaxAmount(int amount) override;
94 void componentComplete() override;
95 int nextCurrentIndex(const QQuick3DParticleEmitter *emitter) override;
96 void setParticleData(int particleIndex,
97 const QVector3D &position,
98 const QVector3D &rotation,
99 const QVector4D &color,
100 float size, float age);
101 QVector3D particleCenter(int particleIndex) const;
102 QVector3D particleEndPosition(int particleIndex) const;
103 QVector3D particleEndRotation(int particleIndex) const;
104 int randomIndex(int particleIndex);
105 void commitParticles()
106 {
107 markAllDirty();
108 update();
109 }
110
111private:
112 friend class QQuick3DParticleSystem;
113 friend class QQuick3DParticleEmitter;
114
115 struct TriangleParticleData
116 {
117 QVector3D position;
118 QVector3D rotation;
119 QVector3D center;
120 QVector4D color;
121 float age = 0.0f;
122 float size = 1.0f;
123 int emitterIndex = -1;
124 };
125
126 struct PerEmitterData
127 {
128 int particleCount = 0;
129 int emitterIndex = -1;
130 const QQuick3DParticleEmitter *emitter = nullptr;
131 };
132
133 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
134 void updateParticleBuffer(QSSGParticleBuffer *buffer, const QMatrix4x4 &sceneTransform);
135 void regenerate();
136 void updateParticles();
137 void handleEndNodeChanged();
138 PerEmitterData &perEmitterData(int emitterIndex);
139
140 QVector<TriangleParticleData> m_triangleParticleData;
141 QVector<QVector3D> m_centerData;
142 QHash<QByteArray, QMetaObject::Connection> m_connections;
143 QMap<const QQuick3DParticleEmitter *, PerEmitterData> m_perEmitterData;
144 QVector<int> m_randomParticles;
145 PerEmitterData n_noPerEmitterData;
146 int m_nextEmitterIndex = 0;
147 QQmlComponent *m_delegate = nullptr;
148 QQuick3DModel *m_model = nullptr;
149 QQuick3DGeometry *m_modelGeometry = nullptr;
150 QQuick3DNode *m_endNode = nullptr;
151 QVector3D m_endNodePosition;
152 QVector3D m_endNodeRotation;
153 QVector3D m_endNodeScale;
154 QMatrix4x4 m_endRotationMatrix;
155 int m_particleCount = 0;
156 ModelBlendMode m_modelBlendMode = Explode;
157 int m_endTime = 0;
158 bool m_dataChanged = true;
159 ModelBlendEmitMode m_emitMode = Sequential;
160 QQuick3DNode *m_activationNode = nullptr;
161 float m_maxTriangleRadius = 0.f;
162};
163
164QT_END_NAMESPACE
165
166#endif
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:27
Combined button and popup list for selecting options.
static QVector3D reflect(const QVector3D &I, QVector3D &N)
static QMatrix4x4 rotationFromNormal(const QVector3D &n)