| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2014 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_QATTRIBUTE_H |
| 41 | #define QT3DRENDER_QATTRIBUTE_H |
| 42 | |
| 43 | #include <Qt3DRender/qt3drender_global.h> |
| 44 | #include <Qt3DCore/qnode.h> |
| 45 | #include <QtCore/QSharedPointer> |
| 46 | |
| 47 | QT_BEGIN_NAMESPACE |
| 48 | |
| 49 | namespace Qt3DRender { |
| 50 | |
| 51 | class QBuffer; |
| 52 | class QAttributePrivate; |
| 53 | |
| 54 | typedef QSharedPointer<QBuffer> QBufferPtr; |
| 55 | |
| 56 | class Q_3DRENDERSHARED_EXPORT QAttribute : public Qt3DCore::QNode |
| 57 | { |
| 58 | Q_OBJECT |
| 59 | Q_PROPERTY(Qt3DRender::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged) |
| 60 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
| 61 | Q_PROPERTY(VertexBaseType vertexBaseType READ vertexBaseType WRITE setVertexBaseType NOTIFY vertexBaseTypeChanged) |
| 62 | Q_PROPERTY(uint vertexSize READ vertexSize WRITE setVertexSize NOTIFY vertexSizeChanged) |
| 63 | Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged) |
| 64 | Q_PROPERTY(uint byteStride READ byteStride WRITE setByteStride NOTIFY byteStrideChanged) |
| 65 | Q_PROPERTY(uint byteOffset READ byteOffset WRITE setByteOffset NOTIFY byteOffsetChanged) |
| 66 | Q_PROPERTY(uint divisor READ divisor WRITE setDivisor NOTIFY divisorChanged) |
| 67 | Q_PROPERTY(AttributeType attributeType READ attributeType WRITE setAttributeType NOTIFY attributeTypeChanged) |
| 68 | Q_PROPERTY(QString defaultPositionAttributeName READ defaultPositionAttributeName CONSTANT) |
| 69 | Q_PROPERTY(QString defaultNormalAttributeName READ defaultNormalAttributeName CONSTANT) |
| 70 | Q_PROPERTY(QString defaultColorAttributeName READ defaultColorAttributeName CONSTANT) |
| 71 | Q_PROPERTY(QString defaultTextureCoordinateAttributeName READ defaultTextureCoordinateAttributeName CONSTANT) |
| 72 | Q_PROPERTY(QString defaultTextureCoordinate1AttributeName READ defaultTextureCoordinate1AttributeName CONSTANT REVISION 11) |
| 73 | Q_PROPERTY(QString defaultTextureCoordinate2AttributeName READ defaultTextureCoordinate2AttributeName CONSTANT REVISION 11) |
| 74 | Q_PROPERTY(QString defaultTangentAttributeName READ defaultTangentAttributeName CONSTANT) |
| 75 | Q_PROPERTY(QString defaultJointIndicesAttributeName READ defaultJointIndicesAttributeName CONSTANT REVISION 10) |
| 76 | Q_PROPERTY(QString defaultJointWeightsAttributeName READ defaultJointWeightsAttributeName CONSTANT REVISION 10) |
| 77 | |
| 78 | public: |
| 79 | enum AttributeType { |
| 80 | VertexAttribute, |
| 81 | IndexAttribute, |
| 82 | DrawIndirectAttribute |
| 83 | }; |
| 84 | |
| 85 | Q_ENUM(AttributeType) // LCOV_EXCL_LINE |
| 86 | |
| 87 | enum VertexBaseType { |
| 88 | Byte = 0, |
| 89 | UnsignedByte, |
| 90 | Short, |
| 91 | UnsignedShort, |
| 92 | Int, |
| 93 | UnsignedInt, |
| 94 | HalfFloat, |
| 95 | Float, |
| 96 | Double |
| 97 | }; |
| 98 | Q_ENUM(VertexBaseType) // LCOV_EXCL_LINE |
| 99 | |
| 100 | explicit QAttribute(QNode *parent = nullptr); |
| 101 | explicit QAttribute(QBuffer *buf, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); |
| 102 | explicit QAttribute(QBuffer *buf, const QString &name, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); |
| 103 | ~QAttribute(); |
| 104 | |
| 105 | QBuffer *buffer() const; |
| 106 | QString name() const; |
| 107 | VertexBaseType vertexBaseType() const; |
| 108 | uint vertexSize() const; |
| 109 | uint count() const; |
| 110 | uint byteStride() const; |
| 111 | uint byteOffset() const; |
| 112 | uint divisor() const; |
| 113 | AttributeType attributeType() const; |
| 114 | |
| 115 | Q_INVOKABLE static QString defaultPositionAttributeName(); |
| 116 | Q_INVOKABLE static QString defaultNormalAttributeName(); |
| 117 | Q_INVOKABLE static QString defaultColorAttributeName(); |
| 118 | Q_INVOKABLE static QString defaultTextureCoordinateAttributeName(); |
| 119 | Q_INVOKABLE static QString defaultTangentAttributeName(); |
| 120 | static QString defaultJointIndicesAttributeName(); |
| 121 | static QString defaultJointWeightsAttributeName(); |
| 122 | static QString defaultTextureCoordinate1AttributeName(); |
| 123 | static QString defaultTextureCoordinate2AttributeName(); |
| 124 | |
| 125 | public Q_SLOTS: |
| 126 | void setBuffer(QBuffer *buffer); |
| 127 | void setName(const QString &name); |
| 128 | void setVertexBaseType(VertexBaseType type); |
| 129 | void setVertexSize(uint size); |
| 130 | QT_DEPRECATED void setDataType(VertexBaseType type); |
| 131 | QT_DEPRECATED void setDataSize(uint size); |
| 132 | void setCount(uint count); |
| 133 | void setByteStride(uint byteStride); |
| 134 | void setByteOffset(uint byteOffset); |
| 135 | void setDivisor(uint divisor); |
| 136 | void setAttributeType(AttributeType attributeType); |
| 137 | |
| 138 | Q_SIGNALS: |
| 139 | void bufferChanged(QBuffer *buffer); |
| 140 | void nameChanged(const QString &name); |
| 141 | void vertexBaseTypeChanged(VertexBaseType vertexBaseType); |
| 142 | void vertexSizeChanged(uint vertexSize); |
| 143 | void dataTypeChanged(VertexBaseType vertexBaseType); |
| 144 | void dataSizeChanged(uint vertexSize); |
| 145 | void countChanged(uint count); |
| 146 | void byteStrideChanged(uint byteStride); |
| 147 | void byteOffsetChanged(uint byteOffset); |
| 148 | void divisorChanged(uint divisor); |
| 149 | void attributeTypeChanged(AttributeType attributeType); |
| 150 | |
| 151 | private: |
| 152 | Q_DECLARE_PRIVATE(QAttribute) |
| 153 | Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override; |
| 154 | }; |
| 155 | |
| 156 | } // Qt3DRender |
| 157 | |
| 158 | QT_END_NAMESPACE |
| 159 | |
| 160 | #endif // QT3DRENDER_QATTRIBUTE_H |
| 161 | |