Debian Codegraph @

scene/3d/xr/xr_body_modifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* xr_body_modifier_3d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/skeleton_modifier_3d.h"
34 #include "servers/xr/xr_body_tracker.h"
35
36 class Skeleton3D;
37
38 /**
39 The XRBodyModifier3D node drives a body skeleton using body tracking
40 data from an XRBodyTracker instance.
41 */
42
43 class XRBodyModifier3D : public SkeletonModifier3D {
44 GDCLASS(XRBodyModifier3D, SkeletonModifier3D);
45
46 public:
47 enum BodyUpdate {
48 BODY_UPDATE_UPPER_BODY = 1,
49 BODY_UPDATE_LOWER_BODY = 2,
50 BODY_UPDATE_HANDS = 4,
51 };
52
53 enum BoneUpdate {
54 BONE_UPDATE_FULL,
55 BONE_UPDATE_ROTATION_ONLY,
56 BONE_UPDATE_MAX
57 };
58
59 void set_body_tracker(const StringName &p_tracker_name);
60 StringName get_body_tracker() const;
61
62 void set_body_update(BitField<BodyUpdate> p_body_update);
63 BitField<BodyUpdate> get_body_update() const;
64
65 void set_bone_update(BoneUpdate p_bone_update);
66 BoneUpdate get_bone_update() const;
67
68 void _notification(int p_what);
69
70 protected:
71 static void _bind_methods();
72
73 virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override;
74 virtual void _process_modification(double p_delta) override;
75
76 private:
77 struct JointData {
78 int bone = -1;
79 int parent_joint = -1;
80 };
81
82 StringName tracker_name = "/user/body_tracker";
83 BitField<BodyUpdate> body_update = BODY_UPDATE_UPPER_BODY | BODY_UPDATE_LOWER_BODY | BODY_UPDATE_HANDS;
84 BoneUpdate bone_update = BONE_UPDATE_FULL;
85 JointData joints[XRBodyTracker::JOINT_MAX];
86
87 void _get_joint_data();
88 void _tracker_changed(const StringName &p_tracker_name, XRServer::TrackerType p_tracker_type);
89 };
90
91 VARIANT_BITFIELD_CAST(XRBodyModifier3D::BodyUpdate)
92 VARIANT_ENUM_CAST(XRBodyModifier3D::BoneUpdate)