Exemplo n.º 1
0
        private void Update()
        {
            // Store Values to calculate simple velocity
            prevValue = currValue;
            currValue = controllable.GetNormalizedValue();
            currValue = Utils.Approximately(0, currValue) ? 0f : // if close to 0 set to zero      (Should probably used Stepped Function instead)
                        Utils.Approximately(1, currValue) ? 1f : // if close to 1 set to one
                        Mathf.Round(currValue * 1000) / 1000f;   // otherwise round value

            // Simple Press Release check (should update to VRTK event based mechanism)
            if (!padPressed && currValue > triggerThreshold)
            {
                if (sendPressedReleased)
                {
                    if (sendVelocity)
                    {
                        SendOscMessage(string.Format("{0}/pressed", oscAddress), Mathf.Min(rb.velocity.magnitude, 1));
                    }
                    else
                    {
                        SendOscMessage(string.Format("{0}/pressed", oscAddress));
                    }
                }
                padPressed = true;
            }
            else if (padPressed && currValue < triggerThreshold)
            {
                if (sendPressedReleased)
                {
                    if (sendVelocity)
                    {
                        SendOscMessage(string.Format("{0}/released", oscAddress), Mathf.Min(rb.velocity.magnitude, 1));
                    }
                    else
                    {
                        SendOscMessage(string.Format("{0}/released", oscAddress));
                    }
                }
                padPressed = false;
            }
        }
Exemplo n.º 2
0
        private void Update()
        {
            // Store Values to calculate simple velocity
            prevValue = currValue;
            currValue = controllable.GetNormalizedValue();
            currValue = Approximately(0, currValue) ? 0f :     // if close to 0 set to zero
                        Approximately(1, currValue) ? 1f :     // if close to 1 set to one
                        Mathf.Round(currValue * 1000) / 1000f; // otherwise round value

            // Simple Press Release check (should update to VRTK event based mechanism)
            if (!padPressed && currValue > oscPad.triggerThreshold)
            {
                if (oscPad.sendPressedReleased)
                {
                    List <object> values = new List <object>();
                    if (oscPad.sendVelocity)
                    {
                        values.Add(Mathf.Min(rb.velocity.magnitude / .5f, 1));        // normalize magnitude to .5 (based on experience)
                    }
                    oscTransmitObject.SendOSCMessage(string.Format("{0}/pressed", oscTransmitObject.oscAddress), values.ToArray());
                }
                padPressed = true;
            }
            else if (padPressed && currValue < oscPad.triggerThreshold)
            {
                if (oscPad.sendPressedReleased)
                {
                    List <object> values = new List <object>();
                    if (oscPad.sendVelocity)
                    {
                        values.Add(Mathf.Min(rb.velocity.magnitude / .5f, 1));
                    }
                    oscTransmitObject.SendOSCMessage(string.Format("{0}/released", oscTransmitObject.oscAddress), values.ToArray());
                }
                padPressed = false;
            }
        }
Exemplo n.º 3
0
    void Update()
    {
        // value buttons return
        Value1 = Button1.GetNormalizedValue();
        Value2 = Button2.GetNormalizedValue();
        Value3 = Button3.GetNormalizedValue();

        Value4 = Button4.GetNormalizedValue();



        // change bomb radius with weight



        if (Value2 > 0)
        {
            button2pressed = true;
            maxRadius      = 12f;
            RadiusClose();

            if (currentScale > 0)
            {
                RadiusClose();
            }
        }


        if (Value3 > 0)
        {
            button3pressed = true;
            maxRadius      = 18f;
            RadiusClose();

            if (currentScale > 0)
            {
                RadiusClose();
            }
        }

        if (Value1 > 0)
        {
            button1pressed = true;
            maxRadius      = 4f;

            if (currentScale > 0)
            {
                RadiusClose();
            }
        }

        if (Value4 > 0)
        {
            TriggerToggle();
            button4pressed = true;
        }



        if (button1pressed == true && currentScale < 0.1f)
        {
            RadiusExpand();
            button1pressed = false;
        }

        if (button2pressed == true && currentScale < 0.1f)
        {
            RadiusExpand();
            button2pressed = false;
        }
        if (button3pressed == true && currentScale < 0.1f)
        {
            RadiusExpand();
            button3pressed = false;
        }


        //presentation stuff

        if ((presentationScript.currentSceneNumber == 102 && previousSceneNumber != 102) || (presentationScript.currentSceneNumber == 106 && previousSceneNumber != 106) || (presentationScript.currentSceneNumber == 103 && previousSceneNumber != 103) && forcedBombDone == false)
        {
            RadiusExpand();
            //forcedBombDone = true;
            presentationScript.forceBombRadiusOpen = false;
        }

        if (presentationScript.forceBombRadiusClose == true && forcedBombDone == false)
        {
            RadiusClose();

            forcedBombDone = true;
            forcedBombOpen = false;
        }

        if (presentationScript.forceBombRadiusOpen == true && forcedBombOpen == false)
        {
            RadiusExpand();

            forcedBombOpen = true;
            forcedBombDone = false;
        }

        if (presentationScript.forceBombRadiusCloseSCENE5sequence0 == true && forcedBombDoneSCENE5sequence0 == false)
        {
            if (this.gameObject == BombZoom0)
            {
                RadiusExpand();
            }
            else
            {
                RadiusClose();
            }

            forcedBombDoneSCENE5sequence0 = true;
            forcedBombDoneSCENE5sequence1 = false;
        }

        if (presentationScript.forceBombRadiusCloseSCENE5sequence1 == true && forcedBombDoneSCENE5sequence1 == false)
        {
            if (this.gameObject == BombZoom1)
            {
                RadiusExpand();
            }
            else
            {
                RadiusClose();
            }

            forcedBombDoneSCENE5sequence1 = true;
            forcedBombDoneSCENE5sequence0 = false;
        }

        if (presentationScript.forceBombRadiusCloseSCENE4sequence2 == true && forcedBombDoneSCENE4sequence2 == false)
        {
            if (this.gameObject == BombZoom2)
            {
                RadiusClose();
            }
            else
            {
                RadiusExpand();
            }

            forcedBombDoneSCENE4sequence2 = true;
        }

        if (presentationScript.forceBombRadiusOpenSCENE4sequence1 == true && forcedBombOpenSCENE4sequence1 == false)
        {
            if (this.gameObject == BombZoom2)
            {
                RadiusExpand();
            }
            else
            {
                RadiusClose();
            }

            forcedBombOpenSCENE4sequence1 = true;
        }


        if (presentationScript.currentSceneNumber != 105)
        {
            forcedBombDoneSCENE5sequence0 = false;
            presentationScript.forceBombRadiusCloseSCENE5sequence0 = false;

            forcedBombDoneSCENE5sequence1 = false;
            presentationScript.forceBombRadiusCloseSCENE5sequence1 = false;
        }

        if (presentationScript.SequenceNumber == 0 || presentationScript.SequenceNumber == presentationScript.MaxScene4Sequences)
        {
            forcedBombOpenSCENE4sequence1 = false;
            presentationScript.forceBombRadiusOpenSCENE4sequence1 = false;
        }

        if (presentationScript.SequenceNumber != presentationScript.MaxScene4Sequences)
        {
            forcedBombDoneSCENE4sequence2 = false;
            presentationScript.forceBombRadiusCloseSCENE4sequence2 = false;
        }

        // button pressed
        if (Input.GetKeyDown(KeyCode.T))
        {
            TriggerToggle();
        }

        previousSceneNumber = presentationScript.currentSceneNumber;
    }