Turn landmark template into scene

main
copygirl 2 weeks ago
parent f805576494
commit dfc85cb32b
  1. 15
      Resources/debug_landmark.tscn
  2. 12
      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

@ -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