/**
  * Constructs a finger.
  *
  * Generally, you should not create your own finger objects. Such objects will not
  * have valid tracking data. Get valid finger objects from a hand in a frame
  * received from the service.
  *
  * @param frameId The id of the frame this finger appears in.
  * @param handId The id of the hand this finger belongs to.
  * @param fingerId The id of this finger (handId + 0-4 for finger position).
  * @param timeVisible How long this instance of the finger has been visible.
  * @param tipPosition The position of the finger tip.
  * @param tipVelocity The velocity of the finger tip.
  * @param direction The pointing direction of the finger.
  * @param stabilizedTipPosition The stabilized tip position.
  * @param width The average width of the finger.
  * @param length The length of the finger.
  * @param isExtended Whether the finger is more-or-less straight.
  * @param type The finger name.
  * @param metacarpal The first bone of the finger (inside the hand).
  * @param proximal The second bone of the finger
  * @param intermediate The third bone of the finger.
  * @param distal The end bone.
  * @since 3.0
  */
 public Finger(long frameId,
               int handId,
               int fingerId,
               float timeVisible,
               Vector tipPosition,
               Vector tipVelocity,
               Vector direction,
               Vector stabilizedTipPosition,
               float width,
               float length,
               bool isExtended,
               Finger.FingerType type,
               Bone metacarpal,
               Bone proximal,
               Bone intermediate,
               Bone distal)
 {
   Type = type;
   _bones[0] = metacarpal;
   _bones[1] = proximal;
   _bones[2] = intermediate;
   _bones[3] = distal;
   _frameId = frameId;
   Id = (handId * 10) + fingerId;
   HandId = handId;
   TipPosition = tipPosition;
   TipVelocity = tipVelocity;
   Direction = direction;
   Width = width;
   Length = length;
   IsExtended = isExtended;
   StabilizedTipPosition = stabilizedTipPosition;
   TimeVisible = timeVisible;
 }
Exemple #2
0
 public Finger(int frameId,
                    int handId, 
                    int fingerId,
                    float timeVisible,
                    Vector tipPosition,
                    Vector tipVelocity,
                    Vector direction,
                    Vector stabilizedTipPosition,
                    float width,
                    float length,
                    bool isExtended,
                    Finger.FingerType type,
                    Bone metacarpal,
                    Bone proximal,
                    Bone intermediate,
                    Bone distal)
 {
     _type = type;
     _bones [0] = metacarpal;
     _bones [1] = proximal;
     _bones [2] = intermediate;
     _bones [3] = distal;
     _frameId = frameId;
     _id = (handId * 10) + fingerId;
     _handID = handId;
     _tipPosition = tipPosition;
     _tipVelocity = tipVelocity;
     _direction = direction;
     _width = width;
     _length = length;
     _isExtended = isExtended;
     _isValid = false;
     _stabilizedTipPosition = stabilizedTipPosition;
     _timeVisible = timeVisible;
 }
Exemple #3
0
    private Vector3 VectorConvert(Leap.Bone leapBone)
    {
        Vector3 vec3;

        vec3.x = leapBone.Center.x;
        vec3.y = leapBone.Center.y;
        vec3.z = leapBone.Center.z;

        return(vec3);
    }
 public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
 {
     Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
       Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
       Vector center = (nextJoint + prevJoint) * .5f;
       float length = (nextJoint - prevJoint).Magnitude;
       Vector direction = (nextJoint - prevJoint) / length;
       LeapQuaternion rotation = new LeapQuaternion(bone.rotation);
       return new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, rotation);
 }
