Example #1
0
        /**
         * Returns a copy of this Hand object transformed by the specifid transform matrix.
         */
        public Hand TransformedCopy(LeapTransform trs)
        {
            List <Finger> transformedFingers = new List <Finger>(5);

            for (int f = 0; f < this.Fingers.Count; f++)
            {
                transformedFingers.Add(Fingers[f].TransformedCopy(trs));
            }

            return(new Hand(
                       FrameId,
                       Id,
                       Confidence,
                       GrabStrength,
                       GrabAngle,
                       PinchStrength,
                       PinchDistance,
                       PalmWidth * trs.scale.x,
                       IsLeft,
                       TimeVisible,
                       Arm.TransformedCopy(trs),
                       transformedFingers,
                       trs.TransformPoint(PalmPosition),
                       trs.TransformPoint(StabilizedPalmPosition),
                       trs.TransformVelocity(PalmVelocity),
                       trs.TransformDirection(PalmNormal),
                       trs.TransformDirection(Direction),
                       trs.TransformPoint(WristPosition)
                       ));
        }
        /**
         * Does an in-place rigid transformation of a Finger.
         *
         * @param transform A LeapTransform containing the desired translation, rotation, and scale
         * to be applied to the Finger.
         */
        public static Finger Transform(this Finger finger, LeapTransform transform)
        {
            Bone nextBone = finger.bones[3];

            nextBone.NextJoint = transform.TransformPoint(nextBone.NextJoint);

            finger.TipPosition = nextBone.NextJoint;

            for (int i = 3; i-- != 0;)
            {
                Bone bone = finger.bones[i];

                bone.NextJoint = nextBone.PrevJoint = transform.TransformPoint(bone.NextJoint);

                nextBone.TransformGivenJoints(transform);
                nextBone = bone;
            }

            nextBone.PrevJoint = transform.TransformPoint(nextBone.PrevJoint);
            nextBone.TransformGivenJoints(transform);

            finger.TipVelocity           = transform.TransformVelocity(finger.TipVelocity);
            finger.Direction             = finger.bones[2].Direction;
            finger.StabilizedTipPosition = transform.TransformPoint(finger.StabilizedTipPosition);
            finger.Width  *= Math.Abs(transform.scale.x);
            finger.Length *= Math.Abs(transform.scale.z);

            return(finger);
        }
        /**
         * Does an in-place rigid transformation of a Bone.
         *
         * @param transform A LeapTransform containing the desired translation, rotation, and scale
         * -    *  to be applied to the bone.
         */
        public static Bone Transform(this Bone bone, LeapTransform transform)
        {
            bone.PrevJoint = transform.TransformPoint(bone.PrevJoint);
            bone.NextJoint = transform.TransformPoint(bone.NextJoint);

            bone.TransformGivenJoints(transform);

            return(bone);
        }
Example #4
0
 /**
  * Creates a copy of this arm, transformed by the specified transform.
  *
  * @param trs A LeapTransform containing the desired translation, rotation, and scale
  * of the copied arm.
  * @since 3.0
  */
 public new Arm TransformedCopy(LeapTransform trs)
 {
     return(new Arm(trs.TransformPoint(PrevJoint),
                    trs.TransformPoint(NextJoint),
                    trs.TransformPoint(Center),
                    trs.TransformDirection(Direction),
                    Length * trs.scale.z,
                    Width * trs.scale.x,
                    trs.TransformQuaternion(Rotation)));
 }
Example #5
0
 /**
  * Creates a copy of this finger, transformed by the specified transform.
  *
  * @param trs A LeapTransform containing the desired translation, rotation, and scale
  * of the copied finger.
  * @since 3.0
  */
 public Finger TransformedCopy(LeapTransform trs)
 {
     return(new Finger(_frameId,
                       HandId,
                       Id % 10, //remove hand portion of finger Id
                       TimeVisible,
                       trs.TransformPoint(TipPosition),
                       trs.TransformVelocity(TipVelocity),
                       trs.TransformDirection(Direction),
                       trs.TransformPoint(StabilizedTipPosition),
                       Width * trs.scale.x,
                       Length * trs.scale.z,
                       IsExtended,
                       Type,
                       _bones[0].TransformedCopy(trs),
                       _bones[1].TransformedCopy(trs),
                       _bones[2].TransformedCopy(trs),
                       _bones[3].TransformedCopy(trs)));
 }
        /**
         * Does an in-place rigid transformation of a Hand.
         *
         * @param transform A LeapTransform containing the desired translation, rotation, and scale
         * to be applied to the Hand.
         */
        public static Hand Transform(this Hand hand, LeapTransform transform)
        {
            hand.PalmPosition           = transform.TransformPoint(hand.PalmPosition);
            hand.StabilizedPalmPosition = transform.TransformPoint(hand.StabilizedPalmPosition);
            hand.PalmVelocity           = transform.TransformVelocity(hand.PalmVelocity);
            hand.PalmNormal             = transform.TransformDirection(hand.PalmNormal);
            hand.Direction     = transform.TransformDirection(hand.Direction);
            hand.WristPosition = transform.TransformPoint(hand.WristPosition);
            hand.PalmWidth    *= Math.Abs(transform.scale.x);
            hand.Rotation      = transform.TransformQuaternion(hand.Rotation);

            hand.Arm.Transform(transform);

            for (int i = 5; i-- != 0;)
            {
                hand.Fingers[i].Transform(transform);
            }

            return(hand);
        }
Example #7
0
 /**
  * Creates a copy of this finger, transformed by the specified transform.
  *
  * @param trs A LeapTransform containing the desired translation, rotation, and scale
  * of the copied finger.
  * @since 3.0
  */
 public Finger TransformedCopy(LeapTransform trs)
 {
     return new Finger(_frameId,
                 HandId,
                 Id % 10, //remove hand portion of finger Id
                 TimeVisible,
                 trs.TransformPoint(TipPosition),
                 trs.TransformVelocity(TipVelocity),
                 trs.TransformDirection(Direction),
                 trs.TransformPoint(StabilizedTipPosition),
                 Width * trs.scale.x,
                 Length * trs.scale.z,
                 IsExtended,
                 Type,
                 _bones[0].TransformedCopy(trs),
                 _bones[1].TransformedCopy(trs),
                 _bones[2].TransformedCopy(trs),
                 _bones[3].TransformedCopy(trs));
 }
Example #8
0
 /**
  * Creates a copy of this arm, transformed by the specified transform.
  *
  * @param trs A LeapTransform containing the desired translation, rotation, and scale
  * of the copied arm.
  * @since 3.0
  */
 public new Arm TransformedCopy(LeapTransform trs)
 {
     return new Arm(trs.TransformPoint(PrevJoint),
       trs.TransformPoint(NextJoint),
       trs.TransformPoint(Center),
       trs.TransformDirection(Direction),
       Length * trs.scale.z,
       Width * trs.scale.x,
       trs.TransformQuaternion(Rotation));
 }