| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "texture.h" |
| 34 |
|
| 35 |
class SkeletonProfile : public Resource { |
| 36 |
GDCLASS(SkeletonProfile, Resource); |
| 37 |
|
| 38 |
public: |
| 39 |
enum TailDirection { |
| 40 |
TAIL_DIRECTION_AVERAGE_CHILDREN, |
| 41 |
TAIL_DIRECTION_SPECIFIC_CHILD, |
| 42 |
TAIL_DIRECTION_END |
| 43 |
}; |
| 44 |
|
| 45 |
protected: |
| 46 |
|
| 47 |
|
| 48 |
bool is_read_only = false; |
| 49 |
|
| 50 |
struct SkeletonProfileGroup { |
| 51 |
StringName group_name; |
| 52 |
Ref<Texture2D> texture; |
| 53 |
}; |
| 54 |
|
| 55 |
struct SkeletonProfileBone { |
| 56 |
StringName bone_name; |
| 57 |
StringName bone_parent; |
| 58 |
TailDirection tail_direction = TAIL_DIRECTION_AVERAGE_CHILDREN; |
| 59 |
StringName bone_tail; |
| 60 |
Transform3D reference_pose; |
| 61 |
Vector2 handle_offset; |
| 62 |
StringName group; |
| 63 |
bool required = false; |
| 64 |
}; |
| 65 |
|
| 66 |
StringName root_bone; |
| 67 |
StringName scale_base_bone; |
| 68 |
|
| 69 |
Vector<SkeletonProfileGroup> groups; |
| 70 |
Vector<SkeletonProfileBone> bones; |
| 71 |
|
| 72 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 73 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 74 |
void _validate_property(PropertyInfo &p_property) const; |
| 75 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 76 |
static void _bind_methods(); |
| 77 |
|
| 78 |
public: |
| 79 |
StringName get_root_bone(); |
| 80 |
void set_root_bone(const StringName &p_bone_name); |
| 81 |
|
| 82 |
StringName get_scale_base_bone(); |
| 83 |
void set_scale_base_bone(const StringName &p_bone_name); |
| 84 |
|
| 85 |
int get_group_size(); |
| 86 |
void set_group_size(int p_size); |
| 87 |
|
| 88 |
StringName get_group_name(int p_group_idx) const; |
| 89 |
void set_group_name(int p_group_idx, const StringName &p_group_name); |
| 90 |
|
| 91 |
Ref<Texture2D> get_texture(int p_group_idx) const; |
| 92 |
void set_texture(int p_group_idx, const Ref<Texture2D> &p_texture); |
| 93 |
|
| 94 |
int get_bone_size(); |
| 95 |
void set_bone_size(int p_size); |
| 96 |
|
| 97 |
int find_bone(const StringName &p_bone_name) const; |
| 98 |
|
| 99 |
PackedStringArray get_bone_names(); |
| 100 |
StringName get_bone_name(int p_bone_idx) const; |
| 101 |
void set_bone_name(int p_bone_idx, const StringName &p_bone_name); |
| 102 |
|
| 103 |
StringName get_bone_parent(int p_bone_idx) const; |
| 104 |
void set_bone_parent(int p_bone_idx, const StringName &p_bone_parent); |
| 105 |
|
| 106 |
TailDirection get_tail_direction(int p_bone_idx) const; |
| 107 |
void set_tail_direction(int p_bone_idx, TailDirection p_tail_direction); |
| 108 |
|
| 109 |
StringName get_bone_tail(int p_bone_idx) const; |
| 110 |
void set_bone_tail(int p_bone_idx, const StringName &p_bone_tail); |
| 111 |
|
| 112 |
Transform3D get_reference_pose(int p_bone_idx) const; |
| 113 |
void set_reference_pose(int p_bone_idx, const Transform3D &p_reference_pose); |
| 114 |
|
| 115 |
Vector2 get_handle_offset(int p_bone_idx) const; |
| 116 |
void set_handle_offset(int p_bone_idx, const Vector2 &p_handle_offset); |
| 117 |
|
| 118 |
StringName get_group(int p_bone_idx) const; |
| 119 |
void set_group(int p_bone_idx, const StringName &p_group); |
| 120 |
|
| 121 |
bool is_required(int p_bone_idx) const; |
| 122 |
void set_required(int p_bone_idx, bool p_required); |
| 123 |
|
| 124 |
bool has_bone(const StringName &p_bone_name); |
| 125 |
|
| 126 |
SkeletonProfile(); |
| 127 |
~SkeletonProfile(); |
| 128 |
}; |
| 129 |
|
| 130 |
class SkeletonProfileHumanoid : public SkeletonProfile { |
| 131 |
GDCLASS(SkeletonProfileHumanoid, SkeletonProfile); |
| 132 |
|
| 133 |
public: |
| 134 |
SkeletonProfileHumanoid(); |
| 135 |
~SkeletonProfileHumanoid(); |
| 136 |
}; |
| 137 |
|
| 138 |
VARIANT_ENUM_CAST(SkeletonProfile::TailDirection); |