1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGSKIN_H
5#define QSSGSKIN_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/qquick3dobject.h>
19#include <QtQuick3D/private/qquick3dnode_p.h>
20#include <QtCore/qlist.h>
21#include <QtCore/qhash.h>
22
23QT_BEGIN_NAMESPACE
24
25class Q_QUICK3D_EXPORT QQuick3DSkin : public QQuick3DObject
26{
27 Q_OBJECT
28 Q_PROPERTY(QQmlListProperty<QQuick3DNode> joints READ joints)
29 Q_PROPERTY(QList<QMatrix4x4> inverseBindPoses READ inverseBindPoses WRITE setInverseBindPoses NOTIFY inverseBindPosesChanged)
30
31 QML_NAMED_ELEMENT(Skin)
32
33public:
34 explicit QQuick3DSkin(QQuick3DObject *parent = nullptr);
35 ~QQuick3DSkin() override;
36
37 QQmlListProperty<QQuick3DNode> joints();
38 QList<QMatrix4x4> inverseBindPoses() const;
39
40public Q_SLOTS:
41 void setInverseBindPoses(const QList<QMatrix4x4> &poses);
42
43Q_SIGNALS:
44 void inverseBindPosesChanged();
45
46private Q_SLOTS:
47 void onJointChanged(QQuick3DNode *node);
48 void onJointDestroyed(QObject *object);
49
50private:
51 void markDirty();
52 void markAllDirty() override;
53
54 static void qmlAppendJoint(QQmlListProperty<QQuick3DNode> *list, QQuick3DNode *joint);
55 static QQuick3DNode *qmlJointAt(QQmlListProperty<QQuick3DNode> *list, qsizetype index);
56 static qsizetype qmlJointsCount(QQmlListProperty<QQuick3DNode> *list);
57 static void qmlClearJoints(QQmlListProperty<QQuick3DNode> *list);
58
59 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
60
61 QVector<QQuick3DNode *> m_joints;
62 QByteArray m_boneData;
63 QList<QMatrix4x4> m_inverseBindPoses;
64 bool m_dirty = false;
65};
66
67QT_END_NAMESPACE
68
69#endif // QSSGSKIN_H
70

source code of qtquick3d/src/quick3d/qquick3dskin_p.h