qgeometryrenderer.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. #ifndef QT3DRENDER_QGEOMETRYRENDERER_H
  40. #define QT3DRENDER_QGEOMETRYRENDERER_H
  41. #include <Qt3DCore/qcomponent.h>
  42. #include <Qt3DRender/qgeometry.h>
  43. #include <Qt3DRender/qt3drender_global.h>
  44. QT_BEGIN_NAMESPACE
  45. namespace Qt3DRender {
  46. class QGeometryRendererPrivate;
  47. class QGeometryFactory;
  48. typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr;
  49. class QT3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent
  50. {
  51. Q_OBJECT
  52. Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged)
  53. Q_PROPERTY(int vertexCount READ vertexCount WRITE setVertexCount NOTIFY vertexCountChanged)
  54. Q_PROPERTY(int indexOffset READ indexOffset WRITE setIndexOffset NOTIFY indexOffsetChanged)
  55. Q_PROPERTY(int firstInstance READ firstInstance WRITE setFirstInstance NOTIFY firstInstanceChanged)
  56. Q_PROPERTY(int firstVertex READ firstVertex WRITE setFirstVertex NOTIFY firstVertexChanged)
  57. Q_PROPERTY(int restartIndexValue READ restartIndexValue WRITE setRestartIndexValue NOTIFY restartIndexValueChanged)
  58. Q_PROPERTY(int verticesPerPatch READ verticesPerPatch WRITE setVerticesPerPatch NOTIFY verticesPerPatchChanged)
  59. Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged)
  60. Q_PROPERTY(Qt3DRender::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
  61. Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged)
  62. public:
  63. explicit QGeometryRenderer(Qt3DCore::QNode *parent = nullptr);
  64. ~QGeometryRenderer();
  65. enum PrimitiveType {
  66. Points = 0x0000,
  67. Lines = 0x0001,
  68. LineLoop = 0x0002,
  69. LineStrip = 0x0003,
  70. Triangles = 0x0004,
  71. TriangleStrip = 0x0005,
  72. TriangleFan = 0x0006,
  73. LinesAdjacency = 0x000A,
  74. TrianglesAdjacency = 0x000C,
  75. LineStripAdjacency = 0x000B,
  76. TriangleStripAdjacency = 0x000D,
  77. Patches = 0x000E
  78. };
  79. Q_ENUM(PrimitiveType)
  80. // how to figure out index count and all the fancy stuff that QMeshData provides for us?
  81. // also how to figure out which attribute(s?) hold the indices?
  82. int instanceCount() const;
  83. int vertexCount() const;
  84. int indexOffset() const;
  85. int firstInstance() const;
  86. int firstVertex() const;
  87. int restartIndexValue() const;
  88. int verticesPerPatch() const;
  89. bool primitiveRestartEnabled() const;
  90. QGeometry *geometry() const;
  91. PrimitiveType primitiveType() const;
  92. QGeometryFactoryPtr geometryFactory() const;
  93. void setGeometryFactory(const QGeometryFactoryPtr &factory);
  94. public Q_SLOTS:
  95. void setInstanceCount(int instanceCount);
  96. void setVertexCount(int vertexCount);
  97. void setIndexOffset(int indexOffset);
  98. void setFirstInstance(int firstInstance);
  99. void setFirstVertex(int firstVertex);
  100. void setRestartIndexValue(int index);
  101. void setVerticesPerPatch(int verticesPerPatch);
  102. void setPrimitiveRestartEnabled(bool enabled);
  103. void setGeometry(QGeometry *geometry);
  104. void setPrimitiveType(PrimitiveType primitiveType);
  105. Q_SIGNALS:
  106. void instanceCountChanged(int instanceCount);
  107. void vertexCountChanged(int vertexCount);
  108. void indexOffsetChanged(int indexOffset);
  109. void firstInstanceChanged(int firstInstance);
  110. void firstVertexChanged(int firstVertex);
  111. void restartIndexValueChanged(int restartIndexValue);
  112. void verticesPerPatchChanged(int verticesPerPatch);
  113. void primitiveRestartEnabledChanged(bool primitiveRestartEnabled);
  114. void geometryChanged(QGeometry *geometry);
  115. void primitiveTypeChanged(PrimitiveType primitiveType);
  116. protected:
  117. explicit QGeometryRenderer(QGeometryRendererPrivate &dd, Qt3DCore::QNode *parent = nullptr);
  118. void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
  119. private:
  120. Q_DECLARE_PRIVATE(QGeometryRenderer)
  121. Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE;
  122. };
  123. } // namespace Qt3DRender
  124. QT_END_NAMESPACE
  125. #endif // QT3DRENDER_QGEOMETRYRENDERER_H