Kinect.KinectManager.CheckForCalibrationPose C# (CSharp) Method

CheckForCalibrationPose() private method

private CheckForCalibrationPose ( Int64 UserId, int bodyIndex, KinectGestures calibrationGesture ) : bool
UserId Int64
bodyIndex int
calibrationGesture KinectGestures
return bool
        private bool CheckForCalibrationPose(Int64 UserId, int bodyIndex, KinectGestures.Gestures calibrationGesture)
        {
            if (calibrationGesture == KinectGestures.Gestures.None)
                return true;

            KinectGestures.GestureData gestureData = playerCalibrationData.ContainsKey(UserId) ?
                playerCalibrationData[UserId] : new KinectGestures.GestureData();

            // init gesture data if needed
            if (gestureData.userId != UserId)
            {
                gestureData.userId = UserId;
                gestureData.gesture = calibrationGesture;
                gestureData.state = 0;
                gestureData.timestamp = Time.realtimeSinceStartup;
                gestureData.joint = 0;
                gestureData.progress = 0f;
                gestureData.complete = false;
                gestureData.cancelled = false;
            }

            // get joint positions and tracking
            int iAllJointsCount = sensorData.jointCount;
            bool[] playerJointsTracked = new bool[iAllJointsCount];
            Vector3[] playerJointsPos = new Vector3[iAllJointsCount];


            int[] aiNeededJointIndexes = KinectGestures.GetNeededJointIndexes(instance);
            int iNeededJointsCount = aiNeededJointIndexes.Length;

            for (int i = 0; i < iNeededJointsCount; i++)
            {
                int joint = aiNeededJointIndexes[i];

                if (joint >= 0)
                {
                    KinectInterop.JointData jointData = bodyFrame.bodyData[bodyIndex].joint[joint];

                    playerJointsTracked[joint] = jointData.trackingState != KinectInterop.TrackingState.NotTracked;
                    playerJointsPos[joint] = jointData.kinectPos;
                }
            }

            // estimate the gesture progess
            KinectGestures.CheckForGesture(UserId, ref gestureData, Time.realtimeSinceStartup,
                ref playerJointsPos, ref playerJointsTracked);
            playerCalibrationData[UserId] = gestureData;

            // check if gesture is complete
            if (gestureData.complete)
            {
                gestureData.userId = 0;
                playerCalibrationData[UserId] = gestureData;

                return true;
            }

            return false;
        }
#endif
KinectManager