using System.Collections.Generic; using UnityEngine; using Warudo.Core.Attributes; using Warudo.Core.Graphs; [NodeType(Id = "7f556756-ee24-45b6-a552-6e8aadddb4a7", Title = "DollarsMoCap Hand Fallback", Category = "DollarsMoCap")] public class DollarsMoCapHandFallbackNode : Node { [DataInput] public float[] InputList; [DataInput] public Dictionary BlendShapeList; [DataInput] [FloatSlider(0.01f, 1f)] public float SmoothTime = 0.2f; private float _smoothLeft = 1f; private float _smoothRight = 1f; [DataOutput] public float[] OutputList() { if (InputList == null) return InputList; var result = (float[])InputList.Clone(); float targetLeft = 1f; float targetRight = 1f; if (BlendShapeList != null) { if (BlendShapeList.TryGetValue("_LeftHandVisibility", out var lv)) targetLeft = lv; if (BlendShapeList.TryGetValue("_RightHandVisibility", out var rv)) targetRight = rv; } float t = 1f - Mathf.Exp(-Time.deltaTime / Mathf.Max(SmoothTime, 0.001f)); _smoothLeft = Mathf.Lerp(_smoothLeft, targetLeft, t); _smoothRight = Mathf.Lerp(_smoothRight, targetRight, t); int[] leftIndices = { 11, 13, 15, 17, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 }; foreach (var i in leftIndices) if (i < result.Length) result[i] = _smoothLeft; int[] rightIndices = { 12, 14, 16, 18, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 }; foreach (var i in rightIndices) if (i < result.Length) result[i] = _smoothRight; return result; } }