Example #1
0
    private vrValue cmdLoadFirstData(vrValue iVal)
    {
        string strResponse = iVal.GetString();

        plot.Init(strResponse);
        return(null);
    }
Example #2
0
        public vrValue ResetRotation(vrValue iValue)
        {
            var node = MiddleVR.VRDisplayMgr.GetNode("VRSystemCenterNode");

            node.SetOrientationLocal(new vrQuat(node.GetYawLocal(), 0, 0));
            return(0);
        }
    private vrValue ColorPickerHandler(vrValue iValue)
    {
        vrVec4 color = iValue.GetVec4();

        print("Selected color : " + color.x().ToString() + " " + color.y().ToString() + " " + color.z().ToString());
        return(null);
    }
    protected vrVec3 GetStylusLEDColor()
    {
        vrValue usedColorValue = MiddleVR.VRKernel.ExecuteCommand(
            "zSpace.GetStylusLEDColor", null);

        return(usedColorValue.GetVec3());
    }
 private void SliderHandler(vrValue iValue)
 {
     if (iValue.IsNumber())
     {
         Debug.Log("Slider value as Number = " + iValue.GetNumber());
     }
 }
Example #6
0
    private vrValue cmdAutoPopulate(vrValue iVal)
    {
        int    layerNum         = iVal[0].GetInt();
        string strSpeedResponse = iVal[1].GetString();
        string strDirResponse   = iVal[2].GetString();

        List <Dictionary <string, object> > listTempData = plot.GetPastData(strSpeedResponse, strDirResponse);

        if (listTempData.Count != 0)
        {
            strLastUpdateDt = (string)listTempData.Last()[WindPlot.Headers.Timestamp];

            List <Dictionary <string, object> > listConcat;
            listConcat = listData.Concat(listTempData).ToList();
            maxSpeed   = Convert.ToSingle(listConcat.Max(item => item[WindPlot.Headers.Speed]));
            minSpeed   = Convert.ToSingle(listConcat.Min(item => item[WindPlot.Headers.Speed]));

            for (int i = 0; i < listTempData.Count; i++)
            {
                plotPt(listTempData[i], PointHolder, layerNum, true);
                listData.Insert(0, listTempData[i]);
            }
            listTempData.Clear();
        }
        return(null);
    }
Example #7
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);
            }
        }
    }
 private void RadioHandler(vrValue iValue)
 {
     if (iValue.IsString())
     {
         Debug.Log("Radio value = " + iValue.GetString());
     }
 }
Example #9
0
    private vrValue cmdUpdatePlot(vrValue iVal)
    {
        List <Dictionary <string, object> > listLastData;
        string strSpeedResponse = iVal[0].GetString();
        string strDirResponse   = iVal[1].GetString();

        if (!strLastUpdateDt.Equals(""))
        {
            listLastData = plot.GetLastData(strSpeedResponse, strDirResponse, strLastUpdateDt);
        }
        else
        {
            Debug.LogError("Should never reach here... ");
            listLastData = plot.GetLastData(strSpeedResponse, strDirResponse, null);
        }

        Debug.Log("wind recevied " + listLastData.Count + " @ " + DateTime.Now);

        if (listLastData.Count != 0)
        {
            strLastUpdateDt = (string)listLastData.Last()[WindPlot.Headers.Timestamp];
            if (DateTime.Now - lastPushUp > new TimeSpan(0, LayersUpdateRateMin, 0))
            {
                lastPushUp = DateTime.Now;
                pushPointsUp();
                listData.AddRange(listRealTime);
                listRealTime.Clear();
            }

            // averaging the data before update layer
            foreach (Dictionary <string, object> pt in listLastData)
            {
                if (listRealTime.Exists(p => Convert.ToString(p[WindPlot.Headers.Id]).Equals((string)pt[WindPlot.Headers.Id])))
                {
                    Dictionary <string, object> realPt = listRealTime.Find(p => Convert.ToString(p[WindPlot.Headers.Id]).Equals((string)pt[WindPlot.Headers.Id]));
                    realPt[WindPlot.Headers.Speed]     = (float)((float)realPt[WindPlot.Headers.Speed] + (float)pt[WindPlot.Headers.Speed]) / 2.0f;
                    realPt[WindPlot.Headers.Dir]       = (float)((float)realPt[WindPlot.Headers.Dir] + (float)pt[WindPlot.Headers.Dir]) / 2.0f;
                    realPt[WindPlot.Headers.Timestamp] = pt[WindPlot.Headers.Timestamp];
                }
                else
                {
                    listRealTime.Add(pt);
                }
            }

            List <Dictionary <string, object> > listConcat;
            listConcat = listData.Concat(listRealTime).ToList();
            maxSpeed   = Convert.ToSingle(listConcat.Max(item => item[WindPlot.Headers.Speed]));
            minSpeed   = Convert.ToSingle(listConcat.Min(item => item[WindPlot.Headers.Speed]));

            clearRealTime();
            for (int i = 0; i < listRealTime.Count; i++)
            {
                plotPt(listRealTime[i], RealTimeHolder);
            }
        }

        return(null);
    }
