GetLocalControllerAngularAcceleration() публичный статический Метод

Gets the angular acceleration of the given Controller local to its tracking space. Only supported for Oculus LTouch and RTouch controllers. Non-tracked controllers will return Quaternion.identity.
public static GetLocalControllerAngularAcceleration ( OVRInput, controllerType ) : Quaternion
controllerType OVRInput,
Результат Quaternion
    void Update()
    {
        string status = ""
                        + "<b>Active: </b>" + OVRInput.GetActiveController() + "\n"
                        + "<b>Connected: </b>" + OVRInput.GetConnectedControllers() + "\n";

        status += "Orientation: " + OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController()) + "\n";
        status += "AngVel: " + OVRInput.GetLocalControllerAngularVelocity(OVRInput.GetActiveController()) + "\n";
        status += "AngAcc: " + OVRInput.GetLocalControllerAngularAcceleration(OVRInput.GetActiveController()) + "\n";
        status += "Position: " + OVRInput.GetLocalControllerPosition(OVRInput.GetActiveController()) + "\n";
        status += "Vel: " + OVRInput.GetLocalControllerVelocity(OVRInput.GetActiveController()) + "\n";
        status += "Acc: " + OVRInput.GetLocalControllerAcceleration(OVRInput.GetActiveController()) + "\n";
        status += "PrimaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad) + "\n";
        status += "SecondaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad) + "\n";

        for (int i = 0; i < monitors.Count; i++)
        {
            monitors[i].Update();
            status += monitors[i].ToString() + "\n";
        }

        if (uiText != null)
        {
            uiText.text = status;
        }
    }
    //Gear Controller code snippet at end of this Update() function
    void Update()
    {
        string status = ""
                        + "<b>Active: </b>" + OVRInput.GetActiveController() + "\n"
                        + "<b>Connected: </b>" + OVRInput.GetConnectedControllers() + "\n";

        status += "Orientation: " + OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController()) + "\n";
        status += "AngVel: " + OVRInput.GetLocalControllerAngularVelocity(OVRInput.GetActiveController()) + "\n";
        status += "AngAcc: " + OVRInput.GetLocalControllerAngularAcceleration(OVRInput.GetActiveController()) + "\n";
        status += "Position: " + OVRInput.GetLocalControllerPosition(OVRInput.GetActiveController()) + "\n";
        status += "Vel: " + OVRInput.GetLocalControllerVelocity(OVRInput.GetActiveController()) + "\n";
        status += "Acc: " + OVRInput.GetLocalControllerAcceleration(OVRInput.GetActiveController()) + "\n";
        status += "PrimaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad) + "\n";
        status += "SecondaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad) + "\n";

        for (int i = 0; i < monitors.Count; i++)
        {
            monitors[i].Update();
            status += monitors[i].ToString() + "\n";
        }

        if (uiText != null)
        {
            uiText.text = status;
        }

        // This queries if the trigger button of the primary hand has just been released
        if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger))
        {
            //if released, shoot projectile
            shootProjectile();
        }
    }
 private void UpdateMomentums()
 {
     leftHand.UpdateMomentum(
         OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch),
         OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch),
         OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch),
         OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch));
     rightHand.UpdateMomentum(
         OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch),
         OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch),
         OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch),
         OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch));
 }
        public override void OnUpdate()
        {
            OVRInput.Controller activeController = OVRInput.GetActiveController();

            rotation.Value = OVRInput.GetLocalControllerRotation(activeController);

            angularVelocity.Value = OVRInput.GetLocalControllerAngularVelocity(activeController);

            angularAcceleration.Value = OVRInput.GetLocalControllerAngularAcceleration(activeController);

            position.Value = OVRInput.GetLocalControllerPosition(activeController);

            velocity.Value = OVRInput.GetLocalControllerVelocity(activeController);

            acceleration.Value = OVRInput.GetLocalControllerAcceleration(activeController);
        }
