예제 #1
0
    private void DetectAndDispatchHeadMotionInput(Vector3 acceleration)
    {
        float magnitude = acceleration.magnitude;
        const float nodTimeDelay = 0.2f;
        const float nodThreshold = 1.05f;
        const float deepNodUpAngle = 5;
        const float deepNodDownAngle = 20;
        float deltaTime = Time.time - lastNodTime;

        // Angle between quaternions 
        Quaternion gazeRotation = Quaternion.LookRotation(Gaze.direction);
        float yawDegrees = Mathf.Atan2(Gaze.direction.x, Gaze.direction.z) * Mathf.Rad2Deg;
        Quaternion rotateAroundAxis = Quaternion.AngleAxis(yawDegrees, Vector3.up);
        Quaternion alignedStartRotation = rotateAroundAxis * startRotation;
        float angle = Quaternion.Angle(gazeRotation, alignedStartRotation);

        //float signedAngle = SignedAngle(gazeRotation, startRotation);
        
        if (isDeepNodding && angle <= deepNodUpAngle)
        {
            // Deep nod up
            isDeepNodding = false;
            choreographer.InputAction(BaseChoreographer.PlayerAction.MOTION_DEEP_NOD_UP);
        }
        else if (angle >= deepNodDownAngle && !isDeepNodding)
        {
            // Deep nod down
            isDeepNodding = true;
            choreographer.InputAction(BaseChoreographer.PlayerAction.MOTION_DEEP_NOD_DOWN);
        }
        else if (deltaTime > nodTimeDelay && magnitude > nodThreshold && !isDeepNodding)
        {
            // Nod gesture
            lastNodTime = Time.time;
            choreographer.InputAction(BaseChoreographer.PlayerAction.MOTION_NOD);
        }

        // TODO(jaween): Detect head tilt gesture

        // Debug input
        if (debugStoredAction != BaseChoreographer.PlayerAction.NONE)
        {
            choreographer.InputAction(debugStoredAction);
            debugStoredAction = BaseChoreographer.PlayerAction.NONE;
        }
    }
예제 #2
0
 private void DebugInput()
 {
     // Debug input
     if (Input.GetMouseButtonDown(0))
     {
         debugStoredAction = BaseChoreographer.PlayerAction.MOTION_NOD;
     }
     if (Input.GetMouseButtonDown(1))
     {
         debugStoredAction = BaseChoreographer.PlayerAction.MOTION_DEEP_NOD_DOWN;
     }
     if (Input.GetMouseButtonUp(1))
     {
         debugStoredAction = BaseChoreographer.PlayerAction.MOTION_DEEP_NOD_UP;
     }
 }