Example #10
0
 private vrValue RadioHandler(vrValue iValue)
 {
     if(iValue.IsString())
     {
         Debug.Log("Radio value = " + iValue.GetString() );
     }
     return null;
 }
Example #11
0
    private vrValue cmdLoadFirstData(vrValue iVal)
    {
        string strSpeedResponse = iVal[0].GetString();
        string strDirResponse   = iVal[1].GetString();

        plot.Init(strSpeedResponse, strDirResponse);
        return(null);
    }
 private vrValue SliderHandler(vrValue iValue)
 {
     if (iValue.IsNumber())
     {
         Debug.Log("Slider value as Number = " + iValue.GetNumber());
     }
     return(null);
 }
 private vrValue RadioHandler(vrValue iValue)
 {
     if (iValue.IsString())
     {
         Debug.Log("Radio value = " + iValue.GetString());
     }
     return(null);
 }
Example #14
0
 public vrValue SetRadius(vrValue iValue)
 {
     if (Algorithm == null || !iValue.IsNumber())
         return null;
     _radius = iValue.GetDouble();
     ((vtkSphereSource) Algorithm).SetRadius(_radius);
     return null;
 }
Example #15
0
    private vrValue CommandHandler(vrValue iValue)
    {
        print("HTML Button was clicked");

        m_webView.ExecuteJavascript("setText('Button was clicked !')");

        return(null);
    }
Example #16
0
    private vrValue ButtonHandler(vrValue iValue)
    {
        m_Progress += 1;

        GetComponent <VRWebView>().webView.ExecuteJavascript("$('#progressbar').progressbar('value'," + m_Progress.ToString() + ");");

        return(null);
    }
Example #17
0
 private vrValue SliderHandler(vrValue iValue)
 {
     if (iValue.IsNumber())
     {
         Debug.Log("Slider value as Number = " + iValue.GetNumber() );
     }
     return null;
 }
Example #18
0
 private void updatePlot()
 {
     if (MiddleVR.VRClusterMgr.IsServer() || (!MiddleVR.VRClusterMgr.IsCluster()))
     {
         vrValue iVal = vrValue.CreateList();
         iVal.AddListItem(WebApiCall.CallWeb(URL));
         m_cmdUpdatePlot.Do(iVal);
     }
 }
Example #19
0
    private vrValue ButtonHandler(vrValue iValue)
    {
        m_Progress += 1;

        GetComponent<VRWebView>().webView.ExecuteJavascript(
            "$('#progressbar').progressbar('value'," + m_Progress.ToString() + ");");

        return null;
    }
Example #20
0
    private vrValue CommandHandler(vrValue iValue)
    {
        print("HTML Button was clicked");

        // Uncomment the following lines to have modify the HTML page in response !
        //vrWebView webView = GetComponent<VRWebView>().webView;
        //webView.ExecuteJavascript("AddResult('Button was clicked !')");

        return null;
    }