Пример #5
0
    void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        data.Length = 0;

        float framerate = OVRPlugin.GetAppFramerate();

        data.AppendFormat("Framerate: {0:F2}\n", framerate);

        string activeControllerName = activeController.ToString();

        data.AppendFormat("Active: {0}\n", activeControllerName);

        string connectedControllerNames = OVRInput.GetConnectedControllers().ToString();

        data.AppendFormat("Connected: {0}\n", connectedControllerNames);

        Quaternion rot = OVRInput.GetLocalControllerRotation(activeController);

        data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", rot.x, rot.y, rot.z, rot.w);

        Vector3 angVel = OVRInput.GetLocalControllerAngularVelocity(activeController);

        data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", angVel.x, angVel.y, angVel.z);

        Vector3 angAcc = OVRInput.GetLocalControllerAngularAcceleration(activeController);

        data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", angAcc.x, angAcc.y, angAcc.z);

        Vector3 pos = OVRInput.GetLocalControllerPosition(activeController);

        data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", pos.x, pos.y, pos.z);

        Vector3 vel = OVRInput.GetLocalControllerVelocity(activeController);

        data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", vel.x, vel.y, vel.z);

        Vector3 acc = OVRInput.GetLocalControllerAcceleration(activeController);

        data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", acc.x, acc.y, acc.z);

        Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);

        data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", primaryTouchpad.x, primaryTouchpad.y);

        Vector2 secondaryTouchpad = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad);

        data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", secondaryTouchpad.x, secondaryTouchpad.y);

        for (int i = 0; i < monitors.Count; i++)
        {
            monitors[i].Update();
            monitors[i].AppendToStringBuilder(ref data);
        }

        if (uiText != null)
        {
            uiText.text = data.ToString();
        }
    }
    public void loop()
    {
#if VADR_GEARVR
        if (OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote)
        {
            orientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote);
            controllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTrackedRemote);
            controllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTrackedRemote);
            controllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTrackedRemote);
            controllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTrackedRemote);
            controllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTrackedRemote);
            Infos info = new Infos(19);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Orientation X", orientation.x);
            info.Add("Orientation Y", -1 * orientation.y);
            info.Add("Orientation Z", -1 * orientation.z);
            info.Add("Orientation W", orientation.w);
            info.Add("Position X", -1 * controllerPosition.x);
            info.Add("Position Y", controllerPosition.y);
            info.Add("Position Z", controllerPosition.z);
            info.Add("Velocity X", -1 * controllerVelocity.x);
            info.Add("Velocity Y", controllerVelocity.y);
            info.Add("Velocity Z", controllerVelocity.z);
            info.Add("Acceleration X", -1 * controllerAcceleration.x);
            info.Add("Acceleration Y", controllerAcceleration.y);
            info.Add("Acceleration Z", controllerAcceleration.z);
            info.Add("Ang Velocity X", controllerAngularVelocity.x);
            info.Add("Ang Velocity Y", -1 * controllerAngularVelocity.y);
            info.Add("Ang Velocity Z", -1 * controllerAngularVelocity.z);
            info.Add("Ang Acceleration X", controllerAngularAcceleration.x);
            info.Add("Ang Acceleration Y", -1 * controllerAngularAcceleration.y);
            info.Add("Ang Acceleration Z", -1 * controllerAngularAcceleration.z);
            VadRAnalyticsManager.RegisterEvent("vadrGearVR Controller Orientation", userCamera.transform.position, filterDictionary["RController"], info);
        }
        if (OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote)
        {
            orientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTrackedRemote);
            controllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTrackedRemote);
            controllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTrackedRemote);
            controllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTrackedRemote);
            controllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTrackedRemote);
            controllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTrackedRemote);
            Infos info = new Infos(19);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Orientation X", orientation.x);
            info.Add("Orientation Y", -1 * orientation.y);
            info.Add("Orientation Z", -1 * orientation.z);
            info.Add("Orientation W", orientation.w);
            info.Add("Position X", -1 * controllerPosition.x);
            info.Add("Position Y", controllerPosition.y);
            info.Add("Position Z", controllerPosition.z);
            info.Add("Velocity X", -1 * controllerVelocity.x);
            info.Add("Velocity Y", controllerVelocity.y);
            info.Add("Velocity Z", controllerVelocity.z);
            info.Add("Acceleration X", -1 * controllerAcceleration.x);
            info.Add("Acceleration Y", controllerAcceleration.y);
            info.Add("Acceleration Z", controllerAcceleration.z);
            info.Add("Ang Velocity X", controllerAngularVelocity.x);
            info.Add("Ang Velocity Y", -1 * controllerAngularVelocity.y);
            info.Add("Ang Velocity Z", -1 * controllerAngularVelocity.z);
            info.Add("Ang Acceleration X", controllerAngularAcceleration.x);
            info.Add("Ang Acceleration Y", -1 * controllerAngularAcceleration.y);
            info.Add("Ang Acceleration Z", -1 * controllerAngularAcceleration.z);
            VadRAnalyticsManager.RegisterEvent("vadrGearVR Controller Orientation", userCamera.transform.position, filterDictionary["LController"], info);
        }
