Well here we go. I wanted to create character face deformation controls, but cant understand why the bone positions are flipped. Also moving them is flipped.
Based on previous script: https://godotforums.org/d/41001-createscale-plane-to-field-of-view-camera-extents/3
I have blender scene import:
extends Node3D
@onready var skeleton_3d: Skeleton3D = $Armature_001/Skeleton3D
@onready var ball = preload("res://ball_node.tscn")
@export var cam:Camera3D
@onready var ball_nodes: Node3D = $BallNodes
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_bones()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func get_bones():
var bone_count = skeleton_3d.get_bone_count()
if bone_count <1:
return
for b_index in range(0,bone_count-1):
var b_pos = skeleton_3d.get_bone_global_pose(b_index)
var pos = skeleton_3d.global_transform * b_pos
var new_ball:Ball = ball.instantiate()
new_ball.ball_position_changed.connect(_on_ball_position_changed)
new_ball.bone_index = b_index
new_ball.cam = cam
new_ball.transform = pos
#new_ball.transform = new_ball.transform.rotated(-Vector3.UP,0)
ball_nodes.add_child(new_ball)
pass
func _on_ball_position_changed(bone_index, bone_pos):
skeleton_3d.set_bone_pose_position(bone_index,bone_pos)
pass
But the balls spawn mirrored or 180° from the original skeleton. And when i try to move them, moving mouse right the ball goes left..
Not sure why i can only see few bones, (only nose)
Blender view
Video demo. Notice the top (detached ball) is not attached to any bone, and i can move it left right perfectly fine, while the other ones that are spawned based on bone position move opposite.