Example #21
0
    private vrValue CommandHandler(vrValue iValue)
    {
        print("HTML Button was clicked");

        // Uncomment the following lines to have modify the HTML page in response !
        //vrWebView webView = GetComponent<VRWebView>().webView;
        //webView.ExecuteJavascript("AddResult('Button was clicked !')");

        return(null);
    }
Example #22
0
    private vrValue _QuitApplicationCommandHandler(vrValue iValue)
    {
        MVRTools.Log(3, "[ ] Received QuitApplicationCommand");

        MVRTools.Log("[ ] Unity says we're quitting.");
        MiddleVR.VRKernel.SetQuitting();
        Application.Quit();

        return(null);
    }
 // When called on the server (master) node, an asynchronous call
 // to _CommandHandler is triggered on all nodes at next
 // synchronization (VRManagerScript or VRManagerPostFrame)
 public void Call(vrValue val)
 {
     if (m_Command != null)
     {
         // On a single machine, this will immediately call _CommandHandler
         // On a cluster server, this will schedule a call to _CommandHandler
         //   on all cluster nodes at the next synchronization point
         // On a cluster client, this does nothing
         m_Command.Do(val);
     }
 }
Example #24
0
 // When called on the server (master) node, an asynchronous call
 // to _CommandHandler is triggered on all nodes at next
 // synchronization (VRManagerScript or VRManagerPostFrame)
 public void Call(vrValue val)
 {
     if (m_Command != null)
     {
         // On a single machine, this will immediately call _CommandHandler
         // On a cluster server, this will schedule a call to _CommandHandler
         //   on all cluster nodes at the next synchronization point
         // On a cluster client, this does nothing
         m_Command.Do(val);
     }
 }
    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 #26
0
    private vrValue RTCConnectionReadyCommandHandler(vrValue iValue)
    {
        if (isServer)
        {
            m_VRRTCWebView.ExecuteJavascript("OpenRoom('MVRAudioChat', '" + m_RTCServerURL + "');");
        }
        else
        {
            m_VRRTCWebView.ExecuteJavascript("JoinRoom('MVRAudioChat', '" + m_RTCServerURL + "');");
        }

        return(null);
    }
    private void ButtonHandler(vrValue iValue)
    {
        m_Progress += 1;

        var vrWebViewScript = gameObject.GetComponent <VRWebView>();

        if (vrWebViewScript != null)
        {
            Debug.Log("Progressbar incremented!");
            var webView = vrWebViewScript.webView;
            webView.ExecuteJavascript(
                "$('#progressbar').progressbar('value'," + m_Progress.ToString() + ");");
        }
    }
Example #28
0
 private vrValue StartParticlesCommandHandler(vrValue iValue)
 {
     // We get all the randomSeed / playOnAwake of the master's particle systems
     // to sync the slaves.
     ParticleSystem[] particles = GameObject.FindObjectsOfType(typeof(ParticleSystem)) as ParticleSystem[];
     for (uint i = 0, iEnd = iValue.GetListItemsNb(), particlesCnt = (uint)particles.GetLength(0); i < iEnd && i < particlesCnt; ++i)
     {
         particles[i].randomSeed = (uint)iValue.GetListItem(i).GetListItem(0).GetInt();
         if (iValue.GetListItem(i).GetListItem(1).GetBool())
         {
             particles[i].Play();
         }
     }
     return(null);
 }
Example #29
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 #30
0
    // Use this for initialization
    void Start()
    {
        m_cmdLoadFirstData = new vrCommand("RainPlotCmdLoadFirstData", cmdLoadFirstData);
        m_cmdAutoPopulate  = new vrCommand("RainPlotCmdAutoPopulate", cmdAutoPopulate);
        m_cmdUpdatePlot    = new vrCommand("RainPlotCmdUpdate", cmdUpdatePlot);

        listData     = new List <Dictionary <string, object> >();
        listRealTime = new List <Dictionary <string, object> >();
        if (MiddleVR.VRClusterMgr.IsServer() || (!MiddleVR.VRClusterMgr.IsCluster()))
        {
            vrValue iVal;
            iVal = new vrValue(WebApiCall.CallWeb(URL));
            m_cmdLoadFirstData.Do(iVal);
        }
        autoPopulate();
        InvokeRepeating("updatePlot", UpdateRate, UpdateRate);
    }
