Compare commits

...

2 Commits

  1. 15
      Resources/debug_landmark.tscn
  2. 32
      copyMediaPipe.gd
  3. 16
      copyMediaPipe.tscn

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://cpyvu3hjbn4rh"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrvph"]
shading_mode = 0
albedo_color = Color(0, 1, 0, 1)
[sub_resource type="SphereMesh" id="SphereMesh_xb663"]
material = SubResource("StandardMaterial3D_wrvph")
radius = 0.005
height = 0.01
radial_segments = 6
rings = 3
[node name="DebugLandmark" type="MeshInstance3D"]
mesh = SubResource("SphereMesh_xb663")

@ -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
@ -385,16 +381,16 @@ const INDEX_FINGER_DIP := 7
const INDEX_FINGER_TIP := 8
const MIDDLE_FINGER_MCP := 9
const MIDDLE_FINGER_PIP := 10
const MIDDLE_FINGER_DIP := 12
const MIDDLE_FINGER_TIP := 13
const RING_FINGER_MCP := 14
const RING_FINGER_PIP := 15
const RING_FINGER_DIP := 16
const RING_FINGER_TIP := 17
const PINKY_MCP := 18
const PINKY_PIP := 19
const PINKY_DIP := 20
const PINKY_TIP := 21
const MIDDLE_FINGER_DIP := 11
const MIDDLE_FINGER_TIP := 12
const RING_FINGER_MCP := 13
const RING_FINGER_PIP := 14
const RING_FINGER_DIP := 15
const RING_FINGER_TIP := 16
const PINKY_MCP := 17
const PINKY_PIP := 18
const PINKY_DIP := 19
const PINKY_TIP := 20
## Calculate the hand rotation from the hand tracking's world landmarks.
func get_hand_rotation(side: String, landmarks: Array[Vector3]) -> Basis:

@ -6,17 +6,6 @@
[sub_resource type="BoxMesh" id="BoxMesh_wtdv4"]
size = Vector3(0.2, 0.2, 0.2)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrvph"]
shading_mode = 0
albedo_color = Color(0, 1, 0, 1)
[sub_resource type="SphereMesh" id="SphereMesh_xb663"]
material = SubResource("StandardMaterial3D_wrvph")
radius = 0.005
height = 0.01
radial_segments = 6
rings = 3
[node name="copyMediaPipe" type="Node"]
script = ExtResource("1_0kpr8")
@ -43,8 +32,3 @@ transform = Transform3D(1.91069e-15, -1, 4.37114e-08, -4.37114e-08, -4.37114e-08
[node name="DebugVisuals" parent="TrackingRoot/RightHand" instance=ExtResource("2_8wmot")]
visible = false
[node name="LandmarkTemplate" type="MeshInstance3D" parent="TrackingRoot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
visible = false
mesh = SubResource("SphereMesh_xb663")

Loading…
Cancel
Save