|
|
|
@ -1,8 +1,6 @@ |
|
|
|
|
class_name copyMediaPipe |
|
|
|
|
extends Mod_Base |
|
|
|
|
|
|
|
|
|
var Blendshapes = preload("res://Mods/MediaPipe/MediaPipeController_BlendShapes.gd") |
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
|
|
# Potentially configurable variables. |
|
|
|
|
# ----------------------------------------------------------------------------- |
|
|
|
@ -29,15 +27,12 @@ var camera_aspect_ratio := 4.0 / 3.0 # Logitech C920 default? |
|
|
|
|
var ik_chains: Array[copyMediaPipe_IKChain] = [] |
|
|
|
|
|
|
|
|
|
@onready var tracking_root: Node3D = $TrackingRoot |
|
|
|
|
@onready var landmark_template: MeshInstance3D = $TrackingRoot/LandmarkTemplate |
|
|
|
|
|
|
|
|
|
@onready var head := { |
|
|
|
|
last_data = null, # Most recent tracking data received. |
|
|
|
|
last_received = INF, # How long ago it was received (in seconds). |
|
|
|
|
tracker = $TrackingRoot/Head, # Node for visualizing tracking data. |
|
|
|
|
rest_pose = Transform3D.IDENTITY, # Rest position of the head. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@onready var hands := { |
|
|
|
|
left = { |
|
|
|
|
last_data = null, |
|
|
|
@ -95,12 +90,11 @@ func _process(delta: float) -> void: |
|
|
|
|
|
|
|
|
|
## Sets up 21 nodes for the landmarks that make up hand/finger tracking. |
|
|
|
|
func setup_hand_landmarks() -> void: |
|
|
|
|
const landmark_scene := preload("Resources/debug_landmark.tscn") |
|
|
|
|
for side in hands: |
|
|
|
|
var hand = hands[side] |
|
|
|
|
for i in 21: |
|
|
|
|
var landmark: MeshInstance3D = landmark_template.duplicate(0) |
|
|
|
|
landmark.position = Vector3.ZERO |
|
|
|
|
landmark.visible = true |
|
|
|
|
var landmark := landmark_scene.instantiate() |
|
|
|
|
hand.tracker.add_child(landmark) |
|
|
|
|
hand.landmarks.append(landmark) |
|
|
|
|
|
|
|
|
@ -355,6 +349,8 @@ func update_ik_chains() -> void: |
|
|
|
|
chain.do_ik_chain() |
|
|
|
|
|
|
|
|
|
func update_blendshapes() -> void: |
|
|
|
|
const Blendshapes := preload("res://Mods/MediaPipe/MediaPipeController_BlendShapes.gd") |
|
|
|
|
|
|
|
|
|
var model := get_model() |
|
|
|
|
if (not model) or (not head.last_data): return |
|
|
|
|
var data: Dictionary = head.last_data.blendshapes |
|
|
|
|