Example #31
0
    // On clients, handle the command call
    private vrValue _CommandHandler(vrValue iValue)
    {
        if (m_ClusterMgr.IsClient())
        {
            // extract position and orientation from the vrValue
            vrVec3 pos = iValue[0].GetVec3();
            vrQuat orient = iValue[1].GetQuat();

            Vector3 p = new Vector3( pos.x(), pos.y(), pos.z() );
            Quaternion q = new Quaternion( orient.x(), orient.y(), orient.z(), orient.w() );

            transform.position = p;
            transform.rotation = q;
        }

        return null;
    }
Example #32
0
    // On clients, handle the command call
    private vrValue _CommandHandler(vrValue iValue)
    {
        if (m_ClusterMgr.IsClient())
        {
            // extract position and orientation from the vrValue
            vrVec3 pos    = iValue[0].GetVec3();
            vrQuat orient = iValue[1].GetQuat();

            Vector3    p = new Vector3(pos.x(), pos.y(), pos.z());
            Quaternion q = new Quaternion(orient.x(), orient.y(), orient.z(), orient.w());

            transform.position = p;
            transform.rotation = q;
        }

        return(null);
    }
Example #33
0
    private vrValue NavigationJoystickHandler(vrValue iValue)
    {
        // Activate Joystick Navigation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Navigation Joystick activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Navigation Joystick deactivated.");
        }

        return null;
    }
Example #34
0
    private vrValue ManipulationHomerHandler(vrValue iValue)
    {
        // Activate Homer Manipulation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Manipulation Homer activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Manipulation Homer deactivated.");
        }

        return null;
    }
Example #35
0
    private vrValue NavigationGrabWorldHandler(vrValue iValue)
    {
        // Activate Grab World Navigation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Navigation Grab World activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Navigation Grab World deactivated.");
        }

        return null;
    }
Example #36
0
    private vrValue VirtualHandGogoButtonHandler(vrValue iValue)
    {
        // Activate Gogo Virtual Hand
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Virtual Hand Gogo activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Virtual Hand Gogo deactivated.");
        }

        return null;
    }
Example #37
0
    private vrValue cmdAutoPopulate(vrValue iVal)
    {
        int    layerNum    = iVal[0].GetInt();
        string strResponse = iVal[1].GetString();
        List <Dictionary <string, object> > listTempData = plot.GetPastData(strResponse);

        if (listTempData.Count != 0)
        {
            strLastUpdateDt = (string)listTempData.Last()[TaxiPlot.Headers.Timestamp];

            for (int i = 0; i < listTempData.Count; i += FILTER_RATE)
            {
                plotPt(listTempData[i], PointHolder, layerNum, true);
                listData.Insert(0, listTempData[i]);
            }
            listTempData.Clear();
        }
        return(null);
    }
Example #38
0
 private vrValue ListHandler(vrValue iValue)
 {
     print( "List Selected Index : " + iValue.GetInt() );
     return null;
 }
Example #39
0
 private vrValue ButtonHandler(vrValue iValue)
 {
     m_Checkbox.SetChecked( ! m_Checkbox.IsChecked() );
     print("ButtonHandler() called");
     return null;
 }
Example #40
0
 private vrValue CheckboxHandler(vrValue iValue)
 {
     print("Checkbox value : " + iValue.GetBool().ToString());
     return null;
 }
Example #41
0
 private vrValue ProxiWarningCheckboxHandler(vrValue iValue)
 {
     m_VRManager.ShowScreenProximityWarnings = iValue.GetBool();
     MVRTools.Log("[ ] Show proximity warnings: " + iValue.GetBool().ToString());
     return null;
 }
