bone_attachment_3d.h 3.9 KB

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