GetLocalControllerPosition() public static method

Gets the position of the given Controller local to its tracking space. Only supported for Oculus LTouch and RTouch controllers. Non-tracked controllers will return Vector3.zero.
public static GetLocalControllerPosition ( OVRInput, controllerType ) : Vector3
controllerType OVRInput,
return Vector3
Example #1
0
    protected void GrabEnd()
    {
        if (m_grabbedObj != null)
        {
            OVRPose localPose = new OVRPose {
                position = OVRInput.GetLocalControllerPosition(m_controller), orientation = OVRInput.GetLocalControllerRotation(m_controller)
            };
            OVRPose offsetPose = new OVRPose {
                position = m_anchorOffsetPosition, orientation = m_anchorOffsetRotation
            };
            localPose = localPose * offsetPose;

            OVRPose trackingSpace = transform.ToOVRPose() * localPose.Inverse();
            OVRPose localVelocity = new OVRPose()
            {
                position = OVRInput.GetLocalControllerVelocity(m_controller), orientation = OVRInput.GetLocalControllerAngularVelocity(m_controller)
            };
            Vector3 linearVelocity  = trackingSpace.orientation * localVelocity.position;
            Vector3 angularVelocity = (trackingSpace.orientation * localVelocity.orientation).eulerAngles * Mathf.Deg2Rad;

            if (angularVelocity.x > Mathf.PI)
            {
                angularVelocity.x -= 2f * Mathf.PI;
            }
            if (angularVelocity.y > Mathf.PI)
            {
                angularVelocity.y -= 2f * Mathf.PI;
            }
            if (angularVelocity.z > Mathf.PI)
            {
                angularVelocity.z -= 2f * Mathf.PI;
            }

            GrabbableRelease(linearVelocity, angularVelocity);
        }

        // Re-enable grab volumes to allow overlap events
        GrabVolumeEnable(true);
    }
Example #2
0
    protected virtual void UpdateAnchors()
    {
        EnsureGameObjectIntegrity();

        if (!Application.isPlaying)
        {
            return;
        }


        OVRPose tracker = OVRManager.tracker.GetPose();

        trackerAnchor.localPosition = tracker.position;
        trackerAnchor.localRotation = tracker.orientation;

        centerEyeAnchor.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye);
        centerEyeAnchor.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye);


        // custom updates of eyes

        leftEye.UpdatePosition(
            UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftEye),
            UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftEye)
            );

        rightEye.UpdatePosition(
            UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightEye),
            UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightEye)
            );

        // controllers

        leftHandAnchor.localRotation  = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
        rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);

        leftHandAnchor.localPosition  = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
        rightHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
    }
Example #3
0
    protected void GrabEnd()
    {
        if (m_grabbedObj != null)
        {
            OVRPose localPose = new OVRPose {
                position = OVRInput.GetLocalControllerPosition(m_controller), orientation = OVRInput.GetLocalControllerRotation(m_controller)
            };
            OVRPose offsetPose = new OVRPose {
                position = m_anchorOffsetPosition, orientation = m_anchorOffsetRotation
            };
            localPose = localPose * offsetPose;

            OVRPose trackingSpace   = transform.ToOVRPose() * localPose.Inverse();
            Vector3 linearVelocity  = trackingSpace.orientation * OVRInput.GetLocalControllerVelocity(m_controller);
            Vector3 angularVelocity = trackingSpace.orientation * OVRInput.GetLocalControllerAngularVelocity(m_controller);

            GrabbableRelease(linearVelocity, angularVelocity);
        }

        // Re-enable grab volumes to allow overlap events
        GrabVolumeEnable(true);
    }