Example #42
0
    private vrValue _QuitApplicationCommandHandler(vrValue iValue)
    {
        MVRTools.Log(3, "[ ] Received QuitApplicationCommand");

        MVRTools.Log("[ ] Unity says we're quitting.");
        MiddleVR.VRKernel.SetQuitting();
        Application.Quit();

        return null;
    }
Example #43
0
    private vrValue NavigationGrabWorldHandler(vrValue iValue)
    {
        // Activate Grab World Navigation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Navigation Grab World activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Navigation Grab World deactivated.");
        }

        return null;
    }
Example #44
0
 private vrValue SliderHandler(vrValue iValue)
 {
     print("Slider value : " + iValue.GetFloat().ToString());
     return null;
 }
Example #45
0
    private vrValue VirtualHandGogoButtonHandler(vrValue iValue)
    {
        // Activate Gogo Virtual Hand
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Virtual Hand Gogo activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Virtual Hand Gogo deactivated.");
        }

        return null;
    }
Example #46
0
 private vrValue ReturnObjectsCheckboxHandler(vrValue iValue)
 {
     m_VRManager.ManipulationReturnObjects = iValue.GetBool();
     MVRTools.Log("[ ] Manipulation return objects: " + iValue.GetBool().ToString());
     return null;
 }
Example #47
0
 private vrValue ResetZeroButtonHandler(vrValue iValue)
 {
     MVRTools.Log("[ ] Reload level zero.");
     Application.LoadLevel(0);
     return null;
 }
Example #48
0
 // General
 private vrValue ResetCurrentButtonHandler(vrValue iValue)
 {
     MVRTools.Log("[ ] Reload current level.");
     Application.LoadLevel(Application.loadedLevel);
     return null;
 }
