コード例 #1
0
        Leg GetLeg(IBone leg)
        {
            var bones = leg.Traverse().Where(x => !x.Name.ToLower().Contains("buttock")).ToArray();

            switch (bones.Length)
            {
            case 0:
            case 1:
            case 2:
                throw new NotImplementedException();

            case 3:
                return(new Leg
                {
                    UpperLeg = bones[0],
                    LowerLeg = bones[1],
                    Foot = bones[2],
                });

            default:
                return(new Leg
                {
                    UpperLeg = bones[bones.Length - 4],
                    LowerLeg = bones[bones.Length - 3],
                    Foot = bones[bones.Length - 2],
                    Toes = bones[bones.Length - 1],
                });
            }
        }
コード例 #2
0
        public static Vector3 CenterOfDescendant(this IBone self)
        {
            var sum = Vector3.zero;
            int i   = 0;

            foreach (var x in self.Traverse())
            {
                sum += x.SkeletonLoacalPosition;
                ++i;
            }
            return(sum / i);
        }
コード例 #3
0
        Arm GetArm(IBone shoulder)
        {
            var bones = shoulder.Traverse().ToArray();

            switch (bones.Length)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                throw new NotImplementedException();

            default:
                return(new Arm
                {
                    Shoulder = bones[0],
                    UpperArm = bones[1],
                    LowerArm = bones[2],
                    Hand = bones[3],
                });
            }
        }