Beispiel #1
0
        void Update()
        {
            if (_keyboard != null && _keyboard.IsKeyToggled(MiddleVR.VRK_SPACE))
            {
                print("Space!");
            }
            for (uint i = 0; i < 6; ++i)
            {
                if (_spaceNavAxis != null && Mathf.Approximately(_spaceNavAxis.GetValue(i), 0))
                {
                    print("SpaceNavAxis " + i + " : " + _spaceNavAxis.GetValue(i));
                }
            }

            if (_spaceNavButtons != null)
            {
                for (uint i = 0; i < 2; ++i)
                {
                    if (_spaceNavButtons.IsToggled(i))
                    {
                        print("SpaceNavButton " + i + " pressed.");
                    }
                    if (_spaceNavButtons.IsToggled(i, false))
                    {
                        print("SpaceNavButton " + i + " released.");
                    }
                }
            }

            if (_flystickAxis != null && Mathf.Approximately(_flystickAxis.GetValue(0), 0))
            {
                print("FlystickAxis Horizontal: " + _flystickAxis.GetValue(0));
            }
            if (_flystickAxis != null && Mathf.Approximately(_flystickAxis.GetValue(1), 0))
            {
                print("FlystickAxis Vertical: " + _flystickAxis.GetValue(1));
            }

            if (_flystickButtons == null)
            {
                return;
            }
            for (uint i = 0; i < 6; ++i)
            {
                if (_flystickButtons.IsToggled(i))
                {
                    print("FlystickButton " + i + " pressed.");
                }
                if (_flystickButtons.IsToggled(i, false))
                {
                    print("FlystickButton " + i + " released.");
                }
            }
        }
