diff --git a/copyMediaPipe.gd b/copyMediaPipe.gd index f8568b0..94c90f6 100644 --- a/copyMediaPipe.gd +++ b/copyMediaPipe.gd @@ -1,10 +1,15 @@ class_name copyMediaPipe extends Mod_Base +var Blendshapes = preload("res://Mods/MediaPipe/MediaPipeController_BlendShapes.gd") + # ----------------------------------------------------------------------------- # Potentially configurable variables. # ----------------------------------------------------------------------------- +enum BlendshapeMode { NONE, MEDIA_PIPE, VRM_STANDARD } +var blendshape_mode := BlendshapeMode.VRM_STANDARD + var arm_rest_angle := 65 var interpolation_factor := 0.000000001 # Yes this value needs to be THAT small. var rest_interpolation_factor := 0.2 # "Lerp about 80% of the way in one second." @@ -86,6 +91,7 @@ func _process(delta: float) -> void: receive_tracker_packets() update_visual_trackers(delta) update_ik_chains() + update_blendshapes() ## Sets up 21 nodes for the landmarks that make up hand/finger tracking. func setup_hand_landmarks() -> void: @@ -348,6 +354,21 @@ func update_ik_chains() -> void: for chain in ik_chains: chain.do_ik_chain() +func update_blendshapes() -> void: + var model := get_model() + if (not model) or (not head.last_data): return + var data: Dictionary = head.last_data.blendshapes + + var shape_dict: Dictionary + match blendshape_mode: + BlendshapeMode.MEDIA_PIPE: shape_dict = data + BlendshapeMode.VRM_STANDARD: shape_dict = \ + Blendshapes.convert_mediapipe_shapes_to_vrm_standard(data) + + # TODO: Blendshapes.apply_smoothing(...) + Blendshapes.fixup_eyes(shape_dict) + Blendshapes.apply_animations(model, shape_dict) + # ----------------------------------------------------------------------------- # Utility functions, currently only relating to update_visual_trackers. # -----------------------------------------------------------------------------