Beispiel #1
0
        public static Hand MakeTestHand(int frameId, int handId, bool isLeft)
        {
            List <Finger> fingers = new List <Finger>(5);

            fingers.Add(MakeThumb(frameId, handId, isLeft));
            fingers.Add(MakeIndexFinger(frameId, handId, isLeft));
            fingers.Add(MakeMiddleFinger(frameId, handId, isLeft));
            fingers.Add(MakeRingFinger(frameId, handId, isLeft));
            fingers.Add(MakePinky(frameId, handId, isLeft));

            Vector armWrist = new Vector(-7.05809944059f, 4.0f, 50.0f);
            Vector elbow    = armWrist + 250f * Vector.Backward;

            // Adrian: The previous "armBasis" used "elbow" as a translation component.
            Arm  arm      = new Arm(elbow, armWrist, (elbow + armWrist) / 2, Vector.Forward, 250f, 41f, LeapQuaternion.Identity);
            Hand testHand = new Hand(frameId,
                                     handId,
                                     1.0f,
                                     0.0f,
                                     0.0f,
                                     0.0f,
                                     0.0f,
                                     85f,
                                     isLeft,
                                     0.0f,
                                     arm,
                                     fingers,
                                     new Vector(0, 0, 0),
                                     new Vector(0, 0, 0),
                                     new Vector(0, 0, 0),
                                     Vector.Down,
                                     LeapQuaternion.Identity,
                                     Vector.Forward,
                                     new Vector(-4.36385750984f, 6.5f, 31.0111342526f)
                                     );
            LeapTransform restPosition = LeapTransform.Identity;

            //restPosition.rotation = RotationFromTo(Vector.Up, Vector.Left).Multiply(RotationFromTo(Vector.Up, Vector.Left));
            restPosition.rotation = AngleAxis(180 * Constants.DEG_TO_RAD, Vector.Forward);
            if (isLeft)
            {
                restPosition.translation = new Vector(80f, 120f, 0f);
            }
            else
            {
                restPosition.translation = new Vector(-80f, 120f, 0f);
                restPosition.MirrorX();
            }
            return(testHand.TransformedCopy(restPosition));
        }
Beispiel #2
0
        /// <summary>
        /// Returns a test Leap Hand object transformed by the leftHandTransform argument. If the Leap hand is
        /// a right hand, the position and rotation of the Hand will be mirrored along the X axis (so you can provide
        /// LeapTransform to construct both left and right hands.
        /// </summary>
        public static Hand MakeTestHand(bool isLeft, LeapTransform leftHandTransform, int frameId = 0, int handId = 0)
        {
            if (!isLeft)
            {
                leftHandTransform.translation = new Vector(-leftHandTransform.translation.x, leftHandTransform.translation.y, leftHandTransform.translation.z);

                leftHandTransform.rotation = new LeapQuaternion(-leftHandTransform.rotation.x,
                                                                leftHandTransform.rotation.y,
                                                                leftHandTransform.rotation.z,
                                                                -leftHandTransform.rotation.w);

                leftHandTransform.MirrorX();
            }
            return(MakeTestHand(frameId, handId, isLeft).Transform(leftHandTransform));
        }
        /// <summary>
        /// Returns a test Leap Hand object transformed by the leftHandTransform argument.
        /// If the Leap hand is a right hand, the position and rotation of the Hand will be
        /// mirrored along the X axis (so you can provide LeapTransform to construct both
        /// left and right hands.
        /// </summary>
        public static Hand MakeTestHand(bool isLeft, LeapTransform leftHandTransform,
                                        int frameId       = 0, int handId = 0,
                                        UnitType unitType = UnitType.LeapUnits)
        {
            // Apply the appropriate mirroring if this is a right hand.
            if (!isLeft)
            {
                leftHandTransform.translation = new Vector(-leftHandTransform.translation.x,
                                                           leftHandTransform.translation.y, leftHandTransform.translation.z);

                leftHandTransform.rotation = new LeapQuaternion(-leftHandTransform.rotation.x,
                                                                leftHandTransform.rotation.y,
                                                                leftHandTransform.rotation.z,
                                                                -leftHandTransform.rotation.w);

                leftHandTransform.MirrorX();
            }

            // Leap space is oriented differently than Unity space, so correct for this here.
            var hand = makeLeapSpaceTestHand(frameId, handId, isLeft)
                       .Transform(leftHandTransform);
            var correctingQuaternion     = Quaternion.Euler(90f, 0f, 180f);
            var correctingLeapQuaternion = new LeapQuaternion(correctingQuaternion.x,
                                                              correctingQuaternion.y,
                                                              correctingQuaternion.z,
                                                              correctingQuaternion.w);

            var transformedHand = hand.Transform(new LeapTransform(Vector.Zero,
                                                                   correctingLeapQuaternion));

            if (unitType == UnitType.UnityUnits)
            {
                transformedHand.TransformToUnityUnits();
            }

            return(transformedHand);
        }