#endif
    }
Пример #7
0
    void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        data.Length = 0;
        byte recenterCount = OVRInput.GetControllerRecenterCount();

        data.AppendFormat("RecenterCount: {0}\n", recenterCount);

        byte battery = OVRInput.GetControllerBatteryPercentRemaining();

        data.AppendFormat("Battery: {0}\n", battery);

        float framerate = OVRPlugin.GetAppFramerate();

        data.AppendFormat("Framerate: {0:F2}\n", framerate);

        string activeControllerName = activeController.ToString();

        data.AppendFormat("Active: {0}\n", activeControllerName);

        string connectedControllerNames = OVRInput.GetConnectedControllers().ToString();

        data.AppendFormat("Connected: {0}\n", connectedControllerNames);

        data.AppendFormat("PrevConnected: {0}\n", prevConnected);

        controllers.Update();
        controllers.AppendToStringBuilder(ref data);

        prevConnected = connectedControllerNames;

        Vector3 rot = OVRInput.GetLocalControllerRotation(activeController).eulerAngles;

        if (rot.x > 180f)
        {
            rot.x -= 360f;
        }
        if (rot.y > 180f)
        {
            rot.y -= 360f;
        }
        if (rot.z > 180f)
        {
            rot.z -= 360f;
        }

        data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2})\n", rot.x, rot.y, rot.z);
        //Quaternion rot = OVRInput.GetLocalControllerRotation(activeController);
        //data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2})\n", rot.x, rot.y, rot.z, rot.w);

        Vector3 angVel = OVRInput.GetLocalControllerAngularVelocity(activeController);

        data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", angVel.x, angVel.y, angVel.z);

        Vector3 angAcc = OVRInput.GetLocalControllerAngularAcceleration(activeController);

        data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", angAcc.x, angAcc.y, angAcc.z);

        Vector3 pos = OVRInput.GetLocalControllerPosition(activeController);

        data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", pos.x, pos.y, pos.z);

        Vector3 vel = OVRInput.GetLocalControllerVelocity(activeController);

        data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", vel.x, vel.y, vel.z);

        Vector3 acc = OVRInput.GetLocalControllerAcceleration(activeController);

        data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", acc.x, acc.y, acc.z);

        Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);

        data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", primaryTouchpad.x, primaryTouchpad.y);

        Vector2 secondaryTouchpad = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad);

        data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", secondaryTouchpad.x, secondaryTouchpad.y);

        float indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);

        data.AppendFormat("PrimaryIndexTriggerAxis1D: ({0:F2})\n", indexTrigger);

        float handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger);

        data.AppendFormat("PrimaryHandTriggerAxis1D: ({0:F2})\n", handTrigger);

        for (int i = 0; i < monitors.Count; i++)
        {
            monitors[i].Update();
            monitors[i].AppendToStringBuilder(ref data);
        }

        if (uiText != null)
        {
            uiText.text = data.ToString();
        }
    }
