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
proceduralmesh_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#ifndef PROCEDURALMESH_H
18#define PROCEDURALMESH_H
19
20#include <QtQuick3DHelpers/qtquick3dhelpersexports.h>
21#include <QQuick3DGeometry>
22#include <QQmlEngine>
23#include <QList>
24#include <QVector3D>
25
27
29 Q_OBJECT
30 Q_PROPERTY(unsigned int offset READ offset WRITE setOffset NOTIFY offsetChanged FINAL)
31 Q_PROPERTY(unsigned int count READ count WRITE setCount NOTIFY countChanged FINAL)
32 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
33 QML_NAMED_ELEMENT(ProceduralMeshSubset)
34 QML_ADDED_IN_VERSION(6, 6)
35
36public:
37 int offset() const;
38 void setOffset(int newOffset);
39
40 int count() const;
41 void setCount(int newCount);
42
43 QString name() const;
44 void setName(const QString &newName);
45Q_SIGNALS:
46 void offsetChanged();
47 void countChanged();
48 void nameChanged();
49 void isDirty();
50
51private:
52 int m_offset = 0;
53 int m_count = 0;
54 QString m_name;
55};
56
57class Q_QUICK3DHELPERS_EXPORT ProceduralMesh : public QQuick3DGeometry
58{
59 Q_OBJECT
60 Q_PROPERTY(QList<QVector3D> positions READ positions WRITE setPositions NOTIFY positionsChanged FINAL)
61 Q_PROPERTY(QList<QVector3D> normals READ normals WRITE setNormals NOTIFY normalsChanged FINAL)
62 Q_PROPERTY(QList<QVector3D> tangents READ tangents WRITE setTangents NOTIFY tangentsChanged FINAL)
63 Q_PROPERTY(QList<QVector3D> binormals READ binormals WRITE setBinormals NOTIFY binormalsChanged FINAL)
64 Q_PROPERTY(QList<QVector2D> uv0s READ uv0s WRITE setUv0s NOTIFY uv0sChanged FINAL)
65 Q_PROPERTY(QList<QVector2D> uv1s READ uv1s WRITE setUv1s NOTIFY uv1sChanged FINAL)
66 Q_PROPERTY(QList<QVector4D> colors READ colors WRITE setColors NOTIFY colorsChanged FINAL)
67 Q_PROPERTY(QList<QVector4D> joints READ joints WRITE setJoints NOTIFY jointsChanged FINAL)
68 Q_PROPERTY(QList<QVector4D> weights READ weights WRITE setWeights NOTIFY weightsChanged FINAL)
69 Q_PROPERTY(QList<unsigned int> indexes READ indexes WRITE setIndexes NOTIFY indexesChanged FINAL)
70 Q_PROPERTY(QQmlListProperty<ProceduralMeshSubset> subsets READ subsets FINAL)
71 Q_PROPERTY(PrimitiveMode primitiveMode READ primitiveMode WRITE setPrimitiveMode NOTIFY primitiveModeChanged FINAL)
72 QML_ELEMENT
73 QML_ADDED_IN_VERSION(6, 6)
74public:
75 enum PrimitiveMode {
76 Points,
77 LineStrip,
78 Lines,
79 TriangleStrip,
80 TriangleFan,
81 Triangles
82 };
83 Q_ENUM(PrimitiveMode)
84
85 ProceduralMesh();
86 QList<QVector3D> positions() const;
87 void setPositions(const QList<QVector3D> &newPositions);
88 PrimitiveMode primitiveMode() const;
89 void setPrimitiveMode(PrimitiveMode newPrimitiveMode);
90
91 QList<unsigned int> indexes() const;
92 void setIndexes(const QList<unsigned int> &newIndexes);
93
94 QList<QVector3D> normals() const;
95 void setNormals(const QList<QVector3D> &newNormals);
96
97 QList<QVector3D> tangents() const;
98 void setTangents(const QList<QVector3D> &newTangents);
99
100 QList<QVector3D> binormals() const;
101 void setBinormals(const QList<QVector3D> &newBinormals);
102
103 QList<QVector2D> uv0s() const;
104 void setUv0s(const QList<QVector2D> &newUv0s);
105
106 QList<QVector2D> uv1s() const;
107 void setUv1s(const QList<QVector2D> &newUv1s);
108
109 QList<QVector4D> colors() const;
110 void setColors(const QList<QVector4D> &newColors);
111
112 QList<QVector4D> joints() const;
113 void setJoints(const QList<QVector4D> &newJoints);
114
115 QList<QVector4D> weights() const;
116 void setWeights(const QList<QVector4D> &newWeights);
117
118 QQmlListProperty<ProceduralMeshSubset> subsets();
119
120Q_SIGNALS:
121 void positionsChanged();
122 void primitiveModeChanged();
123 void indexesChanged();
124 void normalsChanged();
125 void tangentsChanged();
126 void binormalsChanged();
127 void uv0sChanged();
128 void uv1sChanged();
129 void colorsChanged();
130 void jointsChanged();
131 void weightsChanged();
132
133private Q_SLOTS:
134 void requestUpdate();
135 void updateGeometry();
136 void subsetDestroyed(QObject *subset);
137
138private:
139 bool supportsTriangleFanPrimitive() const;
140
141 static void qmlAppendProceduralMeshSubset(QQmlListProperty<ProceduralMeshSubset> *list, ProceduralMeshSubset *subset);
142 static ProceduralMeshSubset *qmlProceduralMeshSubsetAt(QQmlListProperty<ProceduralMeshSubset> *list, qsizetype index);
143 static qsizetype qmlProceduralMeshSubsetCount(QQmlListProperty<ProceduralMeshSubset> *list);
144 static void qmlClearProceduralMeshSubset(QQmlListProperty<ProceduralMeshSubset> *list);
145
146 bool m_updateRequested = false;
147 PrimitiveMode m_primitiveMode = Triangles;
148 QList<QVector3D> m_positions;
149 QList<unsigned int> m_indexes;
150 QList<QVector3D> m_normals;
151 QList<QVector3D> m_tangents;
152 QList<QVector3D> m_binormals;
153 QList<QVector2D> m_uv0s;
154 QList<QVector2D> m_uv1s;
155 QList<QVector4D> m_colors;
156 QList<QVector4D> m_joints;
157 QList<QVector4D> m_weights;
158 QList<ProceduralMeshSubset *> m_subsets;
159};
160
161QT_END_NAMESPACE
162
163#endif // PROCEDURALMESH_H
Combined button and popup list for selecting options.