Exemple #5
0
    void IHandDataSource.UpdatePose(Hand hand)
    {
        if (leapService == null || leapService.IsConnected() == false)
        {
            return;
        }

        var handData = leapService.CurrentFrame.Hands.Find(h => (h.IsLeft && hand.HandID == Hand.HandType.Left) || (h.IsRight && hand.HandID == Hand.HandType.Right));

        if (handData == null)
        {
            return;
        }

        //foreach(Hand.HandJoint joint in System.Enum.GetValues(typeof(Hand.HandJoint))){

        //Update all joint spheres in the fingers
        foreach (var finger in handData.Fingers)
        {
            for (int j = 1; j < 4; j++)
            {
                Hand.HandJoint joint           = hand.getFingerJointIndex((int)finger.Type, j - 1);
                Transform      jointTransform  = hand.GetJoint(joint);
                Vector3        initialPosition = jointTransform.position;

                Leap.Bone currentBone = finger.Bone((Leap.Bone.BoneType)j);

                //Vector3.AngleBetween  currentBone.Direction;

                Vector3 nextJointPos = currentBone.NextJoint.ToVector3();
                Vector3 prevJointPos = currentBone.PrevJoint.ToVector3();

                // if(finger.Type == Leap.Finger.FingerType.TYPE_INDEX && j == 1){
                //     Debug.Log(joint.ToString() + " " + angle);
                // }


                //jointTransform.RotateAroundLocal()


                //currentBone.


                //Quaternion newRot = jointTransform.rotation;
                jointTransform.rotation = Quaternion.LookRotation(nextJointPos - prevJointPos);
                //jointTransform.rotation = Quaternion.LookRotation(nextJointPos - prevJointPos, Vector3.up);

                //jointTransform.position = initialPosition
                //jointTransform.rotation = newRot;
            }
        }
    }
 static Bone MakeBone(Bone.BoneType name, Vector proximalPosition, float length, float width, Vector direction, Vector up)
 {
     Matrix basis = new Matrix();
     basis.zBasis = direction;
     basis.yBasis = up;
     basis.xBasis = direction.Cross(up).Normalized;
     return new Bone(
         proximalPosition,
         proximalPosition + direction * length,
         Vector.Lerp(proximalPosition, proximalPosition + direction * length, 2),
         direction,
         length,
         width,
         name,
         basis);
 }
        public LeapBone(Leap.Bone bone)
        {
            //Create bone object
            boneObject = new GameObject();

            //Set bone object name
            boneObject.name = "Bone";

            //Create bone renderer
            boneRenderer = boneObject.AddComponent <LineRenderer> ();

            //Set renderer properties
            boneRenderer.material = new Material(Shader.Find("Particles/Additive"));
            boneRenderer.SetWidth(2, 2);
            boneRenderer.SetColors(Color.white, Color.white);

            //Draw bone
            boneRenderer.SetVertexCount(2);
            boneRenderer.SetPosition(0, new Vector3(bone.PrevJoint.x, bone.PrevJoint.y, -bone.PrevJoint.z));
            boneRenderer.SetPosition(1, new Vector3(bone.NextJoint.x, bone.NextJoint.y, -bone.NextJoint.z));

            //Create previous joint object
            preJointObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            //Set previous joint object name
            preJointObject.name = "Joint";

            //Save leap bone data
            this.bone = bone;


            //Set previous joint position
            //Reverse z coordinate
            preJointObject.transform.position = new Vector3(bone.PrevJoint.x, bone.PrevJoint.y, -bone.PrevJoint.z);

            //Set bone color
            boneObject.transform.renderer.material.color = Color.white;

            //Set previous joint color
            preJointObject.transform.renderer.material.color = Color.yellow;

            //Set bone size
            boneObject.transform.localScale = new Vector3(scale, scale, scale);

            //Set previous joint size
            preJointObject.transform.localScale = new Vector3(scale, scale, scale);
        }
        //Update the bone
        public void UpdateBone(Leap.Bone bone)
        {
            if (!bone.IsValid)
            {
                return;
            }

            //Refresh leap bone data
            this.bone = bone;

            //Draw bone
            boneRenderer.SetPosition(0, new Vector3(bone.PrevJoint.x, bone.PrevJoint.y, -bone.PrevJoint.z));
            boneRenderer.SetPosition(1, new Vector3(bone.NextJoint.x, bone.NextJoint.y, -bone.NextJoint.z));

            //Set previous joint posiiton
            //Reverse z coordinate
            preJointObject.transform.position = new Vector3(bone.PrevJoint.x, bone.PrevJoint.y, -bone.PrevJoint.z);
        }
