1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the Qt3D module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QT3DRENDER_QGEOMETRYRENDERER_H 41 #define QT3DRENDER_QGEOMETRYRENDERER_H 42 43 #include <Qt3DCore/qcomponent.h> 44 #include <Qt3DRender/qgeometry.h> 45 #include <Qt3DRender/qt3drender_global.h> 46 47 QT_BEGIN_NAMESPACE 48 49 namespace Qt3DRender { 50 51 class QGeometryRendererPrivate; 52 class QGeometryFactory; 53 54 typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr; 55 56 class Q_3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent 57 { 58 Q_OBJECT 59 Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged) 60 Q_PROPERTY(int vertexCount READ vertexCount WRITE setVertexCount NOTIFY vertexCountChanged) 61 Q_PROPERTY(int indexOffset READ indexOffset WRITE setIndexOffset NOTIFY indexOffsetChanged) 62 Q_PROPERTY(int firstInstance READ firstInstance WRITE setFirstInstance NOTIFY firstInstanceChanged) 63 Q_PROPERTY(int firstVertex READ firstVertex WRITE setFirstVertex NOTIFY firstVertexChanged) 64 Q_PROPERTY(int indexBufferByteOffset READ indexBufferByteOffset WRITE setIndexBufferByteOffset NOTIFY indexBufferByteOffsetChanged) 65 Q_PROPERTY(int restartIndexValue READ restartIndexValue WRITE setRestartIndexValue NOTIFY restartIndexValueChanged) 66 Q_PROPERTY(int verticesPerPatch READ verticesPerPatch WRITE setVerticesPerPatch NOTIFY verticesPerPatchChanged) 67 Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged) 68 Q_PROPERTY(Qt3DRender::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) 69 Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged) 70 71 public: 72 explicit QGeometryRenderer(Qt3DCore::QNode *parent = nullptr); 73 ~QGeometryRenderer(); 74 75 enum PrimitiveType { 76 Points = 0x0000, 77 Lines = 0x0001, 78 LineLoop = 0x0002, 79 LineStrip = 0x0003, 80 Triangles = 0x0004, 81 TriangleStrip = 0x0005, 82 TriangleFan = 0x0006, 83 LinesAdjacency = 0x000A, 84 TrianglesAdjacency = 0x000C, 85 LineStripAdjacency = 0x000B, 86 TriangleStripAdjacency = 0x000D, 87 Patches = 0x000E 88 }; 89 Q_ENUM(PrimitiveType) // LCOV_EXCL_LINE 90 91 // how to figure out index count and all the fancy stuff that QMeshData provides for us? 92 // also how to figure out which attribute(s?) hold the indices? 93 94 int instanceCount() const; 95 int vertexCount() const; 96 int indexOffset() const; 97 int firstInstance() const; 98 int firstVertex() const; 99 int indexBufferByteOffset() const; 100 int restartIndexValue() const; 101 int verticesPerPatch() const; 102 bool primitiveRestartEnabled() const; 103 QGeometry *geometry() const; 104 PrimitiveType primitiveType() const; 105 106 Q3D_DECL_DEPRECATED QGeometryFactoryPtr geometryFactory() const; 107 Q3D_DECL_DEPRECATED void setGeometryFactory(const QGeometryFactoryPtr &factory); 108 109 public Q_SLOTS: 110 void setInstanceCount(int instanceCount); 111 void setVertexCount(int vertexCount); 112 void setIndexOffset(int indexOffset); 113 void setFirstInstance(int firstInstance); 114 void setFirstVertex(int firstVertex); 115 void setIndexBufferByteOffset(int offset); 116 void setRestartIndexValue(int index); 117 void setVerticesPerPatch(int verticesPerPatch); 118 void setPrimitiveRestartEnabled(bool enabled); 119 void setGeometry(QGeometry *geometry); 120 void setPrimitiveType(PrimitiveType primitiveType); 121 122 Q_SIGNALS: 123 void instanceCountChanged(int instanceCount); 124 void vertexCountChanged(int vertexCount); 125 void indexOffsetChanged(int indexOffset); 126 void firstInstanceChanged(int firstInstance); 127 void firstVertexChanged(int firstVertex); 128 void indexBufferByteOffsetChanged(int offset); 129 void restartIndexValueChanged(int restartIndexValue); 130 void verticesPerPatchChanged(int verticesPerPatch); 131 void primitiveRestartEnabledChanged(bool primitiveRestartEnabled); 132 void geometryChanged(QGeometry *geometry); 133 void primitiveTypeChanged(PrimitiveType primitiveType); 134 135 protected: 136 explicit QGeometryRenderer(QGeometryRendererPrivate &dd, Qt3DCore::QNode *parent = nullptr); 137 // TODO Unused remove in Qt6 138 void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override; 139 140 private: 141 Q_DECLARE_PRIVATE(QGeometryRenderer) 142 Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override; 143 }; 144 145 } // namespace Qt3DRender 146 147 QT_END_NAMESPACE 148 149 #endif // QT3DRENDER_QGEOMETRYRENDERER_H 150