Example #4
0
        private void moveItem()
        {
            Vector3 controllerPos = OVRInput.GetLocalControllerPosition(KosmosStatics.Controller);

            controllerOrientation = OVRInput.GetLocalControllerRotation(KosmosStatics.Controller);

            // calculate point where object goes based on fixed distance from controller
            Vector3 targetPos = controllerPos + ((controllerOrientation * Vector3.forward) * DistanceToObj);

            // convert target position to world space
            localToWorld = trackingSpace.localToWorldMatrix;
            Vector3 targetPosWorld = localToWorld.MultiplyPoint(targetPos);

            Vector3 newPos = Vector3.Lerp(currentGrabbable.transform.position, targetPosWorld, Time.deltaTime * 10);

            // phantom position means that the real position is controlled by something else but we still want to set
            // the position it would have been
            // phantom position can e.g. be used if grabbing an end of a cable and the cable can't be stretched
            if (currentGrabbable.IsPhantom)
            {
                currentGrabbable.PhantomPosition = newPos;
            }
            else
            {
                currentGrabbable.transform.position = newPos;
            }

            // if it is being constrained, get position from the ConstrainPosition component
            if (constrainPosition)
            {
                currentGrabbable.transform.localPosition = constrainPosition.Constrain();
            }

            // if it has a slidercontrol, make sure to add additional constraints
            if (sliderControl)
            {
                currentGrabbable.transform.localPosition = sliderControl.Constrain();
            }
        }
        public override void OnUpdate()
        {
            OVRInput.Controller activeController = OVRInput.GetActiveController();

            rotation.Value = OVRInput.GetLocalControllerRotation(activeController);

            x.Value = rotation.Value.x;
            y.Value = rotation.Value.y;
            z.Value = rotation.Value.z;

            position.Value = OVRInput.GetLocalControllerPosition(activeController);

            acceleration.Value = OVRInput.GetLocalControllerAcceleration(activeController);

            // Controller pointing events

            if (position.Value.y >= upLimit.Value)
            {
                Fsm.Event(pointingUp);
            }

            else if (position.Value.y <= downLimit.Value)
            {
                Fsm.Event(pointingDown);
            }

            // Controller rotation events

            if (z.Value >= minRotationLeft.Value && acceleration.Value.z <= accelerationLeft.Value)
            {
                Fsm.Event(rotatedLeft);
            }

            else if (z.Value <= minRotationRight.Value && acceleration.Value.z >= accelerationRight.Value)
            {
                Fsm.Event(rotatedRight);
            }
        }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        CheckGrab(OVRInput.Controller.LTouch, OVRInput.RawButton.LHandTrigger);
        CheckGrab(OVRInput.Controller.RTouch, OVRInput.RawButton.RHandTrigger);

        if (grabbedByButton != OVRInput.RawButton.None && OVRInput.GetUp(grabbedByButton))
        {
            // release
            grabbedBy       = OVRInput.Controller.None;
            grabbedByButton = OVRInput.RawButton.None;

            float   orbitRadius = (transform.position - Planet.transform.position).magnitude;
            Vector3 axis        = Vector3.Cross(transform.position - Planet.transform.position, transform.position + smoothedGrabVelocity.average - Planet.transform.position);
            orbitRotation = Quaternion.AngleAxis(smoothedGrabVelocity.average.magnitude / (orbitRadius * Time.fixedDeltaTime), axis);
        }

        if (grabbedBy != OVRInput.Controller.None)
        {
            Vector3    oldPosition = transform.position;
            Quaternion oldRotation = transform.rotation;

            Vector3    handPos = OVRManager.instance.transform.LocalToWorld(OVRInput.GetLocalControllerPosition(grabbedBy));
            Quaternion handRot = OVRManager.instance.transform.LocalToWorld(OVRInput.GetLocalControllerRotation(grabbedBy));
            transform.position = handPos + handRot * localGrabOffset;
            transform.rotation = handRot * localGrabRotation;

            spin = transform.rotation * Quaternion.Inverse(oldRotation);

            smoothedGrabVelocity.AddReading(transform.position - oldPosition);
        }
        else if (unfreezeTimestamp != 0 && unfreezeTimestamp < Time.time)
        {
            unfreezeTimestamp = 0;
            float   orbitRadius = (transform.position - Planet.transform.position).magnitude;
            Vector3 axis        = Vector3.Cross(transform.position - Planet.transform.position, transform.position + tractorBeamVelocity - Planet.transform.position);
            orbitRotation = Quaternion.AngleAxis(tractorBeamVelocity.magnitude / (orbitRadius * Time.fixedDeltaTime), axis);
        }
    }
Example #7
0
    //IEnumerator NormalTime()
    //{
    //    yield return new WaitForSecondsRealtime(2f);
    //    Time.timeScale = 1f;
    //}

    private float getBatForce(Rigidbody batRB, Collision collision)
    {
        float ang_vel;
        float distance;

        if (hand.righty)
        {
            ang_vel  = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch).magnitude;
            distance = (collision.contacts[0].point - OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch)).magnitude;
        }
        else
        {
            ang_vel  = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch).magnitude;
            distance = (collision.contacts[0].point - OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch)).magnitude;
        }
        //Vector3 normal = collision.contacts[0].normal;

        //return ang_vel * distance / 200f * 30f;
        return(ang_vel * distance / 200f * 5f);
        //BatSpeed bs = (BatSpeed)batRB.GetComponent(typeof(BatSpeed));
        //return bs.getVelocity().magnitude /200f * 30f;
        //return batRB.velocity.magnitude / 200f * 30f;
    }
    void Update()
    {
        bool controllersActive = OVRInput.GetActiveController() == OVRInput.Controller.Touch ||
                                 OVRInput.GetActiveController() == OVRInput.Controller.LTouch ||
                                 OVRInput.GetActiveController() == OVRInput.Controller.RTouch;

        displayText.SetActive(controllersActive);

        if (OVRInput.GetUp(OVRInput.Button.Start))
        {
            currentSceneIndex++;
            if (currentSceneIndex >= SceneManager.sceneCountInBuildSettings)
            {
                currentSceneIndex = 0;
            }
            SceneManager.LoadScene(currentSceneIndex);
        }

        Vector3 menuPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch) + Vector3.up * 0.09f;

        displayText.transform.position = menuPosition;
        displayText.transform.rotation = Quaternion.LookRotation(menuPosition - Camera.main.transform.position);
    }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        if (OVRInput.GetDown(touchbutton))
        {
            Vector3    position = tSpace.TransformPoint(OVRInput.GetLocalControllerPosition(Ocontroller));
            Vector3    rotation = tSpace.TransformDirection(OVRInput.GetLocalControllerRotation(Ocontroller).eulerAngles);
            GameObject object1  = Instantiate(wall, position, Quaternion.Euler(rotation));

            if (OVRInput.Get(buttonup))
            {
                Renderer renderer1 = object1.GetComponent <Renderer>();

                renderer1.material.SetColor("_Color", Color.grey);
            }

            if (OVRInput.Get(buttondown))
            {
                Renderer renderer1 = object1.GetComponent <Renderer>();

                renderer1.material.SetColor("_Color", Color.red);
            }
        }
    }
    public void Drop()
    {
        // Destroy the joint between
        var fixJoint = gameObject.GetComponent <FixedJoint>();

        Destroy(fixJoint);
        OVRPose localPose = new OVRPose {
            position = OVRInput.GetLocalControllerPosition(m_controller), orientation = OVRInput.GetLocalControllerRotation(m_controller)
        };
        OVRPose offsetPose = new OVRPose {
            position = m_anchorOffsetPosition, orientation = m_anchorOffsetRotation
        };

        localPose = localPose * offsetPose;

        OVRPose trackingSpace   = transform.ToOVRPose() * localPose.Inverse();
        Vector3 linearVelocity  = trackingSpace.orientation * OVRInput.GetLocalControllerVelocity(m_controller);
        Vector3 angularVelocity = trackingSpace.orientation * OVRInput.GetLocalControllerAngularVelocity(m_controller);

        m_grabbedObj = null;
        grabbable.Drop(linearVelocity, angularVelocity);
        grabbable = null;
    }
