Example #1
0
    private void _SetParticlesSeeds()
    {
        if (MiddleVR.VRClusterMgr.IsCluster())
        {
            // Creating the list of randomSeed / is playOnAwake to sync the seeds
            // of each particle systems to the master
            vrValue particlesDataList = vrValue.CreateList();

            foreach (ParticleSystem particle in GameObject.FindObjectsOfType(typeof(ParticleSystem)) as ParticleSystem[])
            {
                if (MiddleVR.VRClusterMgr.IsServer())
                {
                    vrValue particleData = vrValue.CreateList();

                    particleData.AddListItem((int)particle.randomSeed);
                    particleData.AddListItem(particle.playOnAwake);

                    particlesDataList.AddListItem(particleData);
                }
                // We reset the particle systems to sync them in every nodes of the cluster
                particle.Clear();
                particle.Stop();
                particle.time = .0f;
            }

            m_startParticlesCommand = new vrCommand("startParticleCommand", StartParticlesCommandHandler);

            if (MiddleVR.VRClusterMgr.IsServer())
            {
                m_startParticlesCommand.Do(particlesDataList);
            }
        }
    }
Example #2
0
 private void updatePlot()
 {
     if (MiddleVR.VRClusterMgr.IsServer() || (!MiddleVR.VRClusterMgr.IsCluster()))
     {
         vrValue iVal = vrValue.CreateList();
         iVal.AddListItem(WebApiCall.CallWeb(SPEED_URL));
         iVal.AddListItem(WebApiCall.CallWeb(DIR_URL));
         m_cmdUpdatePlot.Do(iVal);
     }
 }
    private void Start()
    {
        // Create commands

        m_ButtonCommand      = new vrCommand("GUIMenuSample.ButtonCommand", ButtonHandler);
        m_CheckboxCommand    = new vrCommand("GUIMenuSample.CheckboxCommand", CheckboxHandler);
        m_RadioCommand       = new vrCommand("GUIMenuSample.RadioCommand", RadioHandler);
        m_ColorPickerCommand = new vrCommand("GUIMenuSample.ColorPickerCommand", ColorPickerHandler);
        m_SliderCommand      = new vrCommand("GUIMenuSample.SliderCommand", SliderHandler);
        m_ListCommand        = new vrCommand("GUIMenuSample.ListCommand", ListHandler);

        // Create GUI

        m_GUIRendererWeb = null;

        VRWebView webViewScript = GetComponent <VRWebView>();

        if (webViewScript == null)
        {
            MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView.");
            enabled = false;
            return;
        }

        m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView);

        m_Menu = new vrWidgetMenu("GUIMenuSample.MainMenu", m_GUIRendererWeb);

        m_Button1 = new vrWidgetButton("GUIMenuSample.Button1", m_Menu, "Button", m_ButtonCommand);

        new vrWidgetSeparator("GUIMenuSample.Separator1", m_Menu);

        m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", m_Menu, "Toggle Button", m_CheckboxCommand, true);

        m_Submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", m_Menu, "Sub Menu");
        m_Submenu.SetVisible(true);

        m_Radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", m_Submenu, "Huey", m_RadioCommand, "Huey");
        m_Radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", m_Submenu, "Dewey", m_RadioCommand, "Dewey");
        m_Radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", m_Submenu, "Louie", m_RadioCommand, "Louie");

        m_Picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", m_Menu, "Color Picker", m_ColorPickerCommand, new vrVec4(0, 0, 0, 0));

        m_Slider = new vrWidgetSlider("GUIMenuSample.Slider", m_Menu, "Slider", m_SliderCommand, 50.0f, 0.0f, 100.0f, 1.0f);

        vrValue listContents = vrValue.CreateList();

        listContents.AddListItem("Item 1");
        listContents.AddListItem("Item 2");

        m_List = new vrWidgetList("GUIMenuSample.List", m_Menu, "List", m_ListCommand, listContents, 0);
    }
Example #4
0
    // On the server, call the cluster command with a list of [position, rotation] every update
    // On all nodes, _CommandHandler will be called the next time there is a synchronization update :
    // either during VRManagerScript Update() or VRManagerPostFrame Update() (see script ordering)
    protected void Update()
    {
        if (m_ClusterMgr.IsServer())
        {
            // put position and orientation in a vrValue as a list
            Vector3    p = transform.position;
            Quaternion q = transform.rotation;

            vrValue val = vrValue.CreateList();
            val.AddListItem(new vrVec3(p.x, p.y, p.z));
            val.AddListItem(new vrQuat(q.x, q.y, q.z, q.w));

            // Do the actual call
            // This returns immediately
            m_Command.Do(val);
        }
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        m_cmdLoadFirstData = new vrCommand("WindPlotCmdLoadFirstData", cmdLoadFirstData);
        m_cmdAutoPopulate  = new vrCommand("WindPlotCmdAutoPopulate", cmdAutoPopulate);
        m_cmdUpdatePlot    = new vrCommand("WindPlotCmdUpdate", cmdUpdatePlot);

        listData     = new List <Dictionary <string, object> >();
        listRealTime = new List <Dictionary <string, object> >();
        if (MiddleVR.VRClusterMgr.IsServer() || (!MiddleVR.VRClusterMgr.IsCluster()))
        {
            vrValue iVal = vrValue.CreateList();
            iVal.AddListItem(WebApiCall.CallWeb(SPEED_URL));
            iVal.AddListItem(WebApiCall.CallWeb(DIR_URL));
            m_cmdLoadFirstData.Do(iVal);
        }
        autoPopulate();
        InvokeRepeating("updatePlot", UpdateRate, UpdateRate);
    }
