Beispiel #1
0
        public float GetFingerLength(FingerModel finger)
        {
            if (!finger.knuckle || !finger.tip || !finger.tip.bone.reprs.ContainsKey(AvatarModel.key))
            {
                Debug.LogWarning("It was not possible to calculate length for finger " + finger.name);
                return(0.0f);
            }

            float length = 0.0f;

            BoneModel bone = finger.tip.bone;

            length += Vector3.Distance(finger.tip.transformRef.position, bone.transformRef.position);

            for (int i = 0; i < 50; i++)
            {
                if (!bone.parent || bone == finger.knuckle.bone)
                {
                    break;
                }

                length += Vector3.Distance(bone.transformRef.position, bone.parent.transformRef.position);

                bone = bone.parent;
            }

            return(length);
        }
Beispiel #2
0
        public void FingerStart(FingerModel finger)
        {
            finger.part = HumanBodyPart.Finger;

            // Find side
            if (finger.hand == finger.hand.body.leftHand)
            {
                finger.side = Side.Left;
            }
            else if (finger.hand == finger.hand.body.rightHand)
            {
                finger.side = Side.Right;
            }
            else
            {
                finger.side = Side.None;
            }

            // Find finger
            if (finger == finger.hand.thumb)
            {
                finger.finger = HumanFinger.Thumb;
            }
            else if (finger == finger.hand.index)
            {
                finger.finger = HumanFinger.Index;
            }
            else if (finger == finger.hand.middle)
            {
                finger.finger = HumanFinger.Middle;
            }
            else if (finger == finger.hand.ring)
            {
                finger.finger = HumanFinger.Ring;
            }
            else if (finger == finger.hand.pinky)
            {
                finger.finger = HumanFinger.Pinky;
            }
            else
            {
                finger.finger = HumanFinger.None;
            }

            // Clean null bones
            finger.bones.RemoveAll(b => b == null);

            // Find bones
            for (int b = 0; b < finger.bones.Count; b++)
            {
                finger.bones[b].humanBodyBone = AvatarHelpers.GetHumanFingerBone(finger.side, finger.finger, finger.bones.Count - 1 - b);
            }

            // Finger points
            if (!finger.knuckle)
            {
                finger.knuckle = finger.root.point;
            }

            if (!finger.tip)
            {
                List <BoneModel> distalCandidates = finger.bones.FindAll(b => b.children.Count == 0);
                if (distalCandidates.Count == 1 && distalCandidates[0].points.Count > 1)
                {
                    finger.tip = distalCandidates[0].points[1];
                }
                else
                {
                    Debug.LogWarning("Tip not found for finger " + finger.name);
                }
            }

            // Ordered bones
            AvatarHelpers.GetBonesFromRootToTip(finger, finger.bonesFromRootToTip);
        }
Beispiel #3
0
 void UpdateFinger(FingerModel f)
 {
 }