Example #11
0
    void Update()
    {
        gameObject.transform.localPosition = OVRInput.GetLocalControllerPosition(handType);
        gameObject.transform.localRotation = OVRInput.GetLocalControllerRotation(handType);

        OVRInput.Update();

        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            if (/*Input.GetMouseButtonDown(1)*/ OVRInput.Get(OVRInput.Button.One, handType))
            {
                if (handType == OVRInput.Controller.RTouch)
                {
                    print("I detected a touch");
                    float pos = Mathf.Max(0.0f, OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger));
                    cubePrefabClone = Instantiate(cubePrefab, hit.point + new Vector3(pos, pos * 1.1f, pos), Quaternion.Euler(0, 0, 0)) as GameObject;
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        var     posHead = rig.centerEyeAnchor.position;
        Vector3 posR    = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
        Vector3 posL    = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
        Vector3 p       = OVRManager.tracker.GetPose().position;

        var        rotHead           = rig.centerEyeAnchor.rotation;
        Quaternion rotR              = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
        Quaternion rotL              = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
        string     rightpos          = "Position of the RIGHT controller is: ";
        string     leftpos           = "Position of the LEFT controller is: ";
        string     headpos           = "Position of the HEADSET is: ";
        string     rot               = " And rotation is: ";
        string     cl                = "\n";
        string     axisL             = "AXIS LEFT: ";
        string     axisR             = "AXIS RIGHT: ";
        string     accessoryPosition = rightpos + posR.ToString() + rot + rotR.eulerAngles.ToString() + "\n" + leftpos + posL.ToString() + rot + rotL.eulerAngles.ToString() + "\n" + headpos + posHead.ToString() + rot + rotHead.ToString() + "\n";;
        Vector2    inputAxisThumbL   = OVRInput.Get(OVRInput.RawAxis2D.LThumbstick);
        Vector2    inputAxisThumbR   = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick);

        distLabel.text = accessoryPosition + cl + axisL + inputAxisThumbL.ToString() + cl + axisR + inputAxisThumbR.ToString();
    }
Example #13
0
    void OnUpdatedAnchors()
    {
        Vector3    handPos = OVRInput.GetLocalControllerPosition(m_controller);
        Quaternion handRot = OVRInput.GetLocalControllerRotation(m_controller);
        Vector3    destPos = m_parentTransform.TransformPoint(m_anchorOffsetPosition + handPos);
        Quaternion destRot = m_parentTransform.rotation * handRot * m_anchorOffsetRotation;

        GetComponent <Rigidbody>().MovePosition(destPos);
        GetComponent <Rigidbody>().MoveRotation(destRot);

        if (!m_parentHeldObject)
        {
            MoveGrabbedObject(destPos, destRot);
        }
        m_lastPos = transform.position;
        m_lastRot = transform.rotation;

        float prevFlex = m_prevFlex;

        m_prevFlex = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller);

        CheckForGrabOrRelease(prevFlex);
    }
Example #14
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);
        }
    }
Example #15
0
    void Fire(hands leftOrRight)
    {
        Vector3    location;
        Quaternion rotation;

        if (leftOrRight == hands.Left)
        {
            location = OVRInput.GetLocalControllerPosition(controllerLeft);
            rotation = OVRInput.GetLocalControllerRotation(controllerRight);
        }
        else
        {
            location = OVRInput.GetLocalControllerPosition(controllerRight);
            rotation = OVRInput.GetLocalControllerRotation(controllerRight);
        }

        GameObject bullet = Instantiate(bulletType) as GameObject;

        bullet.transform.position = location;
        bullet.transform.rotation = rotation;
        bulletrb = bullet.GetComponent <Rigidbody>();
        bulletrb.AddForce(transform.forward * firingSpeed);
    }
    protected void GrabEnd()
    {
        if (m_grabbedObjs != null)
        {
            for (var i = 0; i < m_grabbedObjs.Count; i++)
            {
                OVRPose localPose = new OVRPose {
                    position = OVRInput.GetLocalControllerPosition(m_controller), orientation = OVRInput.GetLocalControllerRotation(m_controller)
                };
                OVRPose offsetPose = new OVRPose {
                    position = m_anchorOffsetPosition, orientation = m_anchorOffsetRotation
                };
                localPose = localPose * offsetPose;

                OVRPose trackingSpace   = transform.ToOVRPose(true) * localPose.Inverse();
                Vector3 linearVelocity  = trackingSpace.orientation * OVRInput.GetLocalControllerVelocity(m_controller);
                Vector3 angularVelocity = trackingSpace.orientation * OVRInput.GetLocalControllerAngularVelocity(m_controller);
                GrabbableRelease(m_grabbedObjs[i], linearVelocity, angularVelocity);
            }
        }
        m_grabbedObjs = null;
        GrabVolumeEnable(true);
    }
 // Update is called once per frame
 void Update()
 {
     if (OVRInput.GetDown(OVRInput.RawButton.RHandTrigger))  // yama 180201 右中指トリガーを押したか判定
     {
         if (callib_count == 0)
         {
             rHand_pos = transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch));
             //Debug.Log(rHand_pos);
             callib_count++;
             Set_Position();
         }
     }
     if (OVRInput.GetDown(OVRInput.RawButton.LHandTrigger))  // yama 180201 左中指トリガーを押したか判定
     {
         if (callib_count == 1)
         {
             lHand_pos = transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));
             //Debug.Log(lHand_pos);
             callib_count++;
             Set_Position();
         }
     }
 }
