]> Untitled Git - william-skin.git/blob - william_skeleton.gd
Added NPC
[william-skin.git] / william_skeleton.gd
1 extends Skeleton3D
2
3
4 # Called when the node enters the scene tree for the first time.
5 func _ready() -> void:
6         pass
7
8
9 # TODO: this doesn't work well because animation pose positions are offset!
10 # The actual solution is to make blender spit out a proper skeleton hierarchy
11 func _reparent_rigify_floating_bones() -> void:
12         var head_bone_idx: int = find_bone("DEF-spine.006")
13         var head_bone_rest: Transform3D = get_bone_global_rest(head_bone_idx)
14         
15         var to_head_arr := ["ORG-face", "DEF-hair-root", "DEF-hair-root.001", 
16                 "DEF-hair-root.002", "DEF-hair-root.003", "DEF-hair-root.004",
17                 "DEF-hair-root.005"
18                 ]
19         
20         # parent the face, hair, and horns to the head bone
21         for n in to_head_arr:
22                 var idx: int = find_bone(n)
23                 var rest: Transform3D = get_bone_global_rest(idx)
24                 
25                 # set bone position relative to its new parent
26                 set_bone_rest(idx, rest * head_bone_rest)
27                 #set_bone_pose_position(idx, head_bone_rest.basis.x - rest.basis.x)
28                 set_bone_parent(idx, head_bone_idx)