Exemple #1
0
        public void Init(List <PlayerGestureData> _playerGestureDatas)
        {
            playerGestureDatas = new PlayerGestureData[_playerGestureDatas.Count];
            Array.Copy(_playerGestureDatas.ToArray(), playerGestureDatas, _playerGestureDatas.Count);

            gestureJudgeData = new GestureJudgeData[_playerGestureDatas.Count];
            for (int i = 0; i < gestureJudgeData.Length; i++)
            {
                gestureJudgeData[i] = new GestureJudgeData();
            }
        }
Exemple #2
0
        private int GetJointPos(GestureJudgeData gestureJudge, PlayerGestureData playerGestureData, KinectInterop.JointType[] jointTypes)
        {
            for (int i = 0; i < jointTypes.Length; i++)
            {
                if (!KinectManager.Instance.IsInitialized())
                {
                    return(0);
                }
            }
            gesturesValue.Clear();
            for (int i = 0; i < 2; i++)
            {
                Vector3 pos1 = KINECTManager.Instance.GetUserIDJointPos(userID, jointTypes[i], Camera.main, new Rect(0, 0, 1920, 1080));     //实时关节位置
                Vector3 pos2 = KINECTManager.Instance.GetUserIDJointPos(userID, jointTypes[i + 1], Camera.main, new Rect(0, 0, 1920, 1080)); //实时关节位置

                _Vector3 dir = new _Vector3((pos2 - pos1).normalized);

                PlayerGestureJointData EndPlayerGestures = playerGestureData.playerGestureInfo.GetPlayerGestureJointData(
                    PlayerGestureInfo.GestureType.End, jointTypes[i]);                                                     //获取本地储存结束的关节数据
                PlayerGestureJointData StartPlayerGestures = playerGestureData.playerGestureInfo.GetPlayerGestureJointData(
                    PlayerGestureInfo.GestureType.Start, jointTypes[i]);                                                   //获取本地储存开始的关节数据

                float EndAngle   = Vector3.Angle(EndPlayerGestures.direction.Get(), dir.Get());
                float StartAngle = Vector3.Angle(StartPlayerGestures.direction.Get(), dir.Get());

                if (EndAngle <= playerGestureData.playerGestureInfo.offset)
                {
                    gesturesValue.Add(2);
                }
                else if (StartAngle <= playerGestureData.playerGestureInfo.offset)
                {
                    gesturesValue.Add(1);
                }
                else
                {
                    gesturesValue.Add(0);
                }
            }

            if (!gesturesValue.Contains(0) && !gesturesValue.Contains(1))
            {
                return(2);
            }
            else if (!gesturesValue.Contains(0) && !gesturesValue.Contains(2))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }