| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGMORPHTARGET_H |
| 5 | #define QSSGMORPHTARGET_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 <QtQuick3D/private/qquick3dobject_p.h> |
| 19 | |
| 20 | #include <QtQml/QQmlListProperty> |
| 21 | |
| 22 | #include <QtCore/QVector> |
| 23 | #include <QtCore/QUrl> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | class QQuick3DModel; |
| 27 | |
| 28 | class Q_QUICK3D_EXPORT QQuick3DMorphTarget : public QQuick3DObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(float weight READ weight WRITE setWeight NOTIFY weightChanged) |
| 32 | Q_PROPERTY(MorphTargetAttributes attributes READ attributes WRITE setAttributes NOTIFY attributesChanged) |
| 33 | QML_NAMED_ELEMENT(MorphTarget) |
| 34 | QML_ADDED_IN_VERSION(6, 0) |
| 35 | |
| 36 | public: |
| 37 | enum class MorphTargetAttribute { |
| 38 | Position = 0x01, |
| 39 | Normal = 0x02, |
| 40 | Tangent = 0x04, |
| 41 | Binormal = 0x08, |
| 42 | TexCoord0 = 0x10, |
| 43 | TexCoord1 = 0x20, |
| 44 | Color = 0x40 |
| 45 | }; |
| 46 | Q_ENUM(MorphTargetAttribute) |
| 47 | Q_DECLARE_FLAGS(MorphTargetAttributes , MorphTargetAttribute) |
| 48 | Q_FLAG(MorphTargetAttributes) |
| 49 | |
| 50 | explicit QQuick3DMorphTarget(QQuick3DObject *parent = nullptr); |
| 51 | ~QQuick3DMorphTarget() override; |
| 52 | |
| 53 | float weight() const; |
| 54 | MorphTargetAttributes attributes() const; |
| 55 | |
| 56 | public Q_SLOTS: |
| 57 | void setWeight(float castsShadows); |
| 58 | void setAttributes(QQuick3DMorphTarget::MorphTargetAttributes attributes); |
| 59 | Q_SIGNALS: |
| 60 | void weightChanged(); |
| 61 | void attributesChanged(); |
| 62 | |
| 63 | private: |
| 64 | friend QQuick3DModel; |
| 65 | QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; |
| 66 | void markAllDirty() override; |
| 67 | size_t numAttribs(); |
| 68 | |
| 69 | enum QSSGMorphTargetDirtyType { |
| 70 | WeightDirty = 0x00000001, |
| 71 | MorphTargetAttributesDirty = 0x00000002, |
| 72 | }; |
| 73 | |
| 74 | quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default |
| 75 | void markDirty(QSSGMorphTargetDirtyType type); |
| 76 | |
| 77 | float m_weight = 0.0; |
| 78 | MorphTargetAttributes m_attributes = MorphTargetAttribute::Position; |
| 79 | size_t m_numAttribs = 1; |
| 80 | }; |
| 81 | |
| 82 | QT_END_NAMESPACE |
| 83 | |
| 84 | #endif // QSSGMORPHTARGET_H |
| 85 | |