Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dxrhandmodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
7
8#if defined(Q_OS_VISIONOS)
10#else
12#endif
13
15
30
31void QQuick3DXrHandModel::updatePose()
32{
33 if (auto *skin = QQuick3DModel::skin()) {
34 auto jointListProp = skin->joints();
35 int count = jointListProp.count(&jointListProp);
36 const auto positions = m_handTracker->jointPositions();
37 const auto rotations = m_handTracker->jointRotations();
38 for (int i = 0; i < count; ++i) {
39 auto *joint = jointListProp.at(&jointListProp, i);
40 joint->setPosition(positions.at(i));
41 joint->setRotation(rotations.at(i));
42 }
43 } else {
44 static bool warned = false;
45 if (!warned) {
46 qWarning() << "No skin available for hand model";
47 warned = true;
48 }
49 }
50}
51
52void QQuick3DXrHandModel::setupModel()
53{
54 if (m_initialized) {
55 qWarning() << "XrHandModel does not support changing hand";
56 return;
57 }
59 if (m_hand == RightHand)
60 m_handTracker = inputMan->rightHandInput();
61 else if (m_hand == LeftHand)
62 m_handTracker = inputMan->leftHandInput();
63 if (!m_handTracker)
64 return;
65
66 QQuick3DXrInputManagerPrivate::get(inputMan)->setupHandModel(this);
67
68 connect(m_handTracker, &QQuick3DXrHandInput::jointDataUpdated, this, &QQuick3DXrHandModel::updatePose);
69 connect(m_handTracker, &QQuick3DXrHandInput::isHandTrackingChanged, this, [this](){
70 setVisible(m_handTracker->isHandTrackingActive());
71 });
72 setVisible(m_handTracker->isActive());
73 m_initialized = true;
74}
75
81
90{
91 return m_hand;
92}
93
95{
96 if (m_hand == newHand)
97 return;
98 m_hand = newHand;
100}
const_reference at(qsizetype i) const noexcept
Definition qlist.h:447
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
QQuick3DSkin * skin
\qmlproperty Skin Model::skin
void setVisible(bool visible)
QQmlListProperty< QQuick3DNode > joints
\qmlproperty List<QtQuick3D::Node> Skin::joints
void isHandTrackingChanged()
QList< QQuaternion > jointRotations() const
QList< QVector3D > jointPositions() const
QQuick3DXrHandModel(QQuick3DNode *parent=nullptr)
\qmltype XrHandModel \inherits Model \inqmlmodule QtQuick3D.Xr
void setHand(Hand newHand)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
static QQuick3DXrInputManagerPrivate * get(QQuick3DXrInputManager *inputManager)
static QQuick3DXrInputManager * instance()
Combined button and popup list for selecting options.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
#define qWarning
Definition qlogging.h:167
GLenum GLenum GLsizei count
#define emit
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)