1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QSSG_RENDER_GEOMETRY_H |
5 | #define QSSG_RENDER_GEOMETRY_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 | |
18 | #include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h> |
19 | #include <QtQuick3DRuntimeRender/private/qssgrendernode_p.h> |
20 | #include <QtQuick3DRuntimeRender/private/qssgrendermesh_p.h> |
21 | #include <QtQuick3DRuntimeRender/private/qssgrendererutil_p.h> |
22 | #include <QtQuick3DUtils/private/qssgmesh_p.h> |
23 | |
24 | #include <QtCore/qbytearray.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderGeometry : public QSSGRenderGraphObject |
29 | { |
30 | public: |
31 | struct Attribute { |
32 | QSSGMesh::RuntimeMeshData::Attribute::Semantic semantic = QSSGMesh::RuntimeMeshData::Attribute::PositionSemantic; |
33 | int offset = -1; |
34 | QSSGMesh::Mesh::ComponentType componentType = QSSGMesh::Mesh::ComponentType::Float32; |
35 | }; |
36 | struct TargetAttribute { |
37 | quint32 targetId = 0; |
38 | Attribute attr; |
39 | int stride = 0; |
40 | }; |
41 | |
42 | explicit QSSGRenderGeometry(); |
43 | virtual ~QSSGRenderGeometry(); |
44 | |
45 | const QByteArray &vertexBuffer() const; |
46 | QByteArray &vertexBuffer(); |
47 | const QByteArray &indexBuffer() const; |
48 | QByteArray &indexBuffer(); |
49 | int attributeCount() const; |
50 | Attribute attribute(int idx) const; |
51 | QSSGMesh::Mesh::DrawMode primitiveType() const; |
52 | QVector3D boundsMin() const; |
53 | QVector3D boundsMax() const; |
54 | int stride() const; |
55 | int targetStride() const; |
56 | |
57 | void setVertexData(const QByteArray &data); |
58 | void setIndexData(const QByteArray &data); |
59 | void setStride(int stride); |
60 | void setBounds(const QVector3D &min, const QVector3D &max); |
61 | void setPrimitiveType(QSSGMesh::Mesh::DrawMode type); |
62 | |
63 | void addAttribute(QSSGMesh::RuntimeMeshData::Attribute::Semantic semantic, |
64 | int offset, |
65 | QSSGMesh::Mesh::ComponentType componentType); |
66 | void addAttribute(const Attribute &att); |
67 | void addSubset(quint32 offset, quint32 count, const QVector3D &boundsMin, const QVector3D &boundsMax, const QString &name = {}); |
68 | |
69 | void clear(); |
70 | void clearAttributes(); |
71 | |
72 | uint32_t generationId() const; |
73 | const QSSGMesh::RuntimeMeshData &meshData() const; |
74 | |
75 | QString debugObjectName; |
76 | |
77 | void clearVertexAndIndex(); |
78 | void clearTarget(); |
79 | void setTargetData(const QByteArray &data); |
80 | void addTargetAttribute(quint32 targetId, |
81 | QSSGMesh::RuntimeMeshData::Attribute::Semantic semantic, |
82 | int offset, |
83 | int stride = 0); |
84 | void addTargetAttribute(const TargetAttribute &att); |
85 | |
86 | protected: |
87 | Q_DISABLE_COPY(QSSGRenderGeometry) |
88 | |
89 | void markDirty(); |
90 | |
91 | uint32_t m_generationId = 1; |
92 | QSSGMesh::RuntimeMeshData m_meshData; |
93 | QSSGBounds3 m_bounds; |
94 | }; |
95 | |
96 | QT_END_NAMESPACE |
97 | |
98 | #endif // QSSG_GEOMETRY_H |
99 | |