Exemplo n.º 1
0
    public bool addDevice(string deviceName, VRPNDeviceType type)
    {
        Debug.Log(deviceName);
        VRPNDevice device = new VRPNDevice(deviceName, type);

        if (true || (availableDevices.Contains(deviceName) && !devices.ContainsKey(deviceName)))
        {
            devices.Add(deviceName, device);
            switch (type)
            {
            case VRPNDeviceType.Phantom:
                Debug.Log("Instanciating VRPNPicker");
                GameObject go = (GameObject)GameObject.Instantiate(Resources.Load("VRPN/VRPNPicker", typeof(GameObject)), Vector3.zero, Quaternion.identity);
                Debug.Log("Configuring VRPNPickerController");
                VRPNPickerController s1 = go.GetComponent <VRPNPickerController>();
                if (s1)
                {
                    s1.setManager(this);
                    s1.setDeviceName(deviceName);
                }

                Debug.Log("After pickercontroller");

                VRPNButtonController s2 = go.GetComponent <VRPNButtonController>();
                if (s2)
                {
                    s2.setManager(this);
                    s2.setDeviceName(deviceName);
                }

                VRPNForceFeedback s3 = go.GetComponent <VRPNForceFeedback>();
                if (s3)
                {
                    s3.setManager(this);
                    s3.setDeviceName(deviceName);
                    if (!s3.startDeviceInLib())
                    {
                        Debug.Log(":: VRPNManager :: Can't activate Force Feedback");
                    }
                }

                break;

            case VRPNDeviceType.Mouse3DConnexion:
                VRPNAnalogController s = GameObject.FindGameObjectWithTag("LoadBox").GetComponent <VRPNAnalogController>();
                s.setManager(this);
                break;

            default:
                break;
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 2
0
    public void renderDevicesGUI()
    {
        if (initialized)
        {
            VRPNDevice dev;
            foreach (DictionaryEntry de in devices)
            {
                dev = (VRPNDevice)de.Value;

                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                GUILayout.Label(dev.getName());
                GUILayout.EndHorizontal();

                if (dev.getType() == VRPNDeviceType.Phantom)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Connected");
                    GUILayout.EndHorizontal();
                }
                else if (dev.getType() == VRPNDeviceType.Mouse3DConnexion)
                {
                    VRPNAnalogController script = GameObject.FindGameObjectWithTag("LoadBox").GetComponent <VRPNAnalogController>();

                    GUILayout.BeginHorizontal();
                    script.axisInverted = GUILayout.Toggle(script.axisInverted, "Invert Axis");
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("X Speed");
                    GUILayout.Label(script.xspeed.ToString());
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    script.xspeed = GUILayout.HorizontalSlider(script.xspeed, 0.0f, 4.0f);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Y Speed");
                    GUILayout.Label(script.yspeed.ToString());
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    script.yspeed = GUILayout.HorizontalSlider(script.yspeed, 0.0f, 4.0f);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Zoom Speed");
                    GUILayout.Label(script.zspeed.ToString());
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    script.zspeed = GUILayout.HorizontalSlider(script.zspeed, 0.0f, 4.0f);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Rotation Speed");
                    GUILayout.Label(script.rotationSpeed.ToString());
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    script.rotationSpeed = GUILayout.HorizontalSlider(script.rotationSpeed, 120.0f, 280.0f);
                    GUILayout.EndHorizontal();
                }
            }
        }
    }