Пример #8
0
    void AddData()
    {
        RightP_X = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch).x.ToString();
        RightP_Y = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch).y.ToString();
        RightP_Z = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch).z.ToString();

        RightR_W = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).w.ToString();
        RightR_X = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).x.ToString();
        RightR_Y = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).y.ToString();
        RightR_Z = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).z.ToString();


        LeftP_X = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch).x.ToString();
        LeftP_Y = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch).y.ToString();
        LeftP_Z = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch).z.ToString();

        LeftR_W = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch).w.ToString();
        LeftR_X = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch).x.ToString();
        LeftR_Y = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch).y.ToString();
        LeftR_Z = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch).z.ToString();


        playerpos_X = Camera.main.gameObject.transform.position.x.ToString();
        playerpos_Y = Camera.main.gameObject.transform.position.y.ToString();
        playerpos_Z = Camera.main.gameObject.transform.position.z.ToString();


        playerrot_W = Camera.main.gameObject.transform.rotation.w.ToString();
        playerrot_X = Camera.main.gameObject.transform.rotation.x.ToString();
        playerrot_Y = Camera.main.gameObject.transform.rotation.y.ToString();
        playerrot_Z = Camera.main.gameObject.transform.rotation.z.ToString();

        Raccel_X = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch).x.ToString();
        Raccel_Y = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch).y.ToString();
        Raccel_Z = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch).z.ToString();

        Laccel_X = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch).x.ToString();
        Laccel_Y = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch).y.ToString();
        Laccel_Z = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch).z.ToString();

        Cam_pos_X = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye).x.ToString();
        Cam_pos_Y = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye).y.ToString();
        Cam_pos_Z = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye).z.ToString();

        Cam_rot_X = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye).x.ToString();
        Cam_rot_Y = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye).y.ToString();
        Cam_rot_Z = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye).z.ToString();
        Cam_rot_W = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye).w.ToString();

        Raaccel_X = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch).x.ToString();
        Raaccel_Y = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch).y.ToString();
        Raaccel_Z = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch).z.ToString();

        Laaccel_X = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch).x.ToString();
        Laaccel_Y = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch).y.ToString();
        Laaccel_Z = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch).z.ToString();

        Rvel_X = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch).x.ToString();
        Rvel_Y = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch).y.ToString();
        Rvel_Z = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch).z.ToString();

        Lvel_X = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch).x.ToString();
        Lvel_Y = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch).y.ToString();
        Lvel_Z = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch).z.ToString();

        Ravel_X = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch).x.ToString();
        Ravel_Y = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch).y.ToString();
        Ravel_Z = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch).z.ToString();

        Lavel_X = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch).x.ToString();
        Lavel_Y = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch).y.ToString();
        Lavel_Z = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch).z.ToString();

        PrimaryHandTrigger   = OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.LTouch).ToString();
        SecondaryHandTrigger = OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.RTouch).ToString();



        string[]        rowDataTemp = new string[55];
        List <string[]> rowData1    = new List <string[]>();

        // You can add up the values in as many cells as you want.

        rowDataTemp    = new string[55];
        rowDataTemp[0] = Time.frameCount.ToString();
        rowDataTemp[1] = RightP_X;
        rowDataTemp[2] = RightP_Y;
        rowDataTemp[3] = RightP_Z;

        rowDataTemp[4] = RightR_W;
        rowDataTemp[5] = RightR_X;
        rowDataTemp[6] = RightR_Y;
        rowDataTemp[7] = RightR_Z;

        rowDataTemp[8]  = LeftP_X;
        rowDataTemp[9]  = LeftP_Y;
        rowDataTemp[10] = LeftP_Z;

        rowDataTemp[11] = LeftR_W;
        rowDataTemp[12] = LeftR_X;
        rowDataTemp[13] = LeftR_Y;
        rowDataTemp[14] = LeftR_X;

        rowDataTemp[15] = playerpos_X;
        rowDataTemp[16] = playerpos_Y;
        rowDataTemp[17] = playerpos_Z;

        rowDataTemp[18] = playerrot_W;
        rowDataTemp[19] = playerrot_X;
        rowDataTemp[20] = playerrot_Y;
        rowDataTemp[21] = playerrot_Z;

        rowDataTemp[22] = Raccel_X;
        rowDataTemp[23] = Raccel_Y;
        rowDataTemp[24] = Raccel_Z;

        rowDataTemp[25] = Laccel_X;
        rowDataTemp[26] = Laccel_Y;
        rowDataTemp[27] = Laccel_Z;

        rowDataTemp[28] = Cam_pos_X;
        rowDataTemp[29] = Cam_pos_Y;
        rowDataTemp[30] = Cam_pos_Z;

        rowDataTemp[31] = Cam_rot_W;
        rowDataTemp[32] = Cam_rot_X;
        rowDataTemp[33] = Cam_rot_Y;
        rowDataTemp[34] = Cam_rot_Z;

        rowDataTemp[35] = Raaccel_X;
        rowDataTemp[36] = Raaccel_X;
        rowDataTemp[37] = Raaccel_X;

        rowDataTemp[38] = Laaccel_X;
        rowDataTemp[39] = Laaccel_Y;
        rowDataTemp[40] = Laaccel_Z;

        rowDataTemp[41] = Rvel_X;
        rowDataTemp[42] = Rvel_X;
        rowDataTemp[43] = Rvel_X;

        rowDataTemp[44] = Lvel_X;
        rowDataTemp[45] = Lvel_Y;
        rowDataTemp[46] = Lvel_Z;

        rowDataTemp[47] = Ravel_X;
        rowDataTemp[48] = Ravel_X;
        rowDataTemp[49] = Ravel_X;

        rowDataTemp[50] = Lavel_X;
        rowDataTemp[51] = Lavel_Y;
        rowDataTemp[52] = Lavel_Z;

        rowDataTemp[53] = PrimaryHandTrigger;
        rowDataTemp[54] = SecondaryHandTrigger;



        rowData1.Add(rowDataTemp);

        string[][] output = new string[rowData.Count][];

        for (int i = 0; i < output.Length; i++)
        {
            output[i] = rowData1[i];
        }

        int    length    = output.GetLength(0);
        string delimiter = ",";

        StringBuilder sb1 = new StringBuilder();

        for (int index = 0; index < length; index++)
        {
            sb1.AppendLine(string.Join(delimiter, output[index]));
        }


        StreamWriter outStream = File.AppendText(filePath + fileName);

        outStream.Write(sb1);
        outStream.Close();
    }
 void DoGetAcceleration()
 {
     controllerAngularAcceleration.Value = OVRInput.GetLocalControllerAngularAcceleration(controllerInput);
 }
