private void OnTriggerEnter(Collider other)
    {
        if (other.name != "HandCollider")
        {
            return;
        }
        VRButtonFuncs.VibrateTouch(other);

        string displayName = gameObject.name;

        anim.SetTrigger("TouchClick");

        //Debug.Log(gameObject.tag);

        switch (gameObject.tag)
        {
        case "PartButton":
            StartCoroutine(tsController.ChangePartStatus(assocGameObj));
            break;

        case "ScrollBarButton":
            StartCoroutine(tsController.Scroll(gameObject));
            break;

        default:
            StartCoroutine(tsController.SwitchToCanvas(displayName));
            break;
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.name != "HandCollider")
        {
            return;
        }
        VRButtonFuncs.VibrateTouch(other);

        string displayName = gameObject.name;

        anim.SetTrigger("TouchClick");

        switch (displayName)
        {
        // Panel Switches
        case "ColorBy":
            StartCoroutine(tsController.SwitchToColorByCanvas());
            break;

        case "Rotate":
            StartCoroutine(tsController.SwitchToRotateCanvas());
            break;

        case "Return":
            StartCoroutine(tsController.Return());
            break;

        // ColorBy commands
        case "Mass":
            StartCoroutine(tsController.colorBy("Mass"));
            break;

        case "Volume":
            StartCoroutine(tsController.colorBy("Volume"));
            break;

        case "Material":
            StartCoroutine(tsController.colorBy("Material"));
            break;

        case "AvgHeat":
            StartCoroutine(tsController.colorBy("AvgHeat"));
            break;

        // Rotate Commands
        case "RotateModel":
            StartCoroutine(tsController.RotateModel(other));
            break;

        case "RotateUp":
            StartCoroutine(tsController.RotateUp());
            break;

        case "RotateDown":
            StartCoroutine(tsController.RotateDown());
            break;
        }
        //GetComponent<Image>().color.a = 255f;
    }
    //// Possible public "OnClick" methods to call when 3D button is pressed

    public void ResetClick(Collider other)
    {
        if (other.name != "Button")
        {
            return;
        }
        VRButtonFuncs.VibrateTouch(other);
        VRButtonFuncs.ResetAll(other);
    }
    public IEnumerator RotateModel(Collider other)
    {
        yield return(new WaitForSeconds(.617f));

        GameObject rotateLight = new GameObject("RotateLight");

        VRButtonFuncs.RotateComponents(other, isRotating);

        isRotating = !isRotating;
    }
 // DEPRECATED -- Moved from physical button to panel on the screen
 public void RotateClick(Collider other)
 {
     if (other.name != "Button")
     {
         return;
     }
     new GameObject("RotateLight");
     VRButtonFuncs.RotateComponents(other, isRotating);
     isRotating = !isRotating;
 }
 public void QuitClick(Collider other)
 {
     if (other.name != "Button")
     {
         return;
     }
     VRButtonFuncs.VibrateTouch(other);
     SceneManager.LoadScene("MainMenu");
     GameObject.Find("ApplicationInfoStarter").GetComponent <AudioSource>().Play(0);
 }
    // DEPRECATED -- always open
    public void OpenControlScreenClick(Collider other)
    {
        if (other.name != "Button")
        {
            return;
        }
        VRButtonFuncs.VibrateTouch(other);
        GameObject controlScreen = GameObject.Find("ControlScreen");

        // VRButtonFuncs.ControlScreenOn(other, controlOn, controlScreen);
        controlOn = !controlOn;
    }
    public void ScreenClick(Collider other)
    {
        if (other.name != "Button")
        {
            return;
        }

        VRButtonFuncs.VibrateTouch(other);
        GameObject holder = GameObject.Find("FloatingScreen");

        VRButtonFuncs.ScreenOn(other, screenisOn, holder);
        screenisOn = !screenisOn;
    }
