1 | // Copyright (C) 2024 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DXRCONTROLLER_H |
5 | #define QQUICK3DXRCONTROLLER_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 <QtQuick3DXr/qtquick3dxrglobal.h> |
19 | #include "qquick3dxrhandinput_p.h" |
20 | #include "qtquick3dxrglobal_p.h" |
21 | #include <QtQuick3D/private/qquick3dnode_p.h> |
22 | #include <QtQml/QQmlEngine> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QQuick3DXrInputManager; |
27 | |
28 | class Q_QUICK3DXR_EXPORT QQuick3DXrController : public QQuick3DNode |
29 | { |
30 | Q_OBJECT |
31 | Q_PROPERTY(Controller controller READ controller WRITE setController NOTIFY controllerChanged FINAL) |
32 | Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged FINAL) |
33 | Q_PROPERTY(HandPoseSpace poseSpace READ poseSpace WRITE setPoseSpace NOTIFY poseSpaceChanged FINAL) |
34 | |
35 | Q_PROPERTY(QVector3D pokePosition READ pokePosition NOTIFY pokePositionChanged FINAL) |
36 | Q_PROPERTY(QList<QVector3D> jointPositions READ jointPositions NOTIFY jointPositionsChanged FINAL) |
37 | Q_PROPERTY(QList<QQuaternion> jointRotations READ jointRotations NOTIFY jointRotationsChanged FINAL) |
38 | |
39 | QML_NAMED_ELEMENT(XrController) |
40 | QML_ADDED_IN_VERSION(6, 8) |
41 | public: |
42 | enum Controller { |
43 | ControllerLeft = 0, |
44 | ControllerRight = 1, |
45 | ControllerNone = 2, |
46 | }; |
47 | Q_ENUM(Controller) |
48 | |
49 | enum class HandPoseSpace { |
50 | GripPose, |
51 | AimPose |
52 | }; |
53 | Q_ENUM(HandPoseSpace) |
54 | |
55 | QQuick3DXrController(); |
56 | |
57 | QQuick3DXrController::Controller controller() const; |
58 | void setController(QQuick3DXrController::Controller newController); |
59 | |
60 | QQuick3DXrHandInput *handInput() const; |
61 | |
62 | HandPoseSpace poseSpace() const; |
63 | void setPoseSpace(HandPoseSpace newPoseSpace); |
64 | |
65 | QVector3D pokePosition() const; |
66 | |
67 | QList<QVector3D> jointPositions() const; |
68 | QList<QQuaternion> jointRotations() const; |
69 | |
70 | bool isActive() const; |
71 | |
72 | Q_SIGNALS: |
73 | void controllerChanged(); |
74 | void actionMapperChanged(); |
75 | |
76 | void poseSpaceChanged(); |
77 | |
78 | void pokePositionChanged(); |
79 | |
80 | void jointPositionsChanged(); |
81 | void jointRotationsChanged(); |
82 | void jointDataUpdated(); |
83 | |
84 | void isActiveChanged(); |
85 | |
86 | private: |
87 | QPointer<QQuick3DXrInputManager> m_inputManager; |
88 | Controller m_controller = ControllerNone; |
89 | QMetaObject::Connection m_isActiveConnection; |
90 | HandPoseSpace m_poseSpace = HandPoseSpace::AimPose; |
91 | QVector3D m_pokePosition; |
92 | bool m_isActive; |
93 | }; |
94 | |
95 | namespace QtQuick3DXr |
96 | { |
97 | QtQuick3DXr::Hand handForController(QQuick3DXrController::Controller controller); |
98 | QtQuick3DXr::HandPoseSpace pose_cast(QQuick3DXrController::HandPoseSpace poseSpace); |
99 | } |
100 | |
101 | QT_END_NAMESPACE |
102 | |
103 | #endif // QQUICK3DXRCONTROLLER_H |
104 |