Пример #10
0
    private void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();
        this.data.Length = 0;
        byte controllerRecenterCount = OVRInput.GetControllerRecenterCount(OVRInput.Controller.Active);

        this.data.AppendFormat("RecenterCount: {0}\n", controllerRecenterCount);
        byte controllerBatteryPercentRemaining = OVRInput.GetControllerBatteryPercentRemaining(OVRInput.Controller.Active);

        this.data.AppendFormat("Battery: {0}\n", controllerBatteryPercentRemaining);
        float appFramerate = OVRPlugin.GetAppFramerate();

        this.data.AppendFormat("Framerate: {0:F2}\n", appFramerate);
        string arg = activeController.ToString();

        this.data.AppendFormat("Active: {0}\n", arg);
        string arg2 = OVRInput.GetConnectedControllers().ToString();

        this.data.AppendFormat("Connected: {0}\n", arg2);
        this.data.AppendFormat("PrevConnected: {0}\n", OVRGearVrControllerTest.prevConnected);
        OVRGearVrControllerTest.controllers.Update();
        OVRGearVrControllerTest.controllers.AppendToStringBuilder(ref this.data);
        OVRGearVrControllerTest.prevConnected = arg2;
        Quaternion localControllerRotation = OVRInput.GetLocalControllerRotation(activeController);

        this.data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", new object[]
        {
            localControllerRotation.x,
            localControllerRotation.y,
            localControllerRotation.z,
            localControllerRotation.w
        });
        Vector3 localControllerAngularVelocity = OVRInput.GetLocalControllerAngularVelocity(activeController);

        this.data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAngularVelocity.x, localControllerAngularVelocity.y, localControllerAngularVelocity.z);
        Vector3 localControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(activeController);

        this.data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAngularAcceleration.x, localControllerAngularAcceleration.y, localControllerAngularAcceleration.z);
        Vector3 localControllerPosition = OVRInput.GetLocalControllerPosition(activeController);

        this.data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", localControllerPosition.x, localControllerPosition.y, localControllerPosition.z);
        Vector3 localControllerVelocity = OVRInput.GetLocalControllerVelocity(activeController);

        this.data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", localControllerVelocity.x, localControllerVelocity.y, localControllerVelocity.z);
        Vector3 localControllerAcceleration = OVRInput.GetLocalControllerAcceleration(activeController);

        this.data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", localControllerAcceleration.x, localControllerAcceleration.y, localControllerAcceleration.z);
        Vector2 vector = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", vector.x, vector.y);
        Vector2 vector2 = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad, OVRInput.Controller.Active);

        this.data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", vector2.x, vector2.y);
        float num = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryIndexTriggerAxis1D: ({0:F2})\n", num);
        float num2 = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.Active);

        this.data.AppendFormat("PrimaryHandTriggerAxis1D: ({0:F2})\n", num2);
        for (int i = 0; i < this.monitors.Count; i++)
        {
            this.monitors[i].Update();
            this.monitors[i].AppendToStringBuilder(ref this.data);
        }
        if (this.uiText != null)
        {
            this.uiText.text = this.data.ToString();
        }
    }