Example #18
0
    void Update()
    {
        if (leftController == null || rightController == null)
        {
            CopyMeshController();
        }
        else
        {
            padsAreInit = true;
        }

        if (padsAreInit)
        {
            RegisterPosition((int)CONTROLLER.LEFT, OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch), OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch));
            RegisterPosition((int)CONTROLLER.RIGHT, OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch), OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch));

            Pose p;
            p = GetValuePosition((int)CONTROLLER.LEFT, (float)(delay / 1000.0f));
            controllers[(int)CONTROLLER.LEFT].controller.transform.position = p.pose;
            controllers[(int)CONTROLLER.LEFT].controller.transform.rotation = p.rot;

            p = GetValuePosition((int)CONTROLLER.RIGHT, (float)(delay / 1000.0f));
            controllers[(int)CONTROLLER.RIGHT].controller.transform.position = p.pose;
            controllers[(int)CONTROLLER.RIGHT].controller.transform.rotation = p.rot;
        }

        if (controllerIndexZEDHolder != -1)
        {
            if (controllers[(int)controllerIndexZEDHolder].controller != null)
            {
                transform.parent.localPosition = controllers[(int)controllerIndexZEDHolder].controller.transform.position;
                transform.parent.localRotation = controllers[(int)controllerIndexZEDHolder].controller.transform.rotation;
            }
        }

        OVRInput.Update();
    }
    private void ScaleWorld()
    {
        //Obtaining distance and velocity
        Vector3 d = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch) - OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
        Vector3 v = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch) - OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);

        //Calculating Scaling Vector
        float result = Vector3.Dot(v, d);

        //Adjusting result to slow scaling
        float final_result = 1.0F + 0.2F * result;

        Vector3 scalingFactor = Vector3.Scale(transform.localScale, new Vector3(final_result, final_result, final_result));

        objectScale = scalingFactor;

        //Checking Scaling Bounds
        if (scalingFactor.sqrMagnitude > minScale.sqrMagnitude && scalingFactor.sqrMagnitude < maxScale.sqrMagnitude)
        {
            Vector3 A = transform.position;
            Vector3 B = pivot.transform.position;
            B.y = A.y;

            Vector3 startScale = transform.localScale;
            Vector3 endScale   = transform.localScale * final_result;

            Vector3 C = A - B; // diff from object pivot to desired pivot/origin

            // calc final position post-scale
            Vector3 FinalPosition = (C * final_result) + B;

            // finally, actually perform the scale/translation
            transform.localScale = endScale;
            transform.position   = FinalPosition;
        }
    }
Example #20
0
    // Update is called once per frame
    void Update()
    {
        CheckGrab(OVRInput.Controller.LTouch, OVRInput.RawButton.LHandTrigger);
        CheckGrab(OVRInput.Controller.RTouch, OVRInput.RawButton.RHandTrigger);

        if (grabbedByButton != OVRInput.RawButton.None && OVRInput.GetUp(grabbedByButton))
        {
            // release
            grabbedBy      = OVRInput.Controller.None;
            rbody.velocity = smoothedVelocity.average / Time.fixedDeltaTime;
        }

        if (grabbedBy != OVRInput.Controller.None)
        {
            Vector3 oldPosition = transform.position;

            Vector3    handPos = OVRManager.instance.transform.LocalToWorld(OVRInput.GetLocalControllerPosition(grabbedBy));
            Quaternion handRot = OVRManager.instance.transform.LocalToWorld(OVRInput.GetLocalControllerRotation(grabbedBy));
            transform.position = handPos + handRot * localGrabOffset;
            transform.rotation = handRot * localGrabRotation;

            smoothedVelocity.AddReading(transform.position - oldPosition);
        }
    }
Example #21
0
    // Update is called once per frame
    void Update()
    {
        transform.localRotation = OVRInput.GetLocalControllerRotation(controller);
        transform.localPosition = OVRInput.GetLocalControllerPosition(controller);

        // Quit on both thumbstick press
        if (OVRInput.Get(OVRInput.RawButton.LThumbstick) && OVRInput.Get(OVRInput.RawButton.RThumbstick))
        {
            UnityEngine.Application.Quit();
            Debug.LogError("Quit selected.");
        }

        if (!Input.GetKey(KeyCode.Escape))
        {
            seenEscapeReleased = true;
        }

        // Quit if escape is pressed (unless it has been pressed since scene start)
        if (Input.GetKey(KeyCode.Escape) && seenEscapeReleased)
        {
            UnityEngine.Application.Quit();
            Debug.LogError("Quit selected.");
        }
    }
    protected override void PendInputs(AirVRInputStream inputStream)
    {
        bool leftHanded = (OVRInput.GetConnectedControllers() & OVRInput.Controller.LTrackedRemote) != 0;

        OVRInput.Controller controller = OVRInput.Controller.LTrackedRemote | OVRInput.Controller.RTrackedRemote;
        inputStream.PendTransform(this, (byte)AirVRTrackedControllerKey.Transform,
                                  OVRInput.GetLocalControllerPosition(leftHanded ? OVRInput.Controller.LTrackedRemote : OVRInput.Controller.RTrackedRemote),
                                  OVRInput.GetLocalControllerRotation(leftHanded ? OVRInput.Controller.LTrackedRemote : OVRInput.Controller.RTrackedRemote));
        inputStream.PendTouch(this, (byte)AirVRTrackedControllerKey.Touchpad,
                              OVRInput.Get(leftHanded ? OVRInput.RawAxis2D.LTouchpad : OVRInput.RawAxis2D.RTouchpad, controller),
                              OVRInput.Get(leftHanded ? OVRInput.RawTouch.LTouchpad : OVRInput.RawTouch.RTouchpad, controller));
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonTouchpad,
                               OVRInput.Get(leftHanded ? OVRInput.RawButton.LTouchpad : OVRInput.RawButton.RTouchpad, controller));

        // workaround : avoid bugs in OVRInput for important inputs
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonBack, OVRInput.Get(OVRInput.Button.Back));

        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonIndexTrigger,
                               OVRInput.Get(leftHanded ? OVRInput.RawButton.LIndexTrigger : OVRInput.RawButton.RIndexTrigger, controller));
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonUp, OVRInput.Get(OVRInput.RawButton.DpadUp, controller));
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonDown, OVRInput.Get(OVRInput.RawButton.DpadDown, controller));
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonLeft, OVRInput.Get(OVRInput.RawButton.DpadLeft, controller));
        inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonRight, OVRInput.Get(OVRInput.RawButton.DpadRight, controller));
    }
    void Update()
    {
        bool controllerConnected = OVRInput.IsControllerConnected(m_controller);

        if ((controllerConnected != m_prevControllerConnected) || !m_prevControllerConnectedCached)
        {
            m_modelOculusGoController.SetActive(controllerConnected && m_isOculusGo);
            m_modelGearVrController.SetActive(controllerConnected && !m_isOculusGo);

            m_prevControllerConnected       = controllerConnected;
            m_prevControllerConnectedCached = true;
        }

        if (!controllerConnected)
        {
            return;
        }


        OVRInput.Update();
        transform.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController());
        transform.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.GetActiveController());