Example #6
0
    private void autoPopulate()
    {
        DateTime dt = DateTime.Now.Add(new TimeSpan(-1, 0, 0));

        lastPushUp = dt;

        if (MiddleVR.VRClusterMgr.IsServer() || (!MiddleVR.VRClusterMgr.IsCluster()))
        {
            int layerNum = 1;
            while (layerNum < MAX_LAYER)
            {
                dt = dt.AddMinutes(-LayersUpdateRateMin);
                vrValue iVal = vrValue.CreateList();
                iVal.AddListItem(layerNum);
                iVal.AddListItem(WebApiCall.CallWeb(URL, dt.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture)));
                m_cmdAutoPopulate.Do(iVal);
                layerNum++;
            }
        }
    }
    protected void Update()
    {
        var deviceMgr = MiddleVR.VRDeviceMgr;

        if (deviceMgr != null)
        {
            var headTracker   = deviceMgr.GetTracker("zSpace.Head.Tracker");
            var stylusTracker = deviceMgr.GetTracker("zSpace.Stylus.Tracker");

            if (headTracker == null || stylusTracker == null)
            {
                MiddleVRTools.Log(0, "[X] No head or stylus tracker found for zSpace. Did you load the driver?");
                enabled = false;
                return;
            }

            bool headTargetIsVisible = headTracker.IsTracked();
            if (headTargetWasVisible != headTargetIsVisible)
            {
                MiddleVRTools.Log(2, "[+] Head is " + (headTargetIsVisible ? "visible" : "invisible") +
                                  " by the zSpace device.");

                headTargetWasVisible = headTargetIsVisible;
            }

            bool stylusTargetIsVisible = stylusTracker.IsTracked();
            if (stylusTargetWasVisible != stylusTargetIsVisible)
            {
                MiddleVRTools.Log(2, "[+] Stylus is " + (stylusTargetIsVisible ? "visible" : "invisible") +
                                  " by the zSpace device.");

                stylusTargetWasVisible = stylusTargetIsVisible;
            }
        }

        var kernel = MiddleVR.VRKernel;

        if (kernel != null && deviceMgr != null)
        {
            if (deviceMgr.IsKeyToggled(MiddleVR.VRK_C))
            {
                Color c = m_UsingLEDColor0 ? m_LEDColor0 : m_LEDColor1;

                vrVec3 proposedColor = new vrVec3(c.r, c.g, c.b);

                MiddleVRTools.Log(2, "[+] Proposed stylus LED color sent to zSpace: ("
                                  + proposedColor.x() + ", " + proposedColor.y() + ", " + proposedColor.z() + ").");

                kernel.ExecuteCommand(
                    "zSpace.SetStylusLEDColor", proposedColor);

                m_UsingLEDColor0 = !m_UsingLEDColor0;

                vrVec3 usedColorAsRGB = GetStylusLEDColor();

                MiddleVRTools.Log(2, "[+] Current zSpace stylus LED color is: ("
                                  + usedColorAsRGB.x() + ", " + usedColorAsRGB.y() + ", " + usedColorAsRGB.z() + ").");
            }

            if (deviceMgr.IsKeyToggled(MiddleVR.VRK_L))
            {
                bool turnOnLight = true;

                if (deviceMgr.IsKeyPressed(MiddleVR.VRK_LSHIFT) || deviceMgr.IsKeyPressed(MiddleVR.VRK_RSHIFT))
                {
                    turnOnLight = false;
                }

                MiddleVRTools.Log(2, "[+] Trying to turn " +
                                  (turnOnLight ? "on" : "off") + " the zSpace stylus LED.");

                kernel.ExecuteCommand(
                    "zSpace.SetStylusLEDAsTurnedOn", turnOnLight);

                vrValue isLEDTurnedOnValue = kernel.ExecuteCommand(
                    "zSpace.IsStylusLEDTurnedOn", null);

                bool isLEDTurnedOn = isLEDTurnedOnValue.GetBool();

                MiddleVRTools.Log(2, "[+] zSpace stylus LED turned on? " +
                                  (isLEDTurnedOn ? "Yes" : "No") + ".");

                if (isLEDTurnedOn)
                {
                    vrVec3 usedColorAsRGB = GetStylusLEDColor();

                    MiddleVRTools.Log(2, "[+] Current zSpace stylus LED color is: ("
                                      + usedColorAsRGB.x() + ", " + usedColorAsRGB.y() + ", " + usedColorAsRGB.z() + "). If set to black, no light will appear!");
                }
            }

            if (deviceMgr.IsKeyToggled(MiddleVR.VRK_V))
            {
                if (deviceMgr.IsKeyPressed(MiddleVR.VRK_LSHIFT) || deviceMgr.IsKeyPressed(MiddleVR.VRK_RSHIFT))
                {
                    // Stop vibration (nothing will happen if the stylus
                    // is not vibrating).

                    MiddleVRTools.Log(2, "[+] Trying to stop zSpace stylus vibration.");

                    kernel.ExecuteCommand(
                        "zSpace.StopStylusVibration", null);
                }
                else
                {
                    // Start vibration.

                    MiddleVRTools.Log(2, "[+] Trying to start zSpace stylus vibration with parameters:\n" +
                                      "- duration vibration: " + m_DurationVibration + " s,\n" +
                                      "- duration between two vibrations: " + m_DurationBetween + " s,\n" +
                                      "- number of vibrations: " + m_NumberOfVibrations + ".");

                    vrValue vibrationValueList = vrValue.CreateList();
                    vibrationValueList.AddListItem(m_DurationVibration);
                    vibrationValueList.AddListItem(m_DurationBetween);
                    vibrationValueList.AddListItem(m_NumberOfVibrations);
                    // It is also possible to set the intensity of the vibration:
                    // pass then a 4th argument with a float between 0.0 and 1.0.
                    //vibrationValueList.AddListItem(1.0f);

                    kernel.ExecuteCommand(
                        "zSpace.StartStylusVibration", vibrationValueList);
                }
            }

            if (deviceMgr.IsKeyToggled(MiddleVR.VRK_T))
            {
                MiddleVRTools.Log(2, "[+] Trying to trigger a default zSpace stylus vibration.");

                kernel.ExecuteCommand(
                    "zSpace.TriggerDefaultStylusVibration",
                    true);  // or false to stop the vibration (if any).
            }
        }
    }
    private void Start()
    {
        // Automatically register all methods with the [VRCommand] attribute
        MVRTools.RegisterCommands(this);

        // Create GUI

        VRWebView webViewScript = GetComponent <VRWebView>();

        if (webViewScript == null)
        {
            MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView.");
            enabled = false;
            return;
        }

        var GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView);

        // Register the object so the garbage collector does not collect it after this method.
        // The object will be disposed when the GameObject is destroyed.
        MVRTools.RegisterObject(this, GUIRendererWeb);

        var menu = new vrWidgetMenu("GUIMenuSample.MainMenu", GUIRendererWeb);

        MVRTools.RegisterObject(this, menu);

        var button1 = new vrWidgetButton("GUIMenuSample.Button1", menu, "Button", MVRTools.GetCommand("ButtonHandler"));

        MVRTools.RegisterObject(this, button1);

        var separator = new vrWidgetSeparator("GUIMenuSample.Separator1", menu);

        MVRTools.RegisterObject(this, separator);

        m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", menu, "Toggle Button", MVRTools.GetCommand("CheckboxHandler"), true);
        MVRTools.RegisterObject(this, m_Checkbox);

        var submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", menu, "Sub Menu");

        submenu.SetVisible(true);
        MVRTools.RegisterObject(this, submenu);

        var radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", submenu, "Huey", MVRTools.GetCommand("RadioHandler"), "Huey");

        MVRTools.RegisterObject(this, radio1);
        var radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", submenu, "Dewey", MVRTools.GetCommand("RadioHandler"), "Dewey");

        MVRTools.RegisterObject(this, radio2);
        var radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", submenu, "Louie", MVRTools.GetCommand("RadioHandler"), "Louie");

        MVRTools.RegisterObject(this, radio3);

        var picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", menu, "Color Picker", MVRTools.GetCommand("ColorPickerHandler"), new vrVec4(0, 0, 0, 0));

        MVRTools.RegisterObject(this, picker);

        var slider = new vrWidgetSlider("GUIMenuSample.Slider", menu, "Slider", MVRTools.GetCommand("SliderHandler"), 50.0f, 0.0f, 100.0f, 1.0f);

        MVRTools.RegisterObject(this, slider);

        vrValue listContents = vrValue.CreateList();

        listContents.AddListItem("Item 1");
        listContents.AddListItem("Item 2");

        var list = new vrWidgetList("GUIMenuSample.List", menu, "List", MVRTools.GetCommand("ListHandler"), listContents, 0);

        MVRTools.RegisterObject(this, list);
    }