Пример #11
0
    public void loop()
    {
#if VADR_RIFT
        Infos info       = new Infos(38);
        bool  activeFlag = false;
        if (OVRInput.GetActiveController() == OVRInput.Controller.RTouch || OVRInput.GetActiveController() == OVRInput.Controller.Touch)
        {
            activeFlag                     = true;
            rOrientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
            rControllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
            rControllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);
            rControllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch);
            rControllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch);
            rControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Right Orientation X", rOrientation.x);
            info.Add("Right Orientation Y", -1 * rOrientation.y);
            info.Add("Right Orientation Z", -1 * rOrientation.z);
            info.Add("Right Orientation W", rOrientation.w);
            info.Add("Right Position X", -1 * rControllerPosition.x);
            info.Add("Right Position Y", rControllerPosition.y);
            info.Add("Right Position Z", rControllerPosition.z);
            info.Add("Right Velocity X", -1 * rControllerVelocity.x);
            info.Add("Right Velocity Y", rControllerVelocity.y);
            info.Add("Right Velocity Z", rControllerVelocity.z);
            info.Add("Right Acceleration X", -1 * rControllerAcceleration.x);
            info.Add("Right Acceleration Y", rControllerAcceleration.y);
            info.Add("Right Acceleration Z", rControllerAcceleration.z);
            info.Add("Right Ang Velocity X", rControllerAngularVelocity.x);
            info.Add("Right Ang Velocity Y", -1 * rControllerAngularVelocity.y);
            info.Add("Right Ang Velocity Z", -1 * rControllerAngularVelocity.z);
            info.Add("Right Ang Acceleration X", rControllerAngularAcceleration.x);
            info.Add("Right Ang Acceleration Y", -1 * rControllerAngularAcceleration.y);
            info.Add("Right Ang Acceleration Z", -1 * rControllerAngularAcceleration.z);
        }
        if (OVRInput.GetActiveController() == OVRInput.Controller.LTouch || OVRInput.GetActiveController() == OVRInput.Controller.Touch)
        {
            activeFlag                     = true;
            lOrientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
            lControllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
            lControllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch);
            lControllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch);
            lControllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch);
            lControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Left Orientation X", lOrientation.x);
            info.Add("Left Orientation Y", -1 * lOrientation.y);
            info.Add("Left Orientation Z", -1 * lOrientation.z);
            info.Add("Left Orientation W", lOrientation.w);
            info.Add("Left Position X", -1 * lControllerPosition.x);
            info.Add("Left Position Y", lControllerPosition.y);
            info.Add("Left Position Z", lControllerPosition.z);
            info.Add("Left Velocity X", -1 * lControllerVelocity.x);
            info.Add("Left Velocity Y", lControllerVelocity.y);
            info.Add("Left Velocity Z", lControllerVelocity.z);
            info.Add("Left Acceleration X", -1 * lControllerAcceleration.x);
            info.Add("Left Acceleration Y", lControllerAcceleration.y);
            info.Add("Left Acceleration Z", lControllerAcceleration.z);
            info.Add("Left Ang Velocity X", lControllerAngularVelocity.x);
            info.Add("Left Ang Velocity Y", -1 * lControllerAngularVelocity.y);
            info.Add("Left Ang Velocity Z", -1 * lControllerAngularVelocity.z);
            info.Add("Left Ang Acceleration X", lControllerAngularAcceleration.x);
            info.Add("Left Ang Acceleration Y", -1 * lControllerAngularAcceleration.y);
            info.Add("Left Ang Acceleration Z", -1 * lControllerAngularAcceleration.z);
        }
        if (activeFlag)
        {
            VadRAnalyticsManager.RegisterEvent("vadrRift Controller Orientation", userCamera.transform.position, info);
        }