//		// TODO: can't get any trigger events
//		foreach (OVRInput.RawButton button in Enum.GetValues(typeof(OVRInput.RawButton)))
//		{
//
//			if (OVRInput.GetUp(button))
//			{
//				Debug.Log("triggered up! " + button.ToString());
//			}
//			if (OVRInput.GetDown(button))
//			{
//				Debug.Log("triggered down! " + button.ToString());
//			}
//		}
    }
Example #24
0
 public static Vector3 GetLocalPosition(ControllerSide side)
 {
     return(OVRInput.GetLocalControllerPosition(GetOVRController(side)));
 }
Example #25
0
 // Update is called once per frame
 void Update()
 {
     transform.localPosition = OVRInput.GetLocalControllerPosition(controller);
     transform.localRotation = OVRInput.GetLocalControllerRotation(controller);
 }
    protected virtual void UpdateAnchors()
    {
        EnsureGameObjectIntegrity();

        if (!Application.isPlaying)
        {
            return;
        }

        if (_skipUpdate)
        {
            centerEyeAnchor.FromOVRPose(OVRPose.identity, true);
            leftEyeAnchor.FromOVRPose(OVRPose.identity, true);
            rightEyeAnchor.FromOVRPose(OVRPose.identity, true);

            return;
        }

        bool monoscopic = OVRManager.instance.monoscopic;
        bool hmdPresent = OVRNodeStateProperties.IsHmdPresent();

        OVRPose tracker = OVRManager.tracker.GetPose();

        trackerAnchor.localRotation = tracker.orientation;

        Quaternion emulatedRotation = Quaternion.Euler(-OVRManager.instance.headPoseRelativeOffsetRotation.x, -OVRManager.instance.headPoseRelativeOffsetRotation.y, OVRManager.instance.headPoseRelativeOffsetRotation.z);

        //Note: in the below code, when using UnityEngine's API, we only update anchor transforms if we have a new, fresh value this frame.
        //If we don't, it could mean that tracking is lost, etc. so the pose should not change in the virtual world.
        //This can be thought of as similar to calling InputTracking GetLocalPosition and Rotation, but only for doing so when the pose is valid.
        //If false is returned for any of these calls, then a new pose is not valid and thus should not be updated.

        if (hmdPresent)
        {
            Vector3    centerEyePosition = Vector3.zero;
            Quaternion centerEyeRotation = Quaternion.identity;

            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.CenterEye, NodeStatePropertyType.Position, OVRPlugin.Node.EyeCenter, OVRPlugin.Step.Render, out centerEyePosition))
            {
                centerEyeAnchor.localPosition = centerEyePosition;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.CenterEye, NodeStatePropertyType.Orientation, OVRPlugin.Node.EyeCenter, OVRPlugin.Step.Render, out centerEyeRotation))
            {
                centerEyeAnchor.localRotation = centerEyeRotation;
            }
        }
        else
        {
            centerEyeAnchor.localRotation = emulatedRotation;
            centerEyeAnchor.localPosition = OVRManager.instance.headPoseRelativeOffsetTranslation;
        }

        if (!hmdPresent || monoscopic)
        {
            leftEyeAnchor.localPosition  = centerEyeAnchor.localPosition;
            rightEyeAnchor.localPosition = centerEyeAnchor.localPosition;
            leftEyeAnchor.localRotation  = centerEyeAnchor.localRotation;
            rightEyeAnchor.localRotation = centerEyeAnchor.localRotation;
        }
        else
        {
            Vector3    leftEyePosition  = Vector3.zero;
            Vector3    rightEyePosition = Vector3.zero;
            Quaternion leftEyeRotation  = Quaternion.identity;
            Quaternion rightEyeRotation = Quaternion.identity;

            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.LeftEye, NodeStatePropertyType.Position, OVRPlugin.Node.EyeLeft, OVRPlugin.Step.Render, out leftEyePosition))
            {
                leftEyeAnchor.localPosition = leftEyePosition;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.RightEye, NodeStatePropertyType.Position, OVRPlugin.Node.EyeRight, OVRPlugin.Step.Render, out rightEyePosition))
            {
                rightEyeAnchor.localPosition = rightEyePosition;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.LeftEye, NodeStatePropertyType.Orientation, OVRPlugin.Node.EyeLeft, OVRPlugin.Step.Render, out leftEyeRotation))
            {
                leftEyeAnchor.localRotation = leftEyeRotation;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.RightEye, NodeStatePropertyType.Orientation, OVRPlugin.Node.EyeRight, OVRPlugin.Step.Render, out rightEyeRotation))
            {
                rightEyeAnchor.localRotation = rightEyeRotation;
            }
        }

        Vector3 offset = new Vector3(0f, -2f, 0.5f);

        //Need this for controller offset because if we're on OpenVR, we want to set the local poses as specified by Unity, but if we're not, OVRInput local position is the right anchor
        if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
        {
            Vector3    leftPos   = Vector3.zero;
            Vector3    rightPos  = Vector3.zero;
            Quaternion leftQuat  = Quaternion.identity;
            Quaternion rightQuat = Quaternion.identity;


            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.LeftHand, NodeStatePropertyType.Position, OVRPlugin.Node.HandLeft, OVRPlugin.Step.Render, out leftPos))
            {
                leftHandAnchor.localPosition = leftPos;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.RightHand, NodeStatePropertyType.Position, OVRPlugin.Node.HandRight, OVRPlugin.Step.Render, out rightPos))
            {
                rightHandAnchor.localPosition = rightPos + offset;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.LeftHand, NodeStatePropertyType.Orientation, OVRPlugin.Node.HandLeft, OVRPlugin.Step.Render, out leftQuat))
            {
                leftHandAnchor.localRotation = leftQuat;
            }
            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.RightHand, NodeStatePropertyType.Orientation, OVRPlugin.Node.HandRight, OVRPlugin.Step.Render, out rightQuat))
            {
                rightHandAnchor.localRotation = rightQuat;
            }
        }
        else
        {
            leftHandAnchor.localPosition  = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
            rightHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch) + offset;
            leftHandAnchor.localRotation  = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
            rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
        }

        trackerAnchor.localPosition = tracker.position;

        OVRPose leftOffsetPose  = OVRPose.identity;
        OVRPose rightOffsetPose = OVRPose.identity;

        if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
        {
            leftOffsetPose  = OVRManager.GetOpenVRControllerOffset(Node.LeftHand);
            rightOffsetPose = OVRManager.GetOpenVRControllerOffset(Node.RightHand);

            //Sets poses of left and right nodes, local to the tracking space.
            OVRManager.SetOpenVRLocalPose(trackingSpace.InverseTransformPoint(leftControllerAnchor.position),
                                          trackingSpace.InverseTransformPoint(rightControllerAnchor.position),
                                          Quaternion.Inverse(trackingSpace.rotation) * leftControllerAnchor.rotation,
                                          Quaternion.Inverse(trackingSpace.rotation) * rightControllerAnchor.rotation);
        }
        rightControllerAnchor.localPosition = rightOffsetPose.position;
        rightControllerAnchor.localRotation = rightOffsetPose.orientation;
        leftControllerAnchor.localPosition  = leftOffsetPose.position;
        leftControllerAnchor.localRotation  = leftOffsetPose.orientation;

        RaiseUpdatedAnchorsEvent();
    }
