/// <summary>
 /// コンストラクタ(ベースとなるJointAngleあり)
 /// </summary>
 /// <param name="baseJointAngle">ベースとなるJointAngle</param>
 public JointAngle(JointAngle baseJointAngle)
 {
     jointIndex   = baseJointAngle.jointIndex;
     coordUnitVec = baseJointAngle.coordUnitVec;
     eulerAngle   = baseJointAngle.eulerAngle;
     Angle        = baseJointAngle.Angle;
 }
Esempio n. 2
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="jointList">関節オブジェクトリスト</param>
 public Frame(List <GameObject> jointList)
 {
     jointAngles = new JointAngle[jointList.Count];
     // 関節情報セット
     // 左肩ピッチ,右肩ピッチに関しては回転方向をヨーに(モデルの座標的に)
     jointAngles [0]  = new JointAngle(0, new Vector3(0, 0, 1), jointList[0].transform.localEulerAngles);
     jointAngles [1]  = new JointAngle(1, new Vector3(0, 0, 1), jointList[1].transform.localEulerAngles);
     jointAngles [2]  = new JointAngle(2, new Vector3(1, 0, 0), jointList[2].transform.localEulerAngles);
     jointAngles [3]  = new JointAngle(3, new Vector3(1, 0, 0), jointList[3].transform.localEulerAngles);
     jointAngles [4]  = new JointAngle(4, new Vector3(1, 0, 0), jointList[4].transform.localEulerAngles);
     jointAngles [5]  = new JointAngle(5, new Vector3(0, 1, 0), jointList[5].transform.localEulerAngles);
     jointAngles [6]  = new JointAngle(6, new Vector3(0, 1, 0), jointList[6].transform.localEulerAngles);
     jointAngles [7]  = new JointAngle(7, new Vector3(0, 1, 0), jointList[7].transform.localEulerAngles);
     jointAngles [8]  = new JointAngle(8, new Vector3(1, 0, 0), jointList[8].transform.localEulerAngles);
     jointAngles [9]  = new JointAngle(9, new Vector3(0, 0, 1), jointList[9].transform.localEulerAngles);
     jointAngles [10] = new JointAngle(10, new Vector3(0, 0, 1), jointList[10].transform.localEulerAngles);
     jointAngles [11] = new JointAngle(11, new Vector3(1, 0, 0), jointList[11].transform.localEulerAngles);
     jointAngles [12] = new JointAngle(12, new Vector3(1, 0, 0), jointList[12].transform.localEulerAngles);
     jointAngles [13] = new JointAngle(13, new Vector3(1, 0, 0), jointList[13].transform.localEulerAngles);
     jointAngles [14] = new JointAngle(14, new Vector3(0, 1, 0), jointList[14].transform.localEulerAngles);
     jointAngles [15] = new JointAngle(15, new Vector3(0, 1, 0), jointList[15].transform.localEulerAngles);
     jointAngles [16] = new JointAngle(16, new Vector3(0, 1, 0), jointList[16].transform.localEulerAngles);
     jointAngles [17] = new JointAngle(17, new Vector3(1, 0, 0), jointList[17].transform.localEulerAngles);
     modelJointList   = jointList;
 }