#endif
    }
Пример #12
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            _active = !_active;
        }

        _left.Position              = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
        _right.Position             = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
        _left.AngularVelocity       = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch);
        _right.LinearVelocity       = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);
        _left.LinearAccelleration   = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch);
        _right.AngularAccelleration = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch);

        _left.Rotation              = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
        _right.Rotation             = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
        _left.AngularVelocity       = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch);
        _right.AngularVelocity      = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch);
        _left.AngularAccelleration  = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch);
        _right.AngularAccelleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch);

        var indexL = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch);
        var indexR = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.RTouch);

        float x = 0f;
        float y = 0f;

        // Shift look up and down by linearly moving controller
        // Todo: linear, but seen from which perspective? Hands and arms trace arcs. Use that.
        x += _right.LinearVelocity.x * (0.5f + 0.5f * indexR) * 100f;
        y += _right.LinearVelocity.y * (0.5f + 0.5f * indexR) * -100f;

        // Shift look by rotating
        x += _right.AngularVelocity.y * (0.5f + 0.5f * indexR) * 13f;
        y += _right.AngularVelocity.x * (0.5f + 0.5f * indexR) * 13f;

        // Push look by rotating
        float angleX = AngleAroundAxis(_right.Rotation * Vector3.forward, Vector3.forward, Vector3.up);
        float angleY = AngleAroundAxis(_right.Rotation * Vector3.forward, Vector3.forward, Vector3.right);

        x += (Mathf.Sign(angleX) * Mathf.Pow(Mathf.Min(Mathf.Abs(angleX) / 75f, 1f), 2f)) * -120f;
        y += (Mathf.Sign(angleY) * Mathf.Pow(Mathf.Min(Mathf.Abs(angleY) / 75f, 1f), 2f)) * -120f;

        if (_active)
        {
            // Look
            SimMouse.ActRaw(SimMouse.Action.MoveOnly, Mathf.RoundToInt(x), Mathf.RoundToInt(y));

            //Vector2 moveAnalog = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.LTouch);

            // Shoot
            HandleKey(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch, DirectInput.ScanCode.H);

            // Move
            HandleKey(OVRInput.Button.Up, OVRInput.Controller.LTouch, DirectInput.ScanCode.W);
            HandleKey(OVRInput.Button.Down, OVRInput.Controller.LTouch, DirectInput.ScanCode.S);
            HandleKey(OVRInput.Button.Left, OVRInput.Controller.LTouch, DirectInput.ScanCode.A);
            HandleKey(OVRInput.Button.Right, OVRInput.Controller.LTouch, DirectInput.ScanCode.D);

            HandleKey(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.LTouch, DirectInput.ScanCode.Space);
            HandleKey(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.LTouch, DirectInput.ScanCode.LControl);

            // Switch weapons
            HandleKey(OVRInput.Button.Left, OVRInput.Controller.RTouch, DirectInput.ScanCode.Q);
            HandleKey(OVRInput.Button.Right, OVRInput.Controller.RTouch, DirectInput.ScanCode.E);
            HandleKey(OVRInput.Button.One, OVRInput.Controller.RTouch, DirectInput.ScanCode.R);
            HandleKey(OVRInput.Button.Up, OVRInput.Controller.RTouch, DirectInput.ScanCode.Two);
            HandleKey(OVRInput.Button.Down, OVRInput.Controller.RTouch, DirectInput.ScanCode.Three);
            HandleKey(OVRInput.Button.PrimaryThumbstick, OVRInput.Controller.RTouch, DirectInput.ScanCode.One);

            // Zoom
            HandleKey(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.RTouch, DirectInput.ScanCode.J);
        }
    }