Example #27
0
    // Update is called once per frame
    void Update()
    {
        if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger) && OVRInput.Get(OVRInput.Button.SecondaryHandTrigger))
        {
            Vector3 d = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch) - OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
            Vector3 v = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch) - OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);

            float   result       = Vector3.Dot(v, d);
            float   final_result = 1.0F + 0.2F * result;
            Vector3 terrainScale = Vector3.Scale(terrain.terrainData.size, new Vector3(final_result, final_result, final_result));
            if (terrainScale.sqrMagnitude > minScale.sqrMagnitude && terrainScale.sqrMagnitude < maxScale.sqrMagnitude)
            {
                terrain.terrainData.size = terrainScale;
                transform.localScale     = Vector3.Scale(transform.localScale, new Vector3(final_result, final_result, final_result));
                // EditorUtility.DisplayDialog("Both Buttons just pressed", "Both Buttons just pressed \n"+result+"\n"+d+"\n"+v, "Okay", "Cancel");
                Vector3 heightAdjustedPos = transform.position;
                //heightAdjustedPos.y = originalTerrainPosition.y + (0.2F * -result);
                heightAdjustedPos.y = originalTerrainPosition.y + (1 - transform.localScale.y);
                transform.position  = heightAdjustedPos;
            }
        }
        DeactivateDroneMenu();

        //MOVING SCENE

        float moveX = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x;
        float moveZ = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y;
        //float moveY = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).y;
        //float rotate = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).x;


        // update player position based on input
        Vector3 position = transform.position;

        position.x += moveX * speed * Time.deltaTime;
        //position.y += moveY * speed * Time.deltaTime;
        position.z        += moveZ * speed * Time.deltaTime;
        transform.position = position;

        //transform.Rotate(0, rotate*Time.deltaTime*speed*10, 0, Space.Self);

        //Vector3 terrain_position = terrain.transform.position;
        //terrain_position.x += moveHorizontal * speed * Time.deltaTime;
        //terrain_position.z += moveVertical * speed * Time.deltaTime;
        //terrain.transform.position = terrain_position;
    }
