//Constructors: public ManagedHandSkeleton(ManagedHand managedHand) { //refs: _mainCamera = Camera.main; //sets: _managedHand = managedHand; //establish rotation offsets: _rotationOffsets = new List <Vector3>(); _rotationOffsets.Add(Vector3.zero); _rotationOffsets.Add(new Vector3(-0.3004f, -0.9466f, 0.1174f)); _rotationOffsets.Add(new Vector3(-0.8816f, 0.3225f, 0.3447f)); //keypoints: HandCenter = new ManagedKeypoint(); WristCenter = new ManagedKeypoint(); //fingers: Thumb = new ManagedFinger(_managedHand.Hand, FingerType.Thumb, _thumbMCP, _thumbPIP, _thumbTip); Index = new ManagedFinger(_managedHand.Hand, FingerType.Index, _indexMCP, _indexPIP, _indexTip); Middle = new ManagedFinger(_managedHand.Hand, FingerType.Middle, _middleMCP, _middlePIP, _middleTip); Ring = new ManagedFinger(_managedHand.Hand, FingerType.Ring, _ringMCP, _ringTip); Pinky = new ManagedFinger(_managedHand.Hand, FingerType.Pinky, _pinkyMCP, _pinkyTip); Fingers = new ManagedFinger[5] { Thumb, Index, Middle, Ring, Pinky }; }
//Event Handlers: private void HandlePointVisibilityChanged() { for (int i = 0; i < points.Length; i++) { if (points[i].Visible && _lastReliableEnd != points[i]) { _lastReliableEnd = points[i]; _endTransitionStartTime = Time.realtimeSinceStartup; _endIsTransitioning = true; } } }
//Constructors: public ManagedFinger(MLHandTracking.Hand hand, FingerType fingerType, params ManagedKeypoint[] points) { //sets: _hand = hand; this.points = points; _lastReliableEnd = points[0]; FingerType = fingerType; //hooks: foreach (var item in points) { item.OnFound += HandlePointVisibilityChanged; item.OnLost += HandlePointVisibilityChanged; } //initial events: OnVisibilityChanged?.Invoke(this, false); HandlePointVisibilityChanged(); }