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
qquick3dparticlemodelshape_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
4#ifndef QQUICK3DPARTICLEMODELSHAPE_H
5#define QQUICK3DPARTICLEMODELSHAPE_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
19#include <QVector3D>
20
22
23class QQuick3DModel;
24class QQmlComponent;
25
26class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleModelShape : public QQuick3DParticleAbstractShape
27{
28 Q_OBJECT
29 Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
30 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
31 QML_NAMED_ELEMENT(ParticleModelShape3D)
32 QML_ADDED_IN_VERSION(6, 2)
33
34public:
35 QQuick3DParticleModelShape(QObject *parent = nullptr);
36 ~QQuick3DParticleModelShape() override;
37
38 bool fill() const;
39 QQmlComponent *delegate() const;
40
41public Q_SLOTS:
42 void setFill(bool fill);
43 void setDelegate(QQmlComponent *delegate);
44
45 // Returns point inside this shape
46 QVector3D getPosition(int particleIndex) override;
47 QVector3D getSurfaceNormal(int particleIndex) override;
48
49Q_SIGNALS:
50 void fillChanged();
51 void delegateChanged();
52
53private:
54 QVector3D randomPositionModel(int particleIndex);
55 void createModel();
56 void clearModelVertexPositions();
57 void calculateModelVertexPositions();
58
59 QQmlComponent *m_delegate = nullptr;
60 QQuick3DModel *m_model = nullptr;
61 QVector<QVector3D> m_vertexPositions;
62 float m_modelTriangleAreasSum = 0;
63 QVector<float> m_modelTriangleAreas;
64 QVector3D m_modelTriangleCenter;
65 QVector3D m_cachedNormal;
66 int m_cachedIndex = -1;
67 bool m_fill = true;
68};
69
70QT_END_NAMESPACE
71
72#endif // QQUICK3DPARTICLEMODELSHAPE_H
static QSSGMesh::Mesh loadModelShapeMesh(const QString &source)