Example #49
0
 private vrValue StartParticlesCommandHandler(vrValue iValue)
 {
     // We get all the randomSeed / playOnAwake of the master's particle systems
     // to sync the slaves.
     ParticleSystem[] particles = GameObject.FindObjectsOfType(typeof(ParticleSystem)) as ParticleSystem[];
     for (uint i = 0, iEnd = iValue.GetListItemsNb(), particlesCnt = (uint)particles.GetLength(0); i < iEnd && i < particlesCnt; ++i)
     {
         particles[i].randomSeed = (uint)iValue.GetListItem(i).GetListItem(0).GetInt();
         if (iValue.GetListItem(i).GetListItem(1).GetBool())
         {
             particles[i].Play();
         }
     }
     return null;
 }
    protected void Update()
    {
        var deviceMgr = MiddleVR.VRDeviceMgr;

        if (deviceMgr != null &&
            deviceMgr.IsKeyPressed(MiddleVR.VRK_H) &&
            deviceMgr.IsKeyToggled(MiddleVR.VRK_C))
        {
            var physicsMgr = MiddleVR.VRPhysicsMgr;

            if (physicsMgr == null)
            {
                MiddleVRTools.Log(0, "[X] VRChangeAttachedPhysicsBodyIPSISample: No PhysicsManager found.");
                enabled = false;
                return;
            }

            vrPhysicsEngine physicsEngine = physicsMgr.GetPhysicsEngine();

            if (physicsEngine == null)
            {
                return;
            }

            if (!physicsEngine.IsStarted())
            {
                // We have to wait...
                return;
            }

            uint bodiesNb = physicsEngine.GetBodiesNb();

            if (bodiesNb == 0)
            {
                MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: No physics body found!");
                return;
            }

            vrPhysicsBody physicsBody = physicsEngine.GetBody(m_PhysicsBodyId);

            MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: proposed body id: " +
                m_PhysicsBodyId + " ('" + (physicsBody != null ? physicsBody.GetName() : "Null") + "').");

            if (physicsBody != null && physicsBody.IsA("PhysicsBodyIPSI"))
            {
                var objId = physicsBody.GetId();

                // As a reminder: static or frozen physics bodies cannot be manipulated.
                MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Is the physics body '" +
                    objId + "' static? " + (physicsBody.IsStatic() ? "Yes" : "No") + ".");
                MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Is the physics body '" +
                    objId + "' frozen? " + (physicsBody.IsFrozen() ? "Yes" : "No") + ".");

                var kernel = MiddleVR.VRKernel;


                // Use of "Haption.IPSI.GetManipulationDevicesNb".
                // Param with one vrValue:
                //  + None, so vrValue.NULL_VALUE can be used.
                // Return:
                //  A vrValue that contains a uint.
                //  In case of problem, the vrValue is invalid.

                var getManipDeviceNbRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.GetManipulationDevicesNb",
                    vrValue.NULL_VALUE);

                if (getManipDeviceNbRetValue.IsNumber())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: " +
                        getManipDeviceNbRetValue.GetUInt() + " Haption device(s) are connected.");
                }
                else
                {
                    MiddleVRTools.Log(0,
                        "[X] VRChangeAttachedPhysicsBodyIPSISample: Failed to detect how many Haption devices are connected.");
                }


                // Use of "Haption.IPSI.GetManipulationDeviceName".
                // Param with one vrValue:
                //  + the id of an Haption device (as uint).
                // Return:
                //  A vrValue that contains a string (the name).
                //  In case of problem, the vrValue is invalid.

                var getManipDeviceNamePrmsValue = new vrValue(m_ManipulationDeviceId);

                var getManipDeviceNameRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.GetManipulationDeviceName",
                    getManipDeviceNamePrmsValue);

                if (getManipDeviceNameRetValue.IsString())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: The name of the Haption device '" +
                        m_ManipulationDeviceId + "' is '" + getManipDeviceNameRetValue.GetString() + "'.");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to the find the name of the Haption device '" +
                        m_ManipulationDeviceId + "'.");
                }


                // Use of "Haption.IPSI.AttachManipulationDeviceToBody".
                // Params with one vrValue:
                //  + 1st arg: the id of an Haption device (as uint)
                //  + 2st arg: the id of a physics body (returned by GetId() on this object).
                // Return:
                //  A vrValue that contains a boolean: True if successfully attached, False otherwise.
                //  In case of problem, the vrValue is invalid.
                //
                // If the attachment failed, the previous attached physics body
                // will remain attached, otherwise it will be detached.

                var attachManipDeviceToBodyPrmsValue = vrValue.CreateList();
                attachManipDeviceToBodyPrmsValue.AddListItem(m_ManipulationDeviceId);
                attachManipDeviceToBodyPrmsValue.AddListItem(objId);

                // The previous manipulated physics body (if any), will be
                // automatically detached.
                var attachManipDeviceToBodyRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.AttachManipulationDeviceToBody",
                    attachManipDeviceToBodyPrmsValue);

                if (attachManipDeviceToBodyRetValue.IsBool())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Did attachment of the Haption device '" +
                        m_ManipulationDeviceId + "' to the physics body '" + objId + "' succeeded? " +
                        (attachManipDeviceToBodyRetValue.GetBool() == true ? "Yes" : "No") + ".");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to attach the Haption device '" +
                        m_ManipulationDeviceId + "' to the physics body '" + objId + "'.");
                }

                // Use of "Haption.IPSI.IsManipulationDeviceAttachedToABody".
                // Params with one vrValue:
                //  + the id of an Haption device (as uint).
                // Return:
                //  A vrValue that contains a boolean: True means that the device is attached to a body, False otherwise.
                //  In case of problem, the vrValue is invalid.

                var isManipDeviceAttachedToABodyPrmsValue = new vrValue(m_ManipulationDeviceId);

                var isManipDeviceAttachedToABodyRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.IsManipulationDeviceAttachedToABody",
                    isManipDeviceAttachedToABodyPrmsValue);

                if (isManipDeviceAttachedToABodyRetValue.IsBool())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Is the Haption device '" +
                        m_ManipulationDeviceId + "' attached to a physics body? " +
                        (isManipDeviceAttachedToABodyRetValue.GetBool() == true ? "Yes" : "No") + ".");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to check whether the Haption device '" +
                        m_ManipulationDeviceId + "' is attached to a physics body.");
                }


                // Use of "Haption.IPSI.IsBodyAttachedToAManipulationDevice".
                // Params with one vrValue:
                //  + the id of a physics body (returned by GetId() on this object).
                // Return:
                //  A vrValue that contains a boolean: True means that the body is attached to a manipulation device, False otherwise.
                //  In case of problem, the vrValue is invalid.

                var isBodyAttachedToAManipDevicePrmsValue = new vrValue(objId);

                var isBodyAttachedToAManipDeviceRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.IsBodyAttachedToAManipulationDevice",
                    isBodyAttachedToAManipDevicePrmsValue);

                if (isBodyAttachedToAManipDeviceRetValue.IsBool())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Is the physics body '" +
                        objId + "' attached to a Haption device? " +
                        (isBodyAttachedToAManipDeviceRetValue.GetBool() == true ? "Yes" : "No") + ".");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to check whether the physics body " +
                        objId + " is attached to a Haption device.");
                }


                // Use of "Haption.IPSI.GetIdOfManipulationDeviceAttachedToBody".
                // Params with one vrValue:
                //  + the id of a physics body (returned by GetId() on this object).
                // Return:
                //  A vrValue that contains the id (a uint) of the attached manipulation device.
                //  In case of problem or if the physics body was not attached, the vrValue is invalid.

                var getIdOfManipDeviceAttachedToBodyPrmsValue = new vrValue(objId);

                var getIdOfManipDeviceAttachedToBodyRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.GetIdOfManipulationDeviceAttachedToBody",
                    getIdOfManipDeviceAttachedToBodyPrmsValue);

                if (getIdOfManipDeviceAttachedToBodyRetValue.IsNumber())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: The physics body '" +
                        objId + "' is attached to the Haption device '" +
                        getIdOfManipDeviceAttachedToBodyRetValue.GetNumber() + "'.");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: The physics body '" +
                        objId + "' does not seem to be attached to a Haption device.");
                }


                // Use of "Haption.IPSI.GetIdOfBodyAttachedToManipulationDevice".
                // Params with one vrValue:
                //  + the id of an Haption device (as uint).
                // Return:
                //  A vrValue that contains the id (returned by vrObject.GetId()) of the attached physics body.
                //  In case of problem or if the device was not attached, the vrValue is invalid.

                var getIdOfBodyAttachedToManipDevicePrmsValue = new vrValue(m_ManipulationDeviceId);

                var getIdOfBodyAttachedToManipDeviceRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.GetIdOfBodyAttachedToManipulationDevice",
                    getIdOfBodyAttachedToManipDevicePrmsValue);

                if (getIdOfBodyAttachedToManipDeviceRetValue.IsNumber())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: The Haption device '" +
                        m_ManipulationDeviceId + "' is attached to the physics body '" +
                        getIdOfBodyAttachedToManipDeviceRetValue.GetNumber() + "'.");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: The Haption device '" +
                        m_ManipulationDeviceId + "' does not seem to be attached to a physics body.");
                }


                // Use of "Haption.IPSI.DetachManipulationDevice".
                // Params with one vrValue:
                //  + the id of an Haption device (as uint).
                // Return:
                //  A vrValue that contains a boolean: True if successfully detached, False otherwise.
                //  In case of problem, the vrValue is invalid.

                // Please uncomment the code following to try...
                /*
                var detachManipDevicePrmsValue = new vrValue(m_ManipulationDeviceId);

                var detachManipDeviceRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.DetachManipulationDevice",
                    detachManipDevicePrmsValue);

                if (detachManipDeviceRetValue.IsBool())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Did detachment of the Haption device '" +
                        m_ManipulationDeviceId + "' succeeded? " +
                        (detachManipDeviceRetValue.GetBool() == true ? "Yes" : "No") + ".");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to detach the Haption device '" +
                        m_ManipulationDeviceId + "'.");
                }
                */


                // Use of "Haption.IPSI.DetachBodyFromAManipulationDevice".
                // Params with one vrValue:
                //  + the id of a physics body (returned by GetId() on this object).
                // Return:
                //  A vrValue that contains a boolean: True if successfully detached, False otherwise.
                //  In case of problem, the vrValue is invalid.

                // Please uncomment the code following to try...
                /*
                var detachBodyFromAManipDevicePrmsValue = new vrValue(objId);

                var detachBodyFromAManipDeviceRetValue = kernel.ExecuteCommand(
                    "Haption.IPSI.DetachBodyFromAManipulationDevice",
                    detachBodyFromAManipDevicePrmsValue);

                if (detachBodyFromAManipDeviceRetValue.IsBool())
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Did detachment of the physics body '" +
                        objId + "' succeeded? " +
                        (detachBodyFromAManipDeviceRetValue.GetBool() == true ? "Yes" : "No") + ".");
                }
                else
                {
                    MiddleVRTools.Log(0, "[+] VRChangeAttachedPhysicsBodyIPSISample: Failed to detach the physics body '" +
                        objId + "'.");
                }
                */
            }

            m_PhysicsBodyId = (m_PhysicsBodyId + 1) % (bodiesNb);
        }
    }
 vrValue MyItemCommandHandler(vrValue iValue)
 {
     print("My menu item has been clicked");
     return null;
 }