Beispiel #2
0
    private void TestDevices()
    {
        vrTracker  tracker = null;
        vrJoystick joy     = null;
        vrAxis     axis    = null;
        vrButtons  buttons = null;

        var deviceMgr = MiddleVR.VRDeviceMgr;

        // Getting a reference to different device types
        if (deviceMgr != null)
        {
            tracker = deviceMgr.GetTracker("VRPNTracker0.Tracker0");
            joy     = deviceMgr.GetJoystickByIndex(0);
            axis    = deviceMgr.GetAxis("VRPNAxis0.Axis");
            buttons = deviceMgr.GetButtons("VRPNButtons0.Buttons");
        }

        // Getting tracker data
        if (tracker != null)
        {
            MVRTools.Log("TrackerX : " + tracker.GetPosition().x());
        }

        // Testing joystick button
        if (joy != null && joy.IsButtonPressed(0))
        {
            MVRTools.Log("Joystick!");
        }

        // Testing axis value
        if (axis != null && axis.GetValue(0) > 0)
        {
            MVRTools.Log("Axis Value: " + axis.GetValue(0));
        }

        // Testing button state
        if (buttons != null)
        {
            if (buttons.IsToggled(0))
            {
                MVRTools.Log("Button 0 pressed !");
            }

            if (buttons.IsToggled(0, false))
            {
                MVRTools.Log("Button 0 released !");
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //for desktop use

        /*if(Input.GetKeyDown(KeyCode.Z)){
         *      StartCoroutine(Spark ());
         *      StartCoroutine(light ());
         * }*/

        vrButtons buttons = null;

        // Getting a reference to different device types
        if (MiddleVR.VRDeviceMgr != null)
        {
            buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons0.Buttons");
        }
        if (buttons != null)
        {
            if (buttons.IsToggled(2))
            {
                //if(Input.GetKeyDown(KeyCode.Z)){
                StartCoroutine(Spark());
                StartCoroutine(lightFlame());
                //}
            }
        }
    }
Beispiel #4
0
    protected void Update()
    {
        int haptionDeviceId = 0;

        string haptionDeviceNameBase = "Haption" + haptionDeviceId;

        vrButtons buttons = MiddleVR.VRDeviceMgr.GetButtons(haptionDeviceNameBase + ".Buttons");

        for (uint i = 0, iEnd = buttons.GetButtonsNb(); i < iEnd; ++i)
        {
            if (buttons.IsToggled(i, true))
            {
                MiddleVRTools.Log(1, "[+] Haption button '" + i + "' is pressed.");
            }
            else if (buttons.IsToggled(i, false))
            {
                MiddleVRTools.Log(1, "[+] Haption button '" + i + "' is released.");
            }
        }
    }
Beispiel #5
0
    void MiddleVR_Buttons()
    {
        vrButtons buttons = null;

        if (MiddleVR.VRDeviceMgr != null)
        {
            buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons1.Buttons");
        }

        if (buttons != null)
        {
            if (buttons.IsToggled(0) | Input.GetKeyDown(KeyCode.F1))
            {
                MiddleVRTools.Log("Button 0 has been pressed");
                hand_node.GetComponent <Renderer>().material.color = Color.blue;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (8 >= toggleList.transform.childCount)
        {
            scrollbar.size = 1;
        }

        if (wandButtons.IsToggled(3))
        {
            SetVisible(!renderer.enabled);
        }

        if (renderer.enabled)
        {
            transform.position = headNode.transform.position + headNode.transform.forward * 7;
            transform.rotation = Quaternion.LookRotation(transform.position - headNode.transform.position);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!wand && !BookControl.bookInUse)
        {
            deselectBook(false);
        }
        if (MainGame.lampLit && !lit)
        {
            lit               = true;
            light.intensity   = 0.01f;
            light.cullingMask = 1 << 10;
            createBooks.SetLayerRecursively(transform.gameObject, 10);
        }

        /*if (Input.GetKeyUp (KeyCode.O)) {
         *      StartCoroutine( takeBook() );
         * }
         *
         * if (Input.GetKeyUp (KeyCode.P)) {
         *      StartCoroutine( PlayOneShot("flipPage") );
         * }
         *
         * if (Input.GetKeyUp (KeyCode.C)) {
         *      StartCoroutine( replaceBook() );
         * }*/
        vrButtons buttons = null;

        // Getting a reference to different device types
        if (MiddleVR.VRDeviceMgr != null)
        {
            buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons0.Buttons");
        }
        if (buttons != null)
        {
            if (buttons.IsToggled(0) && bookInUse)
            {
                StartCoroutine("flipPage");
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (m_Buttons == null)
        {
            m_Buttons = MiddleVR.VRDeviceMgr.GetWandButtons();
        }

        if (m_Buttons == null)
        {
            if (m_SearchedButtons == false)
            {
                //MiddleVRTools.Log("[~] VRWandInteraction: Wand buttons undefined. Please specify Wand Buttons in the configuration tool.");
                m_SearchedButtons = true;
            }
        }

        Collider hit = GetClosestHit();

        if (hit != null)
        {
            //print("Closest : " + hit.name);

            if (m_CurrentObject != hit.gameObject && m_ObjectInHand == null)
            {
                //MiddleVRTools.Log("Enter other : " + hit.name);
                HighlightObject(m_CurrentObject, false);
                m_CurrentObject = hit.gameObject;
                HighlightObject(m_CurrentObject, true);
                if (book != null && !book.name.Equals(m_CurrentObject.name))
                {
                    if (book.GetComponent <BookControl>() != null)
                    {
                        book.GetComponent <BookControl>().wand = false;
                    }
                }
                //MiddleVRTools.Log("Current : " + m_CurrentObject.name);
            }
        }
        // Else
        else
        {
            //MiddleVRTools.Log("No touch ! ");

            if (m_CurrentObject != null && m_CurrentObject != m_ObjectInHand)
            {
                HighlightObject(m_CurrentObject, false, HighlightColor);
                m_CurrentObject = null;
            }
        }

        //MiddleVRTools.Log("Current : " + m_CurrentObject);

        if (m_Buttons != null && m_CurrentObject != null)
        {
            uint MainButton = MiddleVR.VRDeviceMgr.GetWandButton0();

            VRActor script = m_CurrentObject.GetComponent <VRActor>();
            if (book != null && !book.name.Equals(m_CurrentObject.name))
            {
                if (book.GetComponent <BookControl>() != null)
                {
                    book.GetComponent <BookControl>().wand = false;
                }
            }
            //MiddleVRTools.Log("Trying to take :" + m_CurrentObject.name);
            if (script != null)
            {
                if (m_CurrentObject.GetComponent <BookControl>() != null)
                {
                    book = m_CurrentObject;
                    book.GetComponent <BookControl>().selectBook();
                }
                // Grab
                if (m_Buttons.IsToggled(MainButton))
                {
                    if (script.Grabable)
                    {
                        Grab(m_CurrentObject);
                    }
                }

                // Release
                if (m_Buttons.IsToggled(MainButton, false) && m_ObjectInHand != null)
                {
                    Ungrab();
                }

                // Action
                if (((!RepeatAction && m_Buttons.IsToggled(MainButton)) || (RepeatAction && m_Buttons.IsPressed(MainButton))))
                {
                    m_CurrentObject.SendMessage("VRAction", SendMessageOptions.DontRequireReceiver);
                }
            }
            else
            {
                if (book != null && book.GetComponent <BookControl>() != null)
                {
                    book.GetComponent <BookControl>().wand = false;
                }
            }
        }
    }