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
qquick3dgeometry.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 Q_QUICK3D_GEOMETRY_H
7#define Q_QUICK3D_GEOMETRY_H
8
9#include <QtQuick3D/qquick3dobject.h>
10
11QT_BEGIN_NAMESPACE
12
13class QQuick3DGeometryPrivate;
14
15class Q_QUICK3D_EXPORT QQuick3DGeometry : public QQuick3DObject
16{
17 Q_OBJECT
18 Q_DECLARE_PRIVATE(QQuick3DGeometry)
19
20 QML_NAMED_ELEMENT(Geometry)
21 QML_UNCREATABLE("Geometry is Abstract")
22public:
23 explicit QQuick3DGeometry(QQuick3DObject *parent = nullptr);
24 ~QQuick3DGeometry() override;
25
26 enum class PrimitiveType {
27 Points,
28 LineStrip,
29 Lines,
30 TriangleStrip,
31 TriangleFan,
32 Triangles
33 };
34 Q_ENUM(PrimitiveType)
35
36 struct Attribute {
37 enum Semantic {
38 IndexSemantic,
39 PositionSemantic, // attr_pos
40 NormalSemantic, // attr_norm
41 TexCoordSemantic, // attr_uv0
42 TangentSemantic, // attr_textan
43 BinormalSemantic, // attr_binormal
44 JointSemantic, // attr_joints
45 WeightSemantic, // attr_weights
46 ColorSemantic, // attr_color
47 TargetPositionSemantic, // attr_tpos0
48 TargetNormalSemantic, // attr_tnorm0
49 TargetTangentSemantic, // attr_ttan0
50 TargetBinormalSemantic, // attr_tbinorm0
51 TexCoord1Semantic, // attr_uv1
52 TexCoord0Semantic = TexCoordSemantic // for compatibility
53 };
54 enum ComponentType {
55 U16Type,
56 U32Type,
57 I32Type,
58 F32Type
59 };
60 Semantic semantic = PositionSemantic;
61 int offset = -1;
62 ComponentType componentType = F32Type;
63 };
64
65 struct TargetAttribute {
66 quint32 targetId = 0;
67 Attribute attr;
68 int stride = 0;
69 };
70
71 QByteArray vertexData() const;
72 QByteArray indexData() const;
73 int attributeCount() const;
74 Attribute attribute(int index) const;
75 PrimitiveType primitiveType() const;
76 QVector3D boundsMin() const;
77 QVector3D boundsMax() const;
78 int stride() const;
79
80 void setVertexData(const QByteArray &data);
81 void setVertexData(int offset, const QByteArray &data);
82 void setIndexData(const QByteArray &data);
83 void setIndexData(int offset, const QByteArray &data);
84 void setStride(int stride);
85 void setBounds(const QVector3D &min, const QVector3D &max);
86 void setPrimitiveType(PrimitiveType type);
87
88 void addAttribute(Attribute::Semantic semantic, int offset,
89 Attribute::ComponentType componentType);
90 void addAttribute(const Attribute &att);
91
92 Q_REVISION(6, 3) int subsetCount() const;
93 Q_REVISION(6, 3) QVector3D subsetBoundsMin(int subset) const;
94 Q_REVISION(6, 3) QVector3D subsetBoundsMax(int subset) const;
95 Q_REVISION(6, 3) int subsetOffset(int subset) const;
96 Q_REVISION(6, 3) int subsetCount(int subset) const;
97 Q_REVISION(6, 3) QString subsetName(int subset) const;
98 Q_REVISION(6, 3) void addSubset(int offset, int count, const QVector3D &boundsMin, const QVector3D &boundsMax, const QString &name = {});
99
100 Q_REVISION(6, 6) QByteArray targetData() const;
101 Q_REVISION(6, 6) void setTargetData(const QByteArray &data);
102 Q_REVISION(6, 6) void setTargetData(int offset, const QByteArray &data);
103 Q_REVISION(6, 6) TargetAttribute targetAttribute(int index) const;
104 Q_REVISION(6, 6) int targetAttributeCount() const;
105 Q_REVISION(6, 6) void addTargetAttribute(quint32 targetId,
106 Attribute::Semantic semantic, int offset,
107 int stride = 0);
108 Q_REVISION(6, 6) void addTargetAttribute(const TargetAttribute &att);
109
110 void clear();
111
112Q_SIGNALS:
113 void geometryNodeDirty();
114 Q_REVISION(6, 7) void geometryChanged();
115
116protected:
117 explicit QQuick3DGeometry(QQuick3DGeometryPrivate &dd, QQuick3DObject *parent = nullptr);
118 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
119 void markAllDirty() override;
120};
121
122QT_END_NAMESPACE
123
124#endif // Q_QUICK3D_GEOMETRY_H
\qmltype Geometry \inherits Object3D \inqmlmodule QtQuick3D \nativetype QQuick3DGeometry