Exemplo n.º 1
0
 /// <summary>
 ///   <para>Toggles the Oculus Axis defined by the <strong>axisMask</strong> parameter so as to associate the Input Axis with an Oculus Touch Raw Input Axis.</para>
 ///   <innovasys:widget type="Caution Box" layout="block" xmlns:innovasys="http://www.innovasys.com/widgets">
 ///     <innovasys:widgetproperty layout="block" name="Content">
 ///       <strong>Be careful!</strong> Oculus devices do not use virtual inputs or virtual mappings managed
 ///     through the <see cref="!:https://docs.unity3d.com/Manual/class-InputManager.html">Unity Input Manager</see>. Instead, they are accessed directly through the %Oculus
 ///     Utilities for Unity:https://developer.oculus.com/downloads/game-engines/1.5.0/Oculus_Utilities_for_Unity_5/%.</innovasys:widgetproperty>
 ///   </innovasys:widget>
 /// </summary>
 /// <param name="axisMask">An <see cref="OVRInput.RawAxis1D" /> enum value which represents a bitmask corresponding to one of the hard-coded 1-dimensional raw input axes supported by Oculus devices.</param>
 public void toggleRawAxis2D(OVRInput.RawAxis2D axisMask)
 {
     if (axisMask != OVRInput.RawAxis2D.None)
     {
         _previousRawAxis2D = this.rawAxis2D;
         _previousRawAxis1D = this.rawAxis1D;
         _rawAxis1D         = OVRInput.RawAxis1D.None;
         _rawAxis2D         = axisMask;
     }
     else
     {
         _previousRawAxis2D = this.rawAxis2D;
         _rawAxis2D         = OVRInput.RawAxis2D.None;
         _rawAxis1D         = this._previousRawAxis1D;
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        transform.localPosition = OVRInput.GetLocalControllerPosition(Controller);
        transform.localRotation = OVRInput.GetLocalControllerRotation(Controller);

        OVRInput.RawAxis1D triggerAxis = Controller == OVRInput.Controller.LTouch ? OVRInput.RawAxis1D.LHandTrigger : OVRInput.RawAxis1D.RHandTrigger;
        float   grabStrength           = OVRInput.Get(triggerAxis);
        Gesture oldGesture             = gesture;

        if (grabStrength > 0.8f)
        {
            gesture = Gesture.GRAB;
        }
        else
        {
            gesture = Gesture.OPEN;
        }

        if (oldGesture != gesture)
        {
            BroadcastMessage("OnHandGestureChanged", this);
        }
    }
Exemplo n.º 3
0
    // 指タイプにあわせてボタンや回転軸を自動設定
    // (キャラクターによって調整が必要な場合は下記内容を書き換えるか、Inspector上で手動設定する)
    void SetupFingerType(FingerType type)
    {
        this.fingerType = type;
        if (type == FingerType.Custom)
        {
            return;
        }
        if (type == FingerType.Auto)
        {
            AutoSetupFingerType(); return;
        }

        touchButtonPool.Clear();
        relatedTouchButton = OVRInput.RawTouch.None;
        triggerStart       = 0.0f;
        axis    = new Vector3(0, 0, 1);
        isThumb = false;

        switch (fingerType)
        {
        case FingerType.L_Thumb:
            touchButtonPool.Add(OVRInput.RawTouch.LThumbstick);
            touchButtonPool.Add(OVRInput.RawTouch.LThumbRest);
            touchButtonPool.Add(OVRInput.RawTouch.X);
            touchButtonPool.Add(OVRInput.RawTouch.Y);
            trigger = OVRInput.RawAxis1D.LHandTrigger;
            axis    = new Vector3(0.3f, -0.8f, 0.1f);
            isThumb = true;
            break;

        case FingerType.L_Index:
            trigger            = OVRInput.RawAxis1D.LIndexTrigger;
            triggerStart       = 0.5f;
            relatedTouchButton = OVRInput.RawTouch.LIndexTrigger;
            axis = new Vector3(0.1f, 0, 1);
            break;

        case FingerType.L_Middle:
            trigger            = OVRInput.RawAxis1D.LHandTrigger;
            relatedTouchButton = OVRInput.RawTouch.LIndexTrigger;
            triggerStart       = 0.95f;
            break;

        case FingerType.L_Ring:
            trigger      = OVRInput.RawAxis1D.LHandTrigger;
            triggerStart = 0.3f;
            axis         = new Vector3(-0.2f, 0, 1f);
            break;

        case FingerType.L_Pinky:
            trigger = OVRInput.RawAxis1D.LHandTrigger;
            axis    = new Vector3(-0.3f, 0, 1f);
            break;

        case FingerType.R_Thumb:
            touchButtonPool.Add(OVRInput.RawTouch.RThumbstick);
            touchButtonPool.Add(OVRInput.RawTouch.RThumbRest);
            touchButtonPool.Add(OVRInput.RawTouch.A);
            touchButtonPool.Add(OVRInput.RawTouch.B);
            trigger = OVRInput.RawAxis1D.RHandTrigger;
            axis    = new Vector3(0.3f, 0.8f, 0.1f);
            isThumb = true;
            break;

        case FingerType.R_Index:
            trigger            = OVRInput.RawAxis1D.RIndexTrigger;
            triggerStart       = 0.1f;
            relatedTouchButton = OVRInput.RawTouch.RIndexTrigger;
            axis = new Vector3(0.1f, 0, -1);
            break;

        case FingerType.R_Middle:
            trigger            = OVRInput.RawAxis1D.RHandTrigger;
            relatedTouchButton = OVRInput.RawTouch.RIndexTrigger;
            triggerStart       = 0.95f;
            axis = new Vector3(0, 0, -1);
            break;

        case FingerType.R_Ring:
            trigger      = OVRInput.RawAxis1D.RHandTrigger;
            triggerStart = 0.3f;
            axis         = new Vector3(-0.2f, 0, -1f);
            break;

        case FingerType.R_Pinky:
            trigger = OVRInput.RawAxis1D.RHandTrigger;
            axis    = new Vector3(-0.3f, 0, -1f);
            break;
        }

        if (jointLevelPool.Count >= 3)
        {
            float[,] levels =
            {
                { 0.05f, 0.5f, 0.9f },  // 親指
                {  0.9f, 1.0f, 1.2f },  // 人差し指
                {  1.0f, 0.8f, 1.6f },  // 中指
                {  1.0f, 0.7f, 1.6f },  // 薬指
                {  1.0f, 0.7f, 1.6f }   // 小指
            };

            int fi        = (int)fingerType;
            int levelType = (fi >= (int)FingerType.R_Thumb) ? fi - (int)FingerType.R_Thumb : fi - (int)FingerType.L_Thumb;
            jointLevelPool[0] = levels[levelType, 0];
            jointLevelPool[1] = levels[levelType, 1];
            jointLevelPool[2] = levels[levelType, 2];
        }
    }