skeleton_profile.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**************************************************************************/
  2. /* skeleton_profile.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 SKELETON_PROFILE_H
  31. #define SKELETON_PROFILE_H
  32. #include "texture.h"
  33. class SkeletonProfile : public Resource {
  34. GDCLASS(SkeletonProfile, Resource);
  35. public:
  36. enum TailDirection {
  37. TAIL_DIRECTION_AVERAGE_CHILDREN,
  38. TAIL_DIRECTION_SPECIFIC_CHILD,
  39. TAIL_DIRECTION_END
  40. };
  41. protected:
  42. // Note: SkeletonProfileHumanoid which extends SkeletonProfile exists to unify standard bone names.
  43. // That is what is_read_only is for, so don't make it public.
  44. bool is_read_only = false;
  45. struct SkeletonProfileGroup {
  46. StringName group_name;
  47. Ref<Texture2D> texture;
  48. };
  49. struct SkeletonProfileBone {
  50. StringName bone_name;
  51. StringName bone_parent;
  52. TailDirection tail_direction = TAIL_DIRECTION_AVERAGE_CHILDREN;
  53. StringName bone_tail;
  54. Transform3D reference_pose;
  55. Vector2 handle_offset;
  56. StringName group;
  57. bool required = false;
  58. };
  59. StringName root_bone;
  60. StringName scale_base_bone;
  61. Vector<SkeletonProfileGroup> groups;
  62. Vector<SkeletonProfileBone> bones;
  63. bool _get(const StringName &p_path, Variant &r_ret) const;
  64. bool _set(const StringName &p_path, const Variant &p_value);
  65. void _validate_property(PropertyInfo &p_property) const;
  66. void _get_property_list(List<PropertyInfo> *p_list) const;
  67. static void _bind_methods();
  68. public:
  69. StringName get_root_bone();
  70. void set_root_bone(const StringName &p_bone_name);
  71. StringName get_scale_base_bone();
  72. void set_scale_base_bone(const StringName &p_bone_name);
  73. int get_group_size();
  74. void set_group_size(int p_size);
  75. StringName get_group_name(int p_group_idx) const;
  76. void set_group_name(int p_group_idx, const StringName &p_group_name);
  77. Ref<Texture2D> get_texture(int p_group_idx) const;
  78. void set_texture(int p_group_idx, const Ref<Texture2D> &p_texture);
  79. int get_bone_size();
  80. void set_bone_size(int p_size);
  81. int find_bone(const StringName &p_bone_name) const;
  82. PackedStringArray get_bone_names();
  83. StringName get_bone_name(int p_bone_idx) const;
  84. void set_bone_name(int p_bone_idx, const StringName &p_bone_name);
  85. StringName get_bone_parent(int p_bone_idx) const;
  86. void set_bone_parent(int p_bone_idx, const StringName &p_bone_parent);
  87. TailDirection get_tail_direction(int p_bone_idx) const;
  88. void set_tail_direction(int p_bone_idx, TailDirection p_tail_direction);
  89. StringName get_bone_tail(int p_bone_idx) const;
  90. void set_bone_tail(int p_bone_idx, const StringName &p_bone_tail);
  91. Transform3D get_reference_pose(int p_bone_idx) const;
  92. void set_reference_pose(int p_bone_idx, const Transform3D &p_reference_pose);
  93. Vector2 get_handle_offset(int p_bone_idx) const;
  94. void set_handle_offset(int p_bone_idx, const Vector2 &p_handle_offset);
  95. StringName get_group(int p_bone_idx) const;
  96. void set_group(int p_bone_idx, const StringName &p_group);
  97. bool is_required(int p_bone_idx) const;
  98. void set_required(int p_bone_idx, bool p_required);
  99. bool has_bone(const StringName &p_bone_name);
  100. SkeletonProfile();
  101. ~SkeletonProfile();
  102. };
  103. class SkeletonProfileHumanoid : public SkeletonProfile {
  104. GDCLASS(SkeletonProfileHumanoid, SkeletonProfile);
  105. public:
  106. SkeletonProfileHumanoid();
  107. ~SkeletonProfileHumanoid();
  108. };
  109. VARIANT_ENUM_CAST(SkeletonProfile::TailDirection);
  110. #endif // SKELETON_PROFILE_H