| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DCORE_QATTRIBUTE_H |
| 5 | #define QT3DCORE_QATTRIBUTE_H |
| 6 | |
| 7 | #include <Qt3DCore/qt3dcore_global.h> |
| 8 | #include <Qt3DCore/qnode.h> |
| 9 | #include <Qt3DCore/qbuffer.h> |
| 10 | #include <QtCore/QSharedPointer> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | namespace Qt3DCore { |
| 15 | |
| 16 | class QAttributePrivate; |
| 17 | |
| 18 | typedef QSharedPointer<QBuffer> QBufferPtr; |
| 19 | |
| 20 | class Q_3DCORESHARED_EXPORT QAttribute : public QNode |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | Q_PROPERTY(Qt3DCore::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged) |
| 24 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
| 25 | Q_PROPERTY(VertexBaseType vertexBaseType READ vertexBaseType WRITE setVertexBaseType NOTIFY vertexBaseTypeChanged) |
| 26 | Q_PROPERTY(uint vertexSize READ vertexSize WRITE setVertexSize NOTIFY vertexSizeChanged) |
| 27 | Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged) |
| 28 | Q_PROPERTY(uint byteStride READ byteStride WRITE setByteStride NOTIFY byteStrideChanged) |
| 29 | Q_PROPERTY(uint byteOffset READ byteOffset WRITE setByteOffset NOTIFY byteOffsetChanged) |
| 30 | Q_PROPERTY(uint divisor READ divisor WRITE setDivisor NOTIFY divisorChanged) |
| 31 | Q_PROPERTY(AttributeType attributeType READ attributeType WRITE setAttributeType NOTIFY attributeTypeChanged) |
| 32 | Q_PROPERTY(QString defaultPositionAttributeName READ defaultPositionAttributeName CONSTANT) |
| 33 | Q_PROPERTY(QString defaultNormalAttributeName READ defaultNormalAttributeName CONSTANT) |
| 34 | Q_PROPERTY(QString defaultColorAttributeName READ defaultColorAttributeName CONSTANT) |
| 35 | Q_PROPERTY(QString defaultTextureCoordinateAttributeName READ defaultTextureCoordinateAttributeName CONSTANT) |
| 36 | Q_PROPERTY(QString defaultTextureCoordinate1AttributeName READ defaultTextureCoordinate1AttributeName CONSTANT QT3D_PROPERTY_REVISION(2, 11)) |
| 37 | Q_PROPERTY(QString defaultTextureCoordinate2AttributeName READ defaultTextureCoordinate2AttributeName CONSTANT QT3D_PROPERTY_REVISION(2, 11)) |
| 38 | Q_PROPERTY(QString defaultTangentAttributeName READ defaultTangentAttributeName CONSTANT) |
| 39 | Q_PROPERTY(QString defaultJointIndicesAttributeName READ defaultJointIndicesAttributeName CONSTANT QT3D_PROPERTY_REVISION(2, 10)) |
| 40 | Q_PROPERTY(QString defaultJointWeightsAttributeName READ defaultJointWeightsAttributeName CONSTANT QT3D_PROPERTY_REVISION(2, 10)) |
| 41 | |
| 42 | public: |
| 43 | enum AttributeType { |
| 44 | VertexAttribute, |
| 45 | IndexAttribute, |
| 46 | DrawIndirectAttribute |
| 47 | }; |
| 48 | |
| 49 | Q_ENUM(AttributeType) // LCOV_EXCL_LINE |
| 50 | |
| 51 | enum VertexBaseType { |
| 52 | Byte = 0, |
| 53 | UnsignedByte, |
| 54 | Short, |
| 55 | UnsignedShort, |
| 56 | Int, |
| 57 | UnsignedInt, |
| 58 | HalfFloat, |
| 59 | Float, |
| 60 | Double |
| 61 | }; |
| 62 | Q_ENUM(VertexBaseType) // LCOV_EXCL_LINE |
| 63 | |
| 64 | explicit QAttribute(QNode *parent = nullptr); |
| 65 | explicit QAttribute(QBuffer *buf, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); |
| 66 | explicit QAttribute(QBuffer *buf, const QString &name, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr); |
| 67 | ~QAttribute(); |
| 68 | |
| 69 | QBuffer *buffer() const; |
| 70 | QString name() const; |
| 71 | VertexBaseType vertexBaseType() const; |
| 72 | uint vertexSize() const; |
| 73 | uint count() const; |
| 74 | uint byteStride() const; |
| 75 | uint byteOffset() const; |
| 76 | uint divisor() const; |
| 77 | AttributeType attributeType() const; |
| 78 | |
| 79 | Q_INVOKABLE static QString defaultPositionAttributeName(); |
| 80 | Q_INVOKABLE static QString defaultNormalAttributeName(); |
| 81 | Q_INVOKABLE static QString defaultColorAttributeName(); |
| 82 | Q_INVOKABLE static QString defaultTextureCoordinateAttributeName(); |
| 83 | Q_INVOKABLE static QString defaultTangentAttributeName(); |
| 84 | static QString defaultJointIndicesAttributeName(); |
| 85 | static QString defaultJointWeightsAttributeName(); |
| 86 | static QString defaultTextureCoordinate1AttributeName(); |
| 87 | static QString defaultTextureCoordinate2AttributeName(); |
| 88 | |
| 89 | public Q_SLOTS: |
| 90 | void setBuffer(QBuffer *buffer); |
| 91 | void setName(const QString &name); |
| 92 | void setVertexBaseType(VertexBaseType type); |
| 93 | void setVertexSize(uint size); |
| 94 | void setCount(uint count); |
| 95 | void setByteStride(uint byteStride); |
| 96 | void setByteOffset(uint byteOffset); |
| 97 | void setDivisor(uint divisor); |
| 98 | void setAttributeType(AttributeType attributeType); |
| 99 | |
| 100 | Q_SIGNALS: |
| 101 | void bufferChanged(QBuffer *buffer); |
| 102 | void nameChanged(const QString &name); |
| 103 | void vertexBaseTypeChanged(VertexBaseType vertexBaseType); |
| 104 | void vertexSizeChanged(uint vertexSize); |
| 105 | void dataTypeChanged(VertexBaseType vertexBaseType); |
| 106 | void dataSizeChanged(uint vertexSize); |
| 107 | void countChanged(uint count); |
| 108 | void byteStrideChanged(uint byteStride); |
| 109 | void byteOffsetChanged(uint byteOffset); |
| 110 | void divisorChanged(uint divisor); |
| 111 | void attributeTypeChanged(AttributeType attributeType); |
| 112 | |
| 113 | private: |
| 114 | Q_DECLARE_PRIVATE(QAttribute) |
| 115 | }; |
| 116 | |
| 117 | } // Qt3DCore |
| 118 | |
| 119 | QT_END_NAMESPACE |
| 120 | |
| 121 | #endif // QT3DCORE_QATTRIBUTE_H |
| 122 | |