Esempio n. 3
0
        public bool Compared(IReadOnlyDictionary <JointType, Joint> joints3, List <JointType> jointAngleList,
                             List <Bone> keyBoneList, float angularError, float keyBoneError, out string result)
        {
            result = "";
            //模型当前帧的有关信息
            Dictionary <JointType, Joint> modelJoints = Joints.ToDictionary(o => o.JointType, value => value);

            modelJoints = Skeleton.CoordinateTransformation3D(modelJoints, JointType.SpineMid);
            //待检测的
            joints3 = Skeleton.CoordinateTransformation3D(joints3, JointType.SpineMid);

            IReadOnlyList <JointType> tempJointTypes = jointAngleList != null && jointAngleList.Count > 0
                ? jointAngleList
                : SkeletonDictionary.GetDefaultContrastAngleJoint(); //jointAngleList没有记录关节的话就对比所有的关节

            List <JointAngle> modelJointAngles = Skeleton.GetBodyJointAngleList(modelJoints);
            List <JointAngle> jointAngles      = Skeleton.GetBodyJointAngleList(joints3);

            foreach (JointType jointType in tempJointTypes)
            {
                JointAngle modelAngle = modelJointAngles.First(o => o.Name == jointType);
                JointAngle jointAngle = jointAngles.First(o => o.Name == jointType);
                if (Math.Abs(modelAngle.Angle - jointAngle.Angle) > angularError)
                {
                    result = modelAngle.Angle < 155
                        ? $"请使{BoneNode.SkeletonDictionary.GetJointNameDic()[jointType]}活动到{modelAngle.Angle:###}度"
                        : $"请使{BoneNode.SkeletonDictionary.GetJointNameDic()[jointType]}伸直";
                    return(IsCompared = false);
                }
            }
            IReadOnlyList <Bone> tempBones = keyBoneList != null && keyBoneList.Count > 0
                ? keyBoneList
                : SkeletonDictionary.GetDefaultContrastBones(); //keyBoneList 没有记录骨骼的话就对比所有的骨骼

            List <KeyBone> modelKeyBones = Skeleton.GetBodyAllKeyBones(modelJoints);
            List <KeyBone> keyBones      = Skeleton.GetBodyAllKeyBones(joints3);

            foreach (Bone bone in tempBones)
            {
                KeyBone modelKeyBone = modelKeyBones.First(o => o.Name == bone);
                KeyBone keyBone      = keyBones.First(o => o.Name == bone);
                if (Math.Abs(modelKeyBone.AngleX - keyBone.AngleX) > keyBoneError)
                {
                    return(IsCompared = false);
                }
                if (Math.Abs(modelKeyBone.AngleY - keyBone.AngleY) > keyBoneError)
                {
                    return(IsCompared = false);
                }
                if (Math.Abs(modelKeyBone.AngleZ - keyBone.AngleZ) > keyBoneError)
                {
                    return(IsCompared = false);
                }
            }

            return(IsCompared = true);
        }
 /// <summary>
 /// コンストラクタ(ベースフレームあり)
 /// </summary>
 /// <param name="baseFrame">ベースとなるフレームBase frame.</param>
 public Frame(Frame baseFrame)
 {
     jointAngles = new JointAngle[baseFrame.modelJointList.Count];
     //
     for (int i = 0; i < jointAngles.Length; i++)
     {
         jointAngles [i] = new JointAngle(baseFrame.jointAngles [i]);
     }
     modelJointList = baseFrame.modelJointList;
     transitionTime = baseFrame.transitionTime;
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="jointList">関節オブジェクトリスト</param>
 public Frame(List<GameObject> jointList)
 {
     jointAngles = new JointAngle[jointList.Count];
     // 関節情報セット
     // 左肩ピッチ,右肩ピッチに関しては回転方向をヨーに(モデルの座標的に)
     /*		jointAngles [0]  =  new JointAngle (0 , RotationCoord.Yaw, jointList[0].transform.localEulerAngles);
     jointAngles [1]  =  new JointAngle (1 , RotationCoord.Yaw, jointList[1].transform.localEulerAngles);
     jointAngles [2]  =  new JointAngle (2 , RotationCoord.Roll, jointList[2].transform.localEulerAngles);
     jointAngles [3]  =  new JointAngle (3 , RotationCoord.Roll, jointList[3].transform.localEulerAngles);
     jointAngles [4]  =  new JointAngle (4 , RotationCoord.Roll, jointList[4].transform.localEulerAngles);
     jointAngles [5]  =  new JointAngle (5 , RotationCoord.Pitch, jointList[5].transform.localEulerAngles);
     jointAngles [6]  =  new JointAngle (6 , RotationCoord.Pitch, jointList[6].transform.localEulerAngles);
     jointAngles [7]  =  new JointAngle (7 , RotationCoord.Pitch, jointList[7].transform.localEulerAngles);
     jointAngles [8]  =  new JointAngle (8 , RotationCoord.Roll, jointList[8].transform.localEulerAngles);
     jointAngles [9]  =  new JointAngle (9 , RotationCoord.Yaw, jointList[9].transform.localEulerAngles);
     jointAngles [10] =  new JointAngle (10, RotationCoord.Yaw, jointList[10].transform.localEulerAngles);
     jointAngles [11] =  new JointAngle (11, RotationCoord.Roll, jointList[11].transform.localEulerAngles);
     jointAngles [12] =  new JointAngle (12, RotationCoord.Roll, jointList[12].transform.localEulerAngles);
     jointAngles [13] =  new JointAngle (13, RotationCoord.Roll, jointList[13].transform.localEulerAngles);
     jointAngles [14] =  new JointAngle (14, RotationCoord.Pitch, jointList[14].transform.localEulerAngles);
     jointAngles [15] =  new JointAngle (15, RotationCoord.Pitch, jointList[15].transform.localEulerAngles);
     jointAngles [16] =  new JointAngle (16, RotationCoord.Pitch, jointList[16].transform.localEulerAngles);
     jointAngles [17] =  new JointAngle (17, RotationCoord.Roll, jointList[17].transform.localEulerAngles);
     */
     jointAngles [0]  =  new JointAngle (0 , new Vector3(0, 0, 1), jointList[0].transform.localEulerAngles);
     jointAngles [1]  =  new JointAngle (1 , new Vector3(0, 0, 1), jointList[1].transform.localEulerAngles);
     jointAngles [2]  =  new JointAngle (2 , new Vector3(1, 0, 0), jointList[2].transform.localEulerAngles);
     jointAngles [3]  =  new JointAngle (3 , new Vector3(1, 0, 0), jointList[3].transform.localEulerAngles);
     jointAngles [4]  =  new JointAngle (4 , new Vector3(1, 0, 0), jointList[4].transform.localEulerAngles);
     jointAngles [5]  =  new JointAngle (5 , new Vector3(0, 1, 0), jointList[5].transform.localEulerAngles);
     jointAngles [6]  =  new JointAngle (6 , new Vector3(0, 1, 0), jointList[6].transform.localEulerAngles);
     jointAngles [7]  =  new JointAngle (7 , new Vector3(0, 1, 0), jointList[7].transform.localEulerAngles);
     jointAngles [8]  =  new JointAngle (8 , new Vector3(1, 0, 0), jointList[8].transform.localEulerAngles);
     jointAngles [9]  =  new JointAngle (9 , new Vector3(0, 0, 1), jointList[9].transform.localEulerAngles);
     jointAngles [10] =  new JointAngle (10, new Vector3(0, 0, 1), jointList[10].transform.localEulerAngles);
     jointAngles [11] =  new JointAngle (11, new Vector3(1, 0, 0), jointList[11].transform.localEulerAngles);
     jointAngles [12] =  new JointAngle (12, new Vector3(1, 0, 0), jointList[12].transform.localEulerAngles);
     jointAngles [13] =  new JointAngle (13, new Vector3(1, 0, 0), jointList[13].transform.localEulerAngles);
     jointAngles [14] =  new JointAngle (14, new Vector3(0, 1, 0), jointList[14].transform.localEulerAngles);
     jointAngles [15] =  new JointAngle (15, new Vector3(0, 1, 0), jointList[15].transform.localEulerAngles);
     jointAngles [16] =  new JointAngle (16, new Vector3(0, 1, 0), jointList[16].transform.localEulerAngles);
     jointAngles [17] =  new JointAngle (17, new Vector3(1, 0, 0), jointList[17].transform.localEulerAngles);
     modelJointList = jointList;
 }
 /// <summary>
 /// コンストラクタ(ベースフレームあり)
 /// </summary>
 /// <param name="baseFrame">ベースとなるフレームBase frame.</param>
 public Frame(Frame baseFrame)
 {
     jointAngles = new JointAngle[baseFrame.modelJointList.Count];
     //
     for (int i = 0; i < jointAngles.Length; i++)
         jointAngles [i] = new JointAngle (baseFrame.jointAngles [i]);
     modelJointList = baseFrame.modelJointList;
     transitionTime = baseFrame.transitionTime;
 }
 /// <summary>
 /// コンストラクタ(ベースとなるJointAngleあり)
 /// </summary>
 /// <param name="baseJointAngle">ベースとなるJointAngle</param>
 public JointAngle(JointAngle baseJointAngle)
 {
     jointIndex = baseJointAngle.jointIndex;
     coordUnitVec = baseJointAngle.coordUnitVec;
     eulerAngle = baseJointAngle.eulerAngle;
     Angle = baseJointAngle.Angle;
 }