示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (isTouchingLeft)
        {
            //change hover materiar based on angle
            byte result = (byte)Mathf.FloorToInt(leftController.GetTouchpadAxisAngle() / (360 / 3));
            switch (result)
            {
            case 0:
                leftOptions.GetComponent <MeshRenderer>().material.mainTexture = ivSelectedTexture;
                break;

            case 1:
                leftOptions.GetComponent <MeshRenderer>().material.mainTexture = imSelectedTexture;
                break;

            case 2:
                leftOptions.GetComponent <MeshRenderer>().material.mainTexture = scSelectedTexture;
                break;
            }
        }
        if (isTouchingRight)
        {
            byte result = (byte)Mathf.FloorToInt(rightController.GetTouchpadAxisAngle() / (360 / 3));
            switch (result)
            {
            case 0:
                rightOptions.GetComponent <MeshRenderer>().material.mainTexture = ivSelectedTexture;
                break;

            case 1:
                rightOptions.GetComponent <MeshRenderer>().material.mainTexture = imSelectedTexture;
                break;

            case 2:
                rightOptions.GetComponent <MeshRenderer>().material.mainTexture = scSelectedTexture;
                break;
            }
        }
    }
    private void UpdateDisplayMode()
    {
        bool cycleUp   = (LeftControllerEvents.touchpadPressed && (LeftControllerEvents.GetTouchpadAxisAngle() < 30 || LeftControllerEvents.GetTouchpadAxisAngle() > 330)) ? true : false;
        bool cycleDown = (LeftControllerEvents.touchpadPressed && (LeftControllerEvents.GetTouchpadAxisAngle() < 210 && LeftControllerEvents.GetTouchpadAxisAngle() > 150)) ? true : false;

        //bool cycleUp = OVRInput.GetDown(OVRInput.Button.One) || OVRInput.GetDown(OVRInput.Button.Three);
        //bool cycleDown = OVRInput.GetDown(OVRInput.Button.Two) || OVRInput.GetDown(OVRInput.Button.Four);
        if (cycleUp)
        {
            _modeIndex = (_modeIndex + 1) % modes.Length;
            ApplyDisplayMode();
        }
        if (cycleDown)
        {
            _modeIndex = _modeIndex - 1;
            if (_modeIndex == -1)
            {
                _modeIndex = modes.Length - 1;
            }
            ApplyDisplayMode();
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        float   axisAngle = controllerEvents.GetTouchpadAxisAngle();
        Vector2 axis      = controllerEvents.GetTouchpadAxis();

        Debug.Log("The axis is: " + axis);
        if (controllerEvents.buttonOnePressed)
        {
            superNova.transform.localEulerAngles += Vector3.up * Time.deltaTime * scaleFactor;
        }
        else if (controllerEvents.buttonTwoPressed)
        {
            superNova.transform.localEulerAngles += Vector3.down * Time.deltaTime * scaleFactor;
        }
    }
示例#4
0
    protected virtual void InputHandle()
    {
        if (controllerEvents)
        {
            trigger.localPosition = new Vector3(triggerRestPos.x + (0.07f * controllerEvents.GetTriggerAxis()), triggerRestPos.y, triggerRestPos.z);

            if (controllerEvents.touchpadPressed)
            {
                float angle = controllerEvents.GetTouchpadAxisAngle();
                if (angle < 45 || angle > 315)
                {
                    SlideStopped = false;
                }
                else if (angle < 225 && angle > 135)
                {
                    if (magRelease)
                    {
                        UnLoadMagazine();
                    }
                }
            }


            if (controllerEvents.triggerClicked && (!fired || fullAuto))
            {
                FireBullet();
                fired = true;
            }

            if (fired && !controllerEvents.triggerClicked)
            {
                fired = false;
            }
        }
        else
        {
            trigger.localPosition = triggerRestPos;
        }
    }
示例#5
0
    private void LogPlayerData(PhotonMessageInfo info)
    {
        if (isLogging && playerStreamWriter != null)
        {
            headPos  = headset.position;
            headRot  = headset.rotation;
            leftPos  = leftController.position;
            leftRot  = leftController.rotation;
            rightPos = rightController.position;
            rightRot = rightController.rotation;

            gazeHit  = Physics.Raycast(headset.position, headset.forward, out gazeRaycast);
            leftHit  = Physics.Raycast(leftController.position, leftController.forward, out leftRaycast);
            rightHit = Physics.Raycast(rightController.position, rightController.forward, out rightRaycast);

            gazeInfo  = GetRaycastInfo(gazeHit, gazeRaycast, gazeInfo);
            leftInfo  = GetRaycastInfo(leftHit, leftRaycast, leftInfo);
            rightInfo = GetRaycastInfo(rightHit, rightRaycast, rightInfo);

            playerStreamWriter.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\t{18}\t{19}\t{20}\t{21}\t{22}\t{23}\t{24}\t{25}\t{26}\t{27}\t{28}\t{29}" +
                                         "\t{30}\t{31}\t{32}\t{33}\t{34}\t{35}\t{36}\t{37}\t{38}\t{39}\t{40}\t{41}",
                                         (info.SentServerTime - startTime).ToString("F3"),
                                         // Head position
                                         headPos.x.ToString(format),
                                         headPos.y.ToString(format),
                                         headPos.z.ToString(format),
                                         // Head rotation
                                         headRot.x.ToString(format),
                                         headRot.y.ToString(format),
                                         headRot.z.ToString(format),
                                         headRot.w.ToString(format),
                                         // Left controller position
                                         leftPos.x.ToString(format),
                                         leftPos.y.ToString(format),
                                         leftPos.z.ToString(format),
                                         // Left controller rotation
                                         leftRot.x.ToString(format),
                                         leftRot.y.ToString(format),
                                         leftRot.z.ToString(format),
                                         leftRot.w.ToString(format),
                                         // Left controller events
                                         leftControllerEvents.triggerClicked.ToString(),
                                         leftControllerEvents.gripClicked.ToString(),
                                         leftControllerEvents.touchpadPressed.ToString(),
                                         leftControllerEvents.touchpadPressed ? leftControllerEvents.GetTouchpadAxisAngle().ToString(format) : "-1",
                                         // Right controller position
                                         rightPos.x.ToString(format),
                                         rightPos.y.ToString(format),
                                         rightPos.z.ToString(format),
                                         // Right controller rotation
                                         rightRot.x.ToString(format),
                                         rightRot.y.ToString(format),
                                         rightRot.z.ToString(format),
                                         rightRot.w.ToString(format),
                                         // Right controller events
                                         rightControllerEvents.triggerClicked.ToString(),
                                         rightControllerEvents.gripClicked.ToString(),
                                         rightControllerEvents.touchpadPressed.ToString(),
                                         rightControllerEvents.touchpadPressed ? rightControllerEvents.GetTouchpadAxisAngle().ToString(format) : "-1",
                                         // Raycasting
                                         gazeInfo.ObjectName,
                                         gazeInfo.OriginalObjectOwner,
                                         gazeInfo.ObjectOwner,
                                         gazeInfo.ObjectID,
                                         leftInfo.ObjectName,
                                         leftInfo.OriginalObjectOwner,
                                         leftInfo.ObjectOwner,
                                         leftInfo.ObjectID,
                                         rightInfo.ObjectName,
                                         rightInfo.OriginalObjectOwner,
                                         rightInfo.ObjectOwner,
                                         rightInfo.ObjectID
                                         );

            playerStreamWriter.Flush();
        }
    }
    // Update is called once per frame
    void Update()
    {
        Vector2 axisChange = contrlEvents.GetTouchpadAxis();
        //Debug.Log("This is angle: " + contrlEvents.GetTouchpadAxisAngle());
        float dirMagnitude = axisChange.SqrMagnitude();

        // to go forward
        if ((contrlEvents.GetTouchpadAxisAngle() < 45f || contrlEvents.GetTouchpadAxisAngle() > 315f) &&
            contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the mf magnitude: " + dirMagnitude);

            Vector3 dir = transform.forward;

            //Debug.Log("This is the mf direction: " + dir);
            if (dir.y >= 0)
            {
                dir.y -= .5f;
            }
            cameraRig.transform.position += (dir * dirMagnitude * .2f);
        }

        // to rotate right
        else if ((contrlEvents.GetTouchpadAxisAngle() < 135f && contrlEvents.GetTouchpadAxisAngle() >= 45f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the angle: " + contrlEvents.GetTouchpadAxisAngle());
            cameraRig.transform.Rotate(Vector3.up * dirMagnitude);
        }

        // to rotate left
        else if ((contrlEvents.GetTouchpadAxisAngle() > 225f && contrlEvents.GetTouchpadAxisAngle() <= 315f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the angle: " + contrlEvents.GetTouchpadAxisAngle());
            cameraRig.transform.Rotate(Vector3.down * dirMagnitude);
        }

        // to go backward
        else if ((contrlEvents.GetTouchpadAxisAngle() > 135f && contrlEvents.GetTouchpadAxisAngle() <= 225f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            Vector3 dir = transform.forward;

            //Debug.Log("This is the mf direction: " + -dir);
            if (dir.y >= 0)
            {
                dir.y -= .5f;
            }
            cameraRig.transform.position += (-dir * dirMagnitude * .2f);
        }
    }