Пример #1
0
    float rotationGestureTurnValue()
    {
        float gestureTurnValue = 0;
        float torsoRotation    = skeletonManager.skeletons[characterController.bodyTrackingDeviceID, characterController.kinectPlayerId].torso.rotation.eulerAngles.y;

        if (torsoRotation > 180)
        {
            torsoRotation = (torsoRotation - 360);
        }

        float hmdRotation = 0;

        if (turningGestureType != TurningGestureType.KinectTorsoYaw)
        {
            hmdRotation = coordinateSystem.GetHmdOrientationInMasterFrame().eulerAngles.y;
            if (hmdRotation > 180)
            {
                hmdRotation = (hmdRotation - 360);
            }
        }

        bool kinect2HeuristicsCheckPass = true;

        float hand = 0.5f, wrist = 0.5f, elbow = 0.5f, shoulder = 0.5f;

        if (kinect2Heuristics)
        {
            if (Mathf.Sign(torsoRotation) == -1)
            {
                shoulder = skeletonManager.skeletons[characterController.bodyTrackingDeviceID, characterController.kinectPlayerId].leftShoulder.positionConfidence;
            }
            else
            {
                shoulder = skeletonManager.skeletons[characterController.bodyTrackingDeviceID, characterController.kinectPlayerId].rightShoulder.positionConfidence;
            }

            if (shoulder <= 0.5f || torsoRotation < 30)
            {
                kinect2HeuristicsCheckPass = false;
            }
        }

        switch (turningGestureType)
        {
        case TurningGestureType.HMDYaw:
            if (Mathf.Abs(hmdRotation) > rotationTriggerAngle)
            {
                gestureTurnValue = 1 * Mathf.Sign(hmdRotation);
            }
            break;

        case TurningGestureType.KinectTorsoYaw:
            if (Mathf.Abs(torsoRotation) > rotationTriggerAngle || (kinect2Heuristics && kinect2HeuristicsCheckPass))
            {
                gestureTurnValue = 1 * Mathf.Sign(torsoRotation);
            }
            break;

        case TurningGestureType.HMDToKinectTorsoYaw:
            if (Mathf.Abs(hmdRotation - torsoRotation) > rotationTriggerAngle || (kinect2Heuristics && kinect2HeuristicsCheckPass))
            {
                gestureTurnValue = 1 * Mathf.Sign(hmdRotation);
            }
            break;
        }

        if (GameObject.Find("angleTest"))
        {
            GameObject.Find("angleTest").GetComponent <TextMesh>().text = Mathf.RoundToInt(torsoRotation) + " ( " + rotationTriggerAngle + " )" + " \n " + gestureTurnValue + " \n " + hand + ":" + wrist + ":" + elbow + ":" + shoulder;
        }
        return(gestureTurnValue);
    }