Example #28
0
    // Update is called once per frame
    void Update()
    {
        if (OVRInput.GetDown(OVRInput.RawButton.LHandTrigger))
        {
            Vector3 LTouchPos = OVRManager.instance.transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));
            grabOffsetL = LTouchPos - transform.position;
            if (grabOffsetL.sqrMagnitude < grabRadius * grabRadius)
            {
                grabbedL         = true;
                localGrabOffsetL = transform.WorldToLocal(LTouchPos);
                baseRotationL    = transform.rotation;
            }
        }
        else if (OVRInput.GetUp(OVRInput.RawButton.LHandTrigger))
        {
            grabbedL = false;
            if (grabbedR)
            {
                Vector3 RTouchPos = OVRManager.instance.transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch));
                grabOffsetR      = RTouchPos - transform.position;
                localGrabOffsetR = transform.WorldToLocal(RTouchPos);
                baseRotationR    = transform.rotation;
            }
        }

        if (OVRInput.GetDown(OVRInput.RawButton.RHandTrigger))
        {
            Vector3 RTouchPos = OVRManager.instance.transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch));
            grabOffsetR = RTouchPos - transform.position;
            if (grabOffsetR.sqrMagnitude < grabRadius * grabRadius)
            {
                grabbedR         = true;
                localGrabOffsetR = transform.WorldToLocal(RTouchPos);
                baseRotationR    = transform.rotation;
            }
        }
        else if (OVRInput.GetUp(OVRInput.RawButton.RHandTrigger))
        {
            grabbedR = false;
            if (grabbedL)
            {
                Vector3 LTouchPos = OVRManager.instance.transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));
                grabOffsetL      = LTouchPos - transform.position;
                localGrabOffsetL = transform.WorldToLocal(LTouchPos);
                baseRotationL    = transform.rotation;
            }
        }

        if (grabbedL || grabbedR)
        {
            Quaternion oldRotation = transform.rotation;

            if (grabbedL && grabbedR)
            {
                SetRotation(OVRInput.Controller.RTouch);

                //clamp the L offset to the plane of R
                OVRInput.Controller controller      = OVRInput.Controller.RTouch;
                OVRInput.Controller otherController = (controller == OVRInput.Controller.LTouch) ? OVRInput.Controller.RTouch : OVRInput.Controller.LTouch;

                Vector3 BRlocalspaceTwistOriginal     = (controller == OVRInput.Controller.LTouch) ? localGrabOffsetL.SnapToPlane(localGrabOffsetR).normalized : localGrabOffsetR.SnapToPlane(localGrabOffsetL).normalized;
                Vector3 BRlocalspaceCurrentTwisterPos = transform.WorldToLocal(OVRInput.GetLocalControllerPosition(controller));
                Vector3 BRlocalspaceCurrentAxis       = transform.WorldToLocal(OVRInput.GetLocalControllerPosition(otherController).normalized);
                Vector3 BRlocalspaceTwistCurrent      = BRlocalspaceCurrentTwisterPos.SnapToPlane_PreNormalized(BRlocalspaceCurrentAxis).normalized;
                float   BRtwistAngle = BRlocalspaceTwistCurrent.AngleTo_Raw(BRlocalspaceTwistOriginal) * Mathf.Rad2Deg;
                if (Vector3.Dot(Vector3.Cross(BRlocalspaceCurrentAxis, BRlocalspaceTwistOriginal), BRlocalspaceTwistCurrent) < 0)
                {
                    BRtwistAngle = -BRtwistAngle;
                }

                Vector3 localspaceTwistOriginal = localGrabOffsetL.SnapToPlane(localGrabOffsetR).normalized;
                Vector3 localspaceCurrentL      = transform.WorldToLocal(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));
                Vector3 localspaceCurrentR      = transform.WorldToLocal(OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch)).normalized;
                Vector3 localspaceTwistCurrent  = localspaceCurrentL.SnapToPlane_PreNormalized(localspaceCurrentR).normalized;
                float   twistAngle = localspaceTwistCurrent.AngleTo_Raw(localspaceTwistOriginal) * Mathf.Rad2Deg;

                if (Vector3.Dot(Vector3.Cross(localspaceCurrentR, localspaceTwistOriginal), localspaceTwistCurrent) < 0)
                {
                    twistAngle = -twistAngle;
                }

                if (twistAngle != BRtwistAngle)
                {
                    int breakhere = 0;
                    breakhere++;
                }

                //grabOffsetL - Vector3.Dot(grabOffsetL, grabOffsetR)
                Vector3 twistAxis = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch) - transform.position;

                transform.rotation = Quaternion.AngleAxis(twistAngle, twistAxis) * transform.rotation;
                //Quaternion.Lerp(
                //    Quaternion.AngleAxis(twistAngle, twistAxis) * transform.rotation,
                //    Quaternion.AngleAxis(twistAngle, twistAxis) * transform.rotation,
                //    0.5f);
            }
            else if (grabbedL)
            {
                SetRotation(OVRInput.Controller.LTouch);
            }
            else // (grabbedR)
            {
                SetRotation(OVRInput.Controller.RTouch);
            }

            avelocity = Quaternion.Lerp(avelocity, Quaternion.Inverse(oldRotation) * transform.rotation, 0.1f);
        }
        else
        {
            grabbedL            = false;
            grabbedR            = false;
            transform.rotation *= Quaternion.Lerp(Quaternion.identity, avelocity, 0.6f);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!planetsFound)
        {
            obj      = GameObject.FindGameObjectsWithTag("planet");
            allClipP = GameObject.FindGameObjectsWithTag("ClippingPlane");
            if (obj.Length != 0)
            {
                planetsFound = true;
                planetLabel  = new GameObject[4];

                indices = new List <int>();

                clipP = new GameObject[obj.Length];

                for (int i = 0; i < allClipP.Length; i++)
                {
                    if (allClipP[i].name == "ClippingPlane")
                    {
                        indices.Add(i);
                    }
                }
                for (int i = 0; i < indices.Count; i++)
                {
                    clipP[i] = allClipP[indices[i]];
                }
                for (int i = 0; i < obj.Length; i++)
                {
                    planetLabel[i] = GameObject.Find("PlanetTag" + i.ToString());
                }
            }
        }

        if (useJoystick)
        {
            joystickPositionRight = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.RTouch);
            joystickPositionLeft  = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.LTouch);
        }
        else
        {
            ctrlPosition = OVRInput.GetLocalControllerPosition(controller);
        }


        var delta = (ctrlPosition - previousCtrlPosition) * 600;

        if (planetsFound)
        {
            ///TRANSLATION OF THE PLANETS ON X AND Y DEPENDING ON VIEW TYPE
            if (rightTriggerDown)
            {
                for (int i = 0; i < obj.Length; i++)
                {
                    if (circleViewType)
                    {
                        if (useJoystick)
                        {
                            CircularTranslation(obj[i], planetLabel[i], joystickPositionRight * Vector3.one);
                            CircularTranslation(clipP[i], planetLabel[i], joystickPositionRight * Vector3.one);
                        }
                        else
                        {
                            CircularTranslation(obj[i], planetLabel[i], delta);
                            CircularTranslation(clipP[i], planetLabel[i], delta);
                        }
                    }
                    else
                    {
                        if (useJoystick)
                        {
                            LinearTranslation(obj[i], planetLabel[i], joystickPositionRight * Vector3.one);
                            LinearTranslation(clipP[i], planetLabel[i], joystickPositionRight * Vector3.one);
                        }
                        else
                        {
                            LinearTranslation(obj[i], planetLabel[i], delta);
                            LinearTranslation(clipP[i], planetLabel[i], delta);
                        }
                    }
                }
            }

            ///ROTATION OF THE PLANETS AROUND THEMSELVES; CAN ONLY USE JOYSTICK
            if (leftTriggerDown)
            {
                for (int i = 0; i < obj.Length; i++)
                {
                    if (useJoystick)
                    {
                        Rotation(obj[i], joystickPositionLeft * Vector3.one);
                        Rotation(clipP[i], joystickPositionLeft * Vector3.one);
                    }
                    else
                    {
                        Rotation(obj[i], delta);
                        //Rotation(clipP[i], delta);
                    }
                }
            }
        }

        previousCtrlPosition = ctrlPosition;
    }
        /// <summary>
        /// Update the controller data from the provided platform state
        /// </summary>
        /// <param name="interactionSourceState">The InteractionSourceState retrieved from the platform</param>
        public void UpdateController(OVRInput.Controller ovrController, Transform trackingRoot)
        {
            if (!Enabled || trackingRoot == null)
            {
                return;
            }

            IsPositionAvailable = OVRInput.GetControllerPositionValid(ovrController);
            IsRotationAvailable = OVRInput.GetControllerOrientationValid(ovrController);

            // Update transform
            Vector3 localPosition = OVRInput.GetLocalControllerPosition(ovrController);
            Vector3 worldPosition = trackingRoot.TransformPoint(localPosition);
            // Debug.Log("Controller " + Handedness + " - local: " + localPosition + " - world: " + worldPosition);

            Quaternion localRotation = OVRInput.GetLocalControllerRotation(ovrController);
            Quaternion worldRotation = trackingRoot.rotation * localRotation;

            // Update velocity
            Vector3 localVelocity = OVRInput.GetLocalControllerVelocity(ovrController);

            Velocity = trackingRoot.TransformDirection(localVelocity);

            Vector3 localAngularVelocity = OVRInput.GetLocalControllerAngularVelocity(ovrController);

            AngularVelocity = trackingRoot.TransformDirection(localAngularVelocity);

            UpdateJointPoses();

            // If not rendering avatar hands, pointer pose is not available, so we approximate it
            if (IsPositionAvailable)
            {
                currentPointerPose.Position = currentGripPose.Position = worldPosition;
            }

            if (IsRotationAvailable)
            {
                currentPointerPose.Rotation = currentGripPose.Rotation = worldRotation;
            }

            // Todo: Complete touch controller mapping
            bool  isTriggerPressed;
            float triggerValue;

            bool  isGripPressed;
            float gripValue;

            Vector2 stickInput;

            if (ControllerHandedness == Handedness.Left)
            {
                triggerValue     = OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger);
                isTriggerPressed = triggerValue > cTriggerDeadZone;

                gripValue     = OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger);
                isGripPressed = gripValue > cTriggerDeadZone;

                stickInput = OVRInput.Get(OVRInput.RawAxis2D.LThumbstick);
            }
            else
            {
                triggerValue     = OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger);
                isTriggerPressed = triggerValue > cTriggerDeadZone;

                gripValue     = OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger);
                isGripPressed = gripValue > cTriggerDeadZone;

                stickInput = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick);
            }

            UpdateHandPinchStrength(Mathf.Max(triggerValue, gripValue));

            bool isSelecting = isTriggerPressed || isGripPressed;

            UpdateTeleport(stickInput);

            for (int i = 0; i < Interactions?.Length; i++)
            {
                switch (Interactions[i].InputType)
                {
                case DeviceInputType.SpatialPointer:
                    Interactions[i].PoseData = currentPointerPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentPointerPose);
                    }
                    break;

                case DeviceInputType.SpatialGrip:
                    Interactions[i].PoseData = currentGripPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentGripPose);
                    }
                    break;

                case DeviceInputType.Select:
                    Interactions[i].BoolData = isSelecting;

                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.TriggerPress:
                    Interactions[i].BoolData = isSelecting;

                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.IndexFinger:
                    UpdateIndexFingerData(Interactions[i]);
                    break;
                }
            }
        }