1 | /**************************************************************************/ |
2 | /* bone_attachment_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 | #ifndef BONE_ATTACHMENT_3D_H |
32 | #define BONE_ATTACHMENT_3D_H |
33 | |
34 | #include "scene/3d/skeleton_3d.h" |
35 | #ifdef TOOLS_ENABLED |
36 | #include "scene/resources/bone_map.h" |
37 | #endif // TOOLS_ENABLED |
38 | |
39 | class BoneAttachment3D : public Node3D { |
40 | GDCLASS(BoneAttachment3D, Node3D); |
41 | |
42 | bool bound = false; |
43 | String bone_name; |
44 | int bone_idx = -1; |
45 | |
46 | bool override_pose = false; |
47 | bool _override_dirty = false; |
48 | |
49 | bool use_external_skeleton = false; |
50 | NodePath external_skeleton_node; |
51 | ObjectID external_skeleton_node_cache; |
52 | |
53 | void _check_bind(); |
54 | void _check_unbind(); |
55 | |
56 | void _transform_changed(); |
57 | void _update_external_skeleton_cache(); |
58 | Skeleton3D *_get_skeleton3d(); |
59 | |
60 | protected: |
61 | void _validate_property(PropertyInfo &p_property) const; |
62 | bool _get(const StringName &p_path, Variant &r_ret) const; |
63 | bool _set(const StringName &p_path, const Variant &p_value); |
64 | void _get_property_list(List<PropertyInfo> *p_list) const; |
65 | void _notification(int p_what); |
66 | |
67 | static void _bind_methods(); |
68 | #ifdef TOOLS_ENABLED |
69 | virtual void _notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map); |
70 | #endif // TOOLS_ENABLED |
71 | |
72 | public: |
73 | virtual PackedStringArray get_configuration_warnings() const override; |
74 | |
75 | void set_bone_name(const String &p_name); |
76 | String get_bone_name() const; |
77 | |
78 | void set_bone_idx(const int &p_idx); |
79 | int get_bone_idx() const; |
80 | |
81 | void set_override_pose(bool p_override); |
82 | bool get_override_pose() const; |
83 | |
84 | void set_use_external_skeleton(bool p_external_skeleton); |
85 | bool get_use_external_skeleton() const; |
86 | void set_external_skeleton(NodePath p_skeleton); |
87 | NodePath get_external_skeleton() const; |
88 | |
89 | virtual void on_bone_pose_update(int p_bone_index); |
90 | |
91 | BoneAttachment3D(); |
92 | }; |
93 | |
94 | #endif // BONE_ATTACHMENT_3D_H |
95 | |