Example #52
0
    private vrValue ManipulationRayHandler(vrValue iValue)
    {
        // Activate Ray Manipulation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Manipulation Ray activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Manipulation Ray deactivated.");
        }

        return null;
    }
Example #53
0
 private vrValue FlyCheckboxHandler(vrValue iValue)
 {
     m_VRManager.Fly = iValue.GetBool();
     MVRTools.Log("[ ] Fly mode: " + iValue.GetBool().ToString());
     return null;
 }
Example #54
0
 private vrValue ExitButtonHandler(vrValue iValue)
 {
     MVRTools.Log("[ ] Exit simulation.");
     m_VRManager.QuitApplication();
     return null;
 }
Example #55
0
 private vrValue ColorPickerHandler(vrValue iValue)
 {
     vrVec4 color = iValue.GetVec4();
     print("Selected color : " + color.x().ToString() + " " + color.y().ToString() + " " + color.z().ToString());
     return null;
 }
Example #56
0
    private vrValue NavigationJoystickHandler(vrValue iValue)
    {
        // Activate Joystick Navigation
        vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick");

        bool activate = iValue.GetBool();
        if (activate)
        {
            MiddleVR.VRInteractionMgr.Activate(interaction);
            MVRTools.Log("[ ] Navigation Joystick activated.");
        }
        else
        {
            MiddleVR.VRInteractionMgr.Deactivate(interaction);
            MVRTools.Log("[ ] Navigation Joystick deactivated.");
        }

        return null;
    }
Example #57
0
 private vrValue RadioHandler(vrValue iValue)
 {
     print("Radio value : " + iValue.GetString());
     return null;
 }
 // This method is called on all nodes immediately after
 // the same synchronization point
 private vrValue _CommandHandler(vrValue iValue)
 {
     // Do stuff here
     return null; // Return null/undefined vrValue
 }
Example #59
0
 private vrValue FramerateCheckboxHandler(vrValue iValue)
 {
     m_VRManager.ShowFPS = iValue.GetBool();
     MVRTools.Log("[ ] Show Frame Rate: " + iValue.GetBool().ToString());
     return null;
 }
Example #60
0
 private vrValue CollisionsCheckboxHandler(vrValue iValue)
 {
     m_VRManager.NavigationCollisions = iValue.GetBool();
     MVRTools.Log("[ ] Navigation Collisions: " + iValue.GetBool().ToString());
     return null;
 }