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
qquick3dparticleshape_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 QQUICK3DPARTICLESHAPE_H
5#define QQUICK3DPARTICLESHAPE_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 QQuick3DParticleSystem;
24class QQuick3DModel;
25
26class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleShape : public QQuick3DParticleAbstractShape
27{
28 Q_OBJECT
29 Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
30 Q_PROPERTY(ShapeType type READ type WRITE setType NOTIFY typeChanged)
31 Q_PROPERTY(QVector3D extents READ extents WRITE setExtents NOTIFY extentsChanged)
32
33 QML_NAMED_ELEMENT(ParticleShape3D)
34 QML_ADDED_IN_VERSION(6, 2)
35
36public:
37 enum ShapeType
38 {
39 Cube = 0,
40 Sphere,
41 Cylinder
42 };
43 Q_ENUM(ShapeType)
44
45 QQuick3DParticleShape(QObject *parent = nullptr);
46
47 bool fill() const;
48 ShapeType type() const;
49 QVector3D extents() const;
50
51 // Returns point inside this shape
52 QVector3D getPosition(int particleIndex) override;
53 Q_REVISION(6, 10) QVector3D getSurfaceNormal(int particleIndex) override;
54
55public Q_SLOTS:
56 void setFill(bool fill);
57 void setType(QQuick3DParticleShape::ShapeType type);
58 void setExtents(QVector3D extends);
59
60Q_SIGNALS:
61 void fillChanged();
62 void typeChanged();
63 void extentsChanged();
64
65private:
66 QVector3D randomPositionCube(int particleIndex) const;
67 QVector3D randomPositionSphere(int particleIndex) const;
68 QVector3D randomPositionCylinder(int particleIndex) const;
69
70 bool m_fill = true;
71 ShapeType m_type = ShapeType::Cube;
72 QVector3D m_extents = QVector3D(50, 50, 50);
73 QVector3D m_cachedPosition;
74 int m_cachedIndex = -1;
75};
76
77QT_END_NAMESPACE
78
79#endif // QQUICK3DPARTICLESHAPE_H
#define M_PI
Definition qmath.h:200
#define QPSIN
#define QPCOS