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