Exemple #9
0
    private void Update()
    {
        bool rNearTouch = OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, OVRInput.Controller.RTouch);
        bool lNearTouch = OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, OVRInput.Controller.LTouch);

        //Right and left hand Hand Triggers
        float rPHTrig = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.RTouch);
        float lPHTrig = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch);

        //Right and left hand Index Triggers
        float rPITrig = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.RTouch);
        float lPITrig = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.LTouch);


        // TOGGLE FUNCTIONALITY
        if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick, OVRInput.Controller.RTouch))
        {
            //if (!handFunc.isLaser)
            if (SceneManager.GetActiveScene().name == "OkloVROutdoors_PROPRIETARY" || !handFunc.isLaser)
            {
                if (!tooltipOn)
                {
                    ToolTipActivation(true);
                }
                else
                {
                    ToolTipActivation(false);
                }
            }
        }

        // RESETTING FUNCTIONAILTY
        if ((lPITrig == 1 && lPHTrig == 1 && lNearTouch))// && (rPITrig == 1 && rPHTrig == 1 && rNearTouch))
        {
            if (!resetSoundStarted)
            {
                aSourceReset.Play(0);
                resetSoundStarted = true;
            }
            resetValueCanvas.gameObject.SetActive(true);

            float curPct = resetValueCanvas.transform.GetChild(0).GetChild(0).GetComponent <ProgressBar>().currentPercent;

            curPct += Time.deltaTime / 1.25f * 100f;


            if (curPct >= 100)
            {
                if (!resetHasStarted)
                {
                    StartCoroutine(DelayReset());
                    resetValueCanvas.transform.GetChild(0).GetChild(0).GetComponent <ProgressBar>().currentPercent = 100;
                    resetHasStarted = false;
                }
                resetValueCanvas.gameObject.SetActive(false);
            }
            else
            {
                VRButtonFuncs.VibrateTouch(lHand.GetComponent <Collider>());
                resetValueCanvas.transform.GetChild(0).GetChild(0).GetComponent <ProgressBar>().currentPercent = curPct;
            }
        }
        else
        {
            aSourceReset.Stop();
            resetSoundStarted = false;
            resetValueCanvas.transform.GetChild(0).GetChild(0).GetComponent <ProgressBar>().currentPercent = 0;
            resetValueCanvas.gameObject.SetActive(false);
        }
    }
    /// <summary>
    /// Called on the entry of the hand collider (essentially attached to the user's index finger)
    /// to the box collider associated with each button.
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerEnter(Collider other)
    {
        if (other.name != "HandCollider")
        {
            return;                               // only index finger triggers should activate button presses
        }
        // Stop from double touching;
        if (recentlyTouched)
        {
            return;
        }
        recentlyTouched = true;
        StartCoroutine(TouchDelay()); // start counting for next touch

        // Haptic function
        VRButtonFuncs.VibrateTouch(other);

        // Grab the name of the button (CRITICAL: naming allows for proper function execution)
        string displayName = gameObject.name;

        // Button click animation
        anim.SetTrigger("TouchClick");

        // Execute proper function
        switch (displayName)
        {
        // LAUNCH!!!
        case "LaunchButton":
            // pause music and start 2001 A Space Odessey theme
            GameObject.Find("Starter").GetComponent <AudioSource>().Pause();
            AudioSource aLaunchMusic = SetAudioSource(aLaunchClip, false, false, 1f);
            aLaunchMusic.Play(0);
            // Start launch animation
            StartCoroutine(tsController.InitiateLaunchSequence());
            break;


        // Reactor Orientations
        case "HorizontalOrientation":
            tsController.SwitchToHorizontalOrientation();
            break;

        case "VerticalOrientation":
            tsController.SwitchToVerticalOrientation();
            break;

        // Animations
        case "ConstructionAnimation":
            tsController.Animate("Construction");
            break;


        // Animation Controls (Switch to animation object with play pause skip forward backward overwrite methods)
        case "Play":
            tsController.activeAnimObj.Play();

            gameObject.name = "Pause";
            GetComponentInChildren <Text>().text = "Pause";
            break;

        case "Pause":
            tsController.activeAnimObj.Pause();

            gameObject.name = "Play";
            GetComponentInChildren <Text>().text = "Play";
            break;

        case "SkipForward":
            tsController.activeAnimObj.SkipForward();

            playpause.name = "Play";
            playpause.GetComponentInChildren <Text>().text = "Play";
            break;

        case "SkipBackward":
            tsController.activeAnimObj.SkipBackward();

            playpause.name = "Play";
            playpause.GetComponentInChildren <Text>().text = "Play";
            break;
        }
    }
    /// <summary>
    /// Raycasts and returns the collided object that should be connected
    /// to whichHand - adjusts the pointers for the appropriate grabbed object.
    /// </summary>
    /// <param name="whichHand"></param>
    /// <returns></returns>
    private GameObject RayCastSearch(GameObject whichHand)
    {
        RaycastHit hit;
        // initiate the layermask
        int layerMask = 1 << 9;

        layerMask = ~layerMask; // we want every layer except for the 8th to be masked


        /////////// NEEDS UPDATE - Switch method for updating position to: grab-exit function-update-drop instead of grab/update ///////////
        if (whichHand == rHand)
        {
            Vector3[] rPoints = { whichHand.transform.position, (whichHand.transform.forward * 500 + whichHand.transform.position) };


            rRend.positionCount = rPoints.Length;
            rRend.SetPositions(rPoints);

            if (Physics.Raycast(whichHand.transform.position, whichHand.transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
            {
                if (hit.transform.tag != "ReactorComponent")
                {
                    return(null);
                }

                if (rLastHit.transform != null)
                {
                    rLastHit.transform.gameObject.GetComponent <Renderer>().material.color = Color.white;
                }

                hit.transform.gameObject.GetComponent <Renderer>().material = (Material)Instantiate(Resources.Load("Materials/LaserMode"));

                if (rLastMov != null)
                {
                    rDeltaMov = rPoints[1] - rLastMov;
                }

                if (OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.RTouch) == 1)
                {
                    if (rgrabbedObj == null)
                    {
                        aSourceGrab.Play(0);
                        VRButtonFuncs.VibrateTouch(rHand.GetComponent <Collider>());
                        rgrabbedObj = hit.transform.gameObject;
                    }
                }
                else
                {
                    rgrabbedObj = null;
                }

                rLastMov = rPoints[1];


                rLastHit = hit;

                return(hit.collider.gameObject);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            Vector3[] lPoints = { whichHand.transform.position, (whichHand.transform.forward * 500 + whichHand.transform.position) };


            lRend.positionCount = lPoints.Length;
            lRend.SetPositions(lPoints);

            if (Physics.Raycast(whichHand.transform.position, whichHand.transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
            {
                if (hit.transform.tag != "ReactorComponent")
                {
                    return(null);
                }

                if (lLastHit.transform != null)
                {
                    lLastHit.transform.gameObject.GetComponent <Renderer>().material.color = Color.white;
                }

                hit.transform.gameObject.GetComponent <Renderer>().material = (Material)Instantiate(Resources.Load("Materials/LaserMode"));


                if (lLastMov != null)
                {
                    lDeltaMov = lPoints[1] - lLastMov;
                }

                if (OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch) == 1)
                {
                    if (lgrabbedObj == null)
                    {
                        aSourceGrab.Play(0);
                        VRButtonFuncs.VibrateTouch(lHand.GetComponent <Collider>());
                        lgrabbedObj = hit.transform.gameObject;
                    }
                }
                else
                {
                    lgrabbedObj = null;
                }

                lLastMov = lPoints[1];

                lLastHit = hit;

                return(hit.collider.gameObject);
            }
            else
            {
                return(null);
            }
        }
    }