Exemple #9
0
    //1,DISTAL(tip) 2,INTERMEDIATE 3,PROXIMAL
    // Update is called once per frame
    void Update()
    {
        Leap.Frame frame = controller.GetFrame();
        if (gestureOption == 0)
        {
            hands = frame.Hands;
            Leap.Hand hand = hands.Leftmost;
            //Debug.Log ("here");
            if (hand.IsValid && hand.IsLeft)
            {
                Leap.FingerList fingers = hand.Fingers;
                Leap.Vector     tipV    = fingers[0].TipVelocity;
                float           tipVmag = tipV.Magnitude;
                //Leap.Vector tipV2 = fingers[1].TipVelocity;
                Leap.Bone bone = fingers[0].Bone(Leap.Bone.BoneType.TYPE_DISTAL);
                //Leap.Bone bone2 = fingers[1].Bone (Leap.Bone.BoneType.TYPE_DISTAL);

                float distFromBoneToPalm = bone.Center.DistanceTo(hand.PalmPosition);
                float palmDirectionSign  = hand.PalmNormal.Dot(vecUpInLeapForm);

                //Debug.Log (distFromBoneToPalm + " " + palmDirectionSign + " " + tipVmag + " " + hand.Confidence);
                //Debug.Log (bone.Direction.Pitch);
                if (distFromBoneToPalm < 70 && palmDirectionSign > 0.5 && tipVmag > 30 && hand.Confidence > 0.7)
                {
                    getCollidersInARangeAndSendMessage();
                }
            }
        }
        else if (gestureOption == 1)
        {
            Leap.GestureList gestures = frame.Gestures();
            for (int i = 0; i < gestures.Count; i++)
            {
                if (gestures[i].Type == Leap.Gesture.GestureType.TYPESWIPE)
                {
                    if (gestures[i].IsValid && gestures[i].State == Leap.Gesture.GestureState.STATESTOP)
                    {
                        Debug.Log("Yes");
                        getCollidersInARangeAndSendMessage();
                    }
                }
            }
        }
    }
Exemple #10
0
 /**
  * Constructs a new Bone object.
  *
  * @param prevJoint The proximal end of the bone (closest to the body)
  * @param nextJoint The distal end of the bone (furthest from the body)
  * @param center The midpoint of the bone
  * @param direction The unit direction vector pointing from prevJoint to nextJoint.
  * @param length The estimated length of the bone.
  * @param width The estimated average width of the bone.
  * @param type The type of finger bone.
  * @param basis The matrix representing the orientation of the bone.
  * @since 3.0
  */
 public Bone(Vector prevJoint,
     Vector nextJoint,
     Vector center,
     Vector direction,
     float length,
     float width,
     Bone.BoneType type,
     LeapQuaternion rotation
     )
 {
     PrevJoint = prevJoint;
       NextJoint = nextJoint;
       Center = center;
       Direction = direction;
       Rotation = rotation;
       Length = length;
       Width = width;
       Type = type;
 }
Exemple #11
0
 public Arm(Vector prevJoint,
             Vector nextJoint,
             Vector center,
             Vector direction,
             float length,
             float width,
             Bone.BoneType type,
             Matrix basis
           )
     : base(prevJoint,
                     nextJoint,
                     center,
                     direction,
                     length,
                     width,
                     type,
                     basis)
 {
 }
Exemple #12
0
 /**
  * Constructs a new Bone object.
  *
  * @param prevJoint The proximal end of the bone (closest to the body)
  * @param nextJoint The distal end of the bone (furthest from the body)
  * @param center The midpoint of the bone
  * @param direction The unit direction vector pointing from prevJoint to nextJoint.
  * @param length The estimated length of the bone.
  * @param width The estimated average width of the bone.
  * @param type The type of finger bone.
  * @param basis The matrix representing the orientation of the bone.
  * @since 3.0
  */
 public Bone(Vector prevJoint,
             Vector nextJoint,
             Vector center,
             Vector direction,
             float length,
             float width,
             Bone.BoneType type,
             Matrix basis
             )
 {
   PrevJoint = prevJoint;
   NextJoint = nextJoint;
   Center = center;
   Direction = direction;
   Basis = basis;
   Length = length;
   Width = width;
   Type = type;
 }
Exemple #13
0
 public Bone(Vector prevJoint,
             Vector nextJoint,
             Vector center,
             Vector direction,
             float length,
             float width,
             Bone.BoneType type,
             Matrix basis
             )
 {
     _prevJoint = prevJoint;
     _nextJoint = nextJoint;
     _center = center;
     _direction = direction;
     _basis = basis;
     _length = length;
     _width = width;
     _type = type;
     _isValid = true;
 }
        static Finger MakeFinger(Finger.FingerType name, Vector position, Vector forward, Vector up, float[] jointLengths, 
            int frameId, int handId, int fingerId)
        {
            Bone[] bones = new Bone[5];
            float proximalDistance = -jointLengths[0];
            Bone metacarpal = MakeBone (Bone.BoneType.TYPE_METACARPAL, position + forward * proximalDistance, jointLengths[0], 8f, forward, up);
            proximalDistance += jointLengths[0];
            bones[0] = metacarpal;

            Bone proximal = MakeBone (Bone.BoneType.TYPE_PROXIMAL,  position + forward * proximalDistance, jointLengths[1], 8f, forward, up);
            proximalDistance += jointLengths[1];
            bones[1] = proximal;

            Bone intermediate = MakeBone (Bone.BoneType.TYPE_INTERMEDIATE,  position + forward * proximalDistance, jointLengths[2], 8f, forward, up);
            proximalDistance += jointLengths[2];
            bones[2] = intermediate;

            Bone distal = MakeBone (Bone.BoneType.TYPE_DISTAL,  position + forward * proximalDistance, jointLengths[3], 8f, forward, up);
            bones[3] = distal;

            return new Finger(frameId,
            handId,
            fingerId,
            0.0f,
            position,
            new Vector(0,0,0),
            forward,
            position,
            8f,
            jointLengths[1] + jointLengths[2] +jointLengths[3],
            true,
            name,
            bones[0],
            bones[1],
            bones[2],
            bones[3]);
        }
Exemple #15
0
 /**
  * Compare Bone object equality.
  *
  * Two Bone objects are equal if and only if both Bone objects represent the
  * exact same physical bone in the same frame and both Bone objects are valid.
  * @since 2.0
  */
 public bool Equals(Bone other)
 {
     return  this.IsValid &&
             other.IsValid &&
             (this.Center == other.Center) &&
             (this.Direction == other.Direction) &&
             (this.Length == other.Length);
 }
         static Bone MakeBone(Bone.BoneType name, Vector proximalPosition, float length, float width, Vector direction, Vector up, bool isLeft){

           LeapQuaternion rotation = UnityEngine.Quaternion.LookRotation(-direction.ToVector3(), up.ToVector3()).ToLeapQuaternion();

           return new Bone(
                proximalPosition,
                proximalPosition + direction * length,
                Vector.Lerp(proximalPosition, proximalPosition + direction * length, .5f),
                direction,
                length,
                width,
                name,
                rotation);
        }
 public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
 {
   Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
   Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
   Vector center = (nextJoint + prevJoint) * .5f;
   float length = (nextJoint - prevJoint).Magnitude;
   Vector direction = (nextJoint - prevJoint) / length;
   Matrix basis = new Matrix(bone.basis.x_basis.x,
                      bone.basis.x_basis.y,
                      bone.basis.x_basis.z,
                      bone.basis.y_basis.x,
                      bone.basis.y_basis.y,
                      bone.basis.y_basis.z,
                      bone.basis.z_basis.x,
                      bone.basis.z_basis.y,
                      bone.basis.z_basis.z);
   return new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, basis);
 }
 private static JointType BoneType2JointType(JointType fingerType, Bone.BoneType type)
 {
     int jt;
     switch (type)
     {
         case Bone.BoneType.TYPE_METACARPAL:
             jt = 1;
             break;
         case Bone.BoneType.TYPE_PROXIMAL:
             jt = 2;
             break;
         case Bone.BoneType.TYPE_INTERMEDIATE:
             jt = 3;
             break;
         case Bone.BoneType.TYPE_DISTAL:
             jt = 4;
             break;
         default:
             return JointType.UNSPECIFIED;
     }
     jt += fingerType.ToInt();
     return (JointType) jt;
 }
 private static float ExtractLength(Bone bone)
 {
     var len = bone.Length;
     if (len <= 0)
     {
         switch (bone.Type)
         {
             case Bone.BoneType.TYPE_DISTAL:
                 len = 18;
                 break;
             case Bone.BoneType.TYPE_INTERMEDIATE:
                 len = 20;
                 break;
             case Bone.BoneType.TYPE_PROXIMAL:
                 len = 25;
                 break;
             case Bone.BoneType.TYPE_METACARPAL:
                 len = 60;
                 break;
         }
     }
     return len;
 }
Exemple #20
0
 /**
  * The bone at a given bone index on this finger.
  *
  * \include Bone_iteration.txt
  *
  * @param boneIx An index value from the Bone::Type enumeration identifying the
  * bone of interest.
  * @returns The Bone that has the specified bone type.
  * @since 2.0
  */
 public Bone Bone(Bone.BoneType boneIx)
 {
     return _bones[(int)boneIx];
 }
    void Update()
    {
        Leap.Frame frame = _provider.CurrentFrame;

        if (frame != null)
        {
            foreach (Leap.Hand hand in frame.Hands)
            {
                GameObject measured = hand.IsLeft ? lmeasured : rmeasured;

                Leap.Bone tip = hand.Fingers[0].Bone(Leap.Bone.BoneType.TYPE_DISTAL);

                // why is this necessary
                Leap.Vector v  = tip.NextJoint;
                Vector3     uv = new Vector3(v.x, v.y, v.z);

                Leap.LeapQuaternion q  = tip.Rotation;
                Quaternion          uq = new Quaternion(q.x, q.y, q.z, q.w);

                measured.transform.position = uv;
                measured.transform.rotation = uq;
            }
        }

        bool lTriggerDown = Input.GetAxis("LeftVRTriggerAxis") > 0.5;
        bool rTriggerDown = Input.GetAxis("RightVRTriggerAxis") > 0.5;
        bool triggerDown  = lTriggerDown || rTriggerDown;

        ltruth.SetActive(lTriggerDown);
        rtruth.SetActive(rTriggerDown);
        lmeasured.SetActive(lTriggerDown);
        rmeasured.SetActive(rTriggerDown);

        if (triggerDown)
        {
            if (!lastTriggerDown)
            {
                leapOrigin.transform.localPosition = Vector3.zero;
                leapOrigin.transform.localRotation = Quaternion.identity;

                truths       = new List <Vector3>();
                measurements = new List <Vector3>();
            }
            else
            {
                Transform cam = Camera.main.transform;

                if (lmeasured.activeInHierarchy)
                {
                    truths.Add(cam.InverseTransformPoint(ltruth.transform.position));
                    measurements.Add(cam.InverseTransformPoint(lmeasured.transform.position));
                }
                if (rmeasured.activeInHierarchy)
                {
                    truths.Add(cam.InverseTransformPoint(rtruth.transform.position));
                    measurements.Add(cam.InverseTransformPoint(rmeasured.transform.position));
                }
            }
        }
        else
        {
            if (lastTriggerDown)
            {
                Vector3 truthCentroid       = new Vector3(0, 0, 0);
                Vector3 measurementCentroid = new Vector3(0, 0, 0);

                int l = truths.Count;

                foreach (Vector3 p in measurements)
                {
                    measurementCentroid += p;
                }
                measurementCentroid /= truths.Count;

                foreach (Vector3 p in truths)
                {
                    truthCentroid += p;
                }
                truthCentroid /= truths.Count;


                double[,] A = new double[3, l];
                double[,] B = new double[3, l];

                int i = 0;
                foreach (Vector3 p in measurements)
                {
                    Vector3 po = p - measurementCentroid;
                    A[0, i] = po.x;
                    A[1, i] = po.y;
                    A[2, i] = po.z;
                    i++;
                }
                i = 0;
                foreach (Vector3 p in truths)
                {
                    Vector3 po = p - truthCentroid;
                    B[0, i] = po.x;
                    B[1, i] = po.y;
                    B[2, i] = po.z;
                    i++;
                }
                double[,] BAT = new double[3, 3];
                alglib.rmatrixgemm(3, 3, l, 1, B, 0, 0, 0, A, 0, 0, 1, 0, ref BAT, 0, 0);

                double[] W = new double[3];
                double[,] U  = new double[3, 3];
                double[,] VT = new double[3, 3];

                alglib.rmatrixsvd(BAT, 3, 3, 2, 2, 2, out W, out U, out VT);

                double[,] UVT = new double[3, 3];
                alglib.rmatrixgemm(3, 3, 3, 1, U, 0, 0, 0, VT, 0, 0, 0, 0, ref UVT, 0, 0);

                double     w   = Math.Sqrt(1 + UVT[0, 0] + UVT[1, 1] + UVT[2, 2]) / 2.0;
                double     iw4 = 1.0 / (w * 4);
                Quaternion q   = new Quaternion((float)((UVT[2, 1] - UVT[1, 2]) * iw4),
                                                (float)((UVT[0, 2] - UVT[2, 0]) * iw4),
                                                (float)((UVT[1, 0] - UVT[0, 1]) * iw4), (float)w);
                Quaternion iq = Quaternion.Inverse(q);

                Vector3 mtt = truthCentroid - measurementCentroid;

                leapOrigin.transform.localPosition = truthCentroid - q * measurementCentroid;
                leapOrigin.transform.localRotation = q;

                StreamWriter writer = new StreamWriter("stored_calibration.txt");
                writer.Write(String.Format("{0} {1} {2} {3} {4} {5} {6}",
                                           leapOrigin.transform.localPosition.x,
                                           leapOrigin.transform.localPosition.y,
                                           leapOrigin.transform.localPosition.z,
                                           leapOrigin.transform.localRotation.x,
                                           leapOrigin.transform.localRotation.y,
                                           leapOrigin.transform.localRotation.z,
                                           leapOrigin.transform.localRotation.w
                                           ));
                writer.Close();

                truths       = null;
                measurements = null;
            }
        }

        lastTriggerDown = triggerDown;
    }
Exemple #22
0
    public void UpdateFromLeapHand(Leap.Hand hand)
    {
        Debug.Assert(hand.IsLeft != right);

        Vector3    v = FixV(hand.Arm.Center);
        Quaternion q = FixQ(hand.Arm.Rotation);

        points[POINT_ELBOW] = v - (q * Vector3.forward * hand.Arm.Length * 0.5f);
        points[POINT_WRIST] = v + (q * Vector3.forward * hand.Arm.Length * 0.5f);
        boneCapsules[BONE_ARM][0].radius = hand.Arm.Width * 0.5f;

        leapReportedBoneAngles[BONE_ARM] = FixQ(hand.Arm.Rotation);

        for (int f = 0; f < 5; f++)
        {
            Leap.Bone lbone = hand.Fingers[f].bones[1];
            float     rad   = lbone.Width * 0.5f;

            points[POINT_KNUCKLE[f]] = FixV(lbone.PrevJoint);
            points[POINT_LOJOINT[f]] = FixV(lbone.NextJoint);

            lbone = hand.Fingers[f].bones[3];

            points[POINT_HIJOINT[f]] = FixV(lbone.PrevJoint);
            points[POINT_TIP[f]]     = FixV(lbone.NextJoint);

            for (int b = 0; b < 4; b++)
            {
                boneCapsules[f * 4 + b][0].radius = rad;
                leapReportedBoneAngles[f * 4 + b] = FixQ(hand.Fingers[f].bones[b].Rotation);
            }
        }

        for (int p = 0; p < NUM_BONES; p++)
        {
            boneCapsules[p][0].length = pointDistanceFromParent[p] = Vector3.Distance(points[p], points[POINT_PARENT[p]]);

            //joint retraction, might help with physics in some cases to not have capsules overlappin

            /*if (p < 20 && p % 4 > 0 && p % 4 < 3)
             * {
             *  boneCapsules[p][0].length -= 0.006f;
             * }*/
        }


        //cosmetic changes
        float   pArmRadius       = boneCapsules[BONE_ARM][0].radius;
        Vector3 pPalmForward     = leapReportedBoneAngles[BONE_FINGER_INPALM[2]] * Vector3.forward;
        Vector3 pPalmFront       = leapReportedBoneAngles[BONE_FINGER_INPALM[2]] * Vector3.down;
        Vector3 pSidewaysToThumb = leapReportedBoneAngles[BONE_FINGER_INPALM[2]] * Vector3.right * (right ? -1f : 1f);

        boneCapsules[BONE_ARM][0].radius -= 0.006f;

        SetPrincipalCapsulePoints(BONE_FINGER_INPALM[0],
                                  points[POINT_WRIST] + pArmRadius * -0.4f * pSidewaysToThumb - pArmRadius * 0.2f * pPalmFront - 0.01f * pPalmForward,
                                  points[POINT_KNUCKLE[0]] + pArmRadius * -0.05f * pPalmFront + 0.002f * pPalmForward - 0.002f * pSidewaysToThumb);
        SetPrincipalCapsulePoints(BONE_FINGER_INPALM[1],
                                  points[POINT_WRIST] + pArmRadius * 0.35f * pSidewaysToThumb + pArmRadius * 0.1f * pPalmFront,
                                  points[POINT_KNUCKLE[1]] - 0.002f * pSidewaysToThumb);
        SetPrincipalCapsulePoints(BONE_FINGER_INPALM[4],
                                  points[POINT_WRIST] + pArmRadius * -0.35f * pSidewaysToThumb + pArmRadius * 0.2f * pPalmFront,
                                  points[POINT_KNUCKLE[4]] + 0.002f * pSidewaysToThumb);

        for (int f = 0; f < 5; f++)
        {
            boneCapsules[BONE_FINGER_INPALM[f]][0].radius += (f == 0) ? 0.005f : ((f == 1 || f == 4) ? 0.0035f : 0.0025f);
        }
        boneCapsules[BONE_FINGER_LO[0]][0].radius += 0.0015f;
    }
Exemple #23
0
 /**
  * Compare Bone object equality.
  *
  * Two Bone objects are equal if and only if both Bone objects represent the
  * exact same physical bone in the same frame and both Bone objects are valid.
  * @since 2.0
  */
 public bool Equals(Bone other)
 {
   return Center == other.Center && Direction == other.Direction && Length == other.Length;
 }
 private static SerializableBone ToSerializableBone(Bone bone)
 {
     return new SerializableBone
     {
         prevJoint = ToSerializableVector(bone.PrevJoint),
         nextJoint = ToSerializableVector(bone.NextJoint),
         center = ToSerializableVector(bone.Center),
         direction = ToSerializableVector(bone.Direction),
         width = bone.Width,
         length = bone.Length,
         type = bone.Type,
         rotation = ToSerializableQuaternion(bone.Rotation)
     };
 }