private void CreateWarningRepresentation( vrNode3D iNode, vrScreen iScreen )
    {
        // Generate name and check if warning doesn't exist
        string warningName = iNode.GetName() + "_" + iScreen.GetName() + "_ProxiWarning";
        if( m_WarningRepresentationObjects.ContainsKey(warningName) )
        {
            return;
        }

        // Retrieve the GameObjects
        GameObject nodeGameObject   = GameObject.Find(iNode.GetName());
        GameObject screenGameObject = GameObject.Find(iScreen.GetName());

        // Create and initialize the warning
        GameObject warningRepresentation = GameObject.Instantiate(WarningRepresentationPrefab) as GameObject;
        warningRepresentation.name                    = warningName;
        warningRepresentation.transform.parent        = screenGameObject.transform;
        warningRepresentation.transform.localPosition = Vector3.zero;
        warningRepresentation.transform.localRotation = Quaternion.identity;
        warningRepresentation.transform.localScale    = new Vector3(iScreen.GetWidth(), iScreen.GetHeight(), 1.0f);

        GameObject warningMesh = warningRepresentation.transform.GetChild(0).gameObject;
        Material mat = Material.Instantiate(warningMesh.GetComponent<Renderer>().material) as Material;
        warningMesh.GetComponent<Renderer>().material = mat;
        warningMesh.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(m_TextureScale * 0.8f * iScreen.GetWidth(), m_TextureScale * iScreen.GetHeight()));

        VRScreenWarningAnimation warningScript = warningMesh.GetComponent<VRScreenWarningAnimation>();
        warningScript.SetNodeToWatch(nodeGameObject);
        warningScript.SetNearDistance(WarningDistance);

        // Add the warning to list
        m_WarningRepresentationObjects[warningRepresentation.name] = warningRepresentation;
    }
Beispiel #2
0
    private void makeNewScreens()
    {
        var displayMgr = MiddleVR.VRDisplayMgr;

        // For each vrCameraStereo, make a new screen for the right eye
        for (uint i = 0, iEnd = displayMgr.GetCamerasNb(); i < iEnd; ++i)
        {
            vrCamera cam = displayMgr.GetCameraByIndex(i);
            if (cam.IsA("CameraStereo"))
            {
                vrCameraStereo stereoCam = displayMgr.GetCameraStereoById(cam.GetId());

                vrScreen leftScreen  = stereoCam.GetCameraLeft().GetScreen();
                vrScreen rightScreen = displayMgr.CreateScreen(leftScreen.GetName() + "right");
                leftScreen.SetName(leftScreen.GetName() + "left");

                rightScreen.SetParent(leftScreen.GetParent());
                rightScreen.SetHeight(leftScreen.GetHeight());
                rightScreen.SetWidth(leftScreen.GetWidth());
                rightScreen.SetFiltered(leftScreen.IsFiltered());
                rightScreen.SetTracker(leftScreen.GetTracker());
                rightScreen.SetPositionWorld(leftScreen.GetPositionWorld());
                rightScreen.SetOrientationWorld(leftScreen.GetOrientationWorld());

                stereoCam.GetCameraRight().SetScreen(rightScreen);
            }
        }
    }
    private void HideOldWarnings()
    {
        uint oldContactsNB = m_it.GetRemovedContactsNb();

        for (uint i = 0; i < oldContactsNB; ++i)
        {
            vrNode3D contactNode   = m_it.GetRemovedContactNode(i);
            vrScreen contactScreen = m_it.GetRemovedContactScreen(i);

            // Hide corresponding warning representation
            DeleteWarningRepresentation(contactNode, contactScreen);
        }
    }
    private void ShowNewWarnings()
    {
        uint newContactsNB = m_it.GetAddedContactsNb();

        for (uint i = 0; i < newContactsNB; ++i)
        {
            vrNode3D contactNode   = m_it.GetAddedContactNode(i);
            vrScreen contactScreen = m_it.GetAddedContactScreen(i);

            // Show corresponding warning representation
            CreateWarningRepresentation(contactNode, contactScreen);
        }
    }
    private void DeleteWarningRepresentation(vrNode3D iNode, vrScreen iScreen)
    {
        // Generate name and check if warning exists
        string warningName = iNode.GetName() + "_" + iScreen.GetName() + "_ProxiWarning";

        if (!m_WarningRepresentationObjects.ContainsKey(warningName))
        {
            return;
        }

        // Remove from list
        m_WarningRepresentationObjects.Remove(warningName);

        // Destroy warning object
        GameObject warningObject = GameObject.Find(warningName);

        warningObject.SetActive(false);
        GameObject.Destroy(warningObject);
    }
Beispiel #6
0
    void TestDisplay()
    {
        // 3D nodes
        vrNode3D       node   = null;
        vrCamera       camera = null;
        vrCameraStereo scam   = null;
        vrScreen       screen = null;
        vrViewport     vp     = null;

        if (MiddleVR.VRDisplayMgr != null)
        {
            node = MiddleVR.VRDisplayMgr.GetNode("HeadNode");
            if (node != null)
            {
                MiddleVRTools.Log("Found HeadNode");
            }

            camera = MiddleVR.VRDisplayMgr.GetCamera("Camera0");
            if (camera != null)
            {
                MiddleVRTools.Log("Found Camera0");
            }

            scam = MiddleVR.VRDisplayMgr.GetCameraStereo("CameraStereo0");
            if (scam != null)
            {
                MiddleVRTools.Log("Found CameraStereo0");
            }

            screen = MiddleVR.VRDisplayMgr.GetScreen("Screen0");
            if (screen != null)
            {
                MiddleVRTools.Log("Found Screen0");
            }

            vp = MiddleVR.VRDisplayMgr.GetViewport("Viewport0");
            if (vp != null)
            {
                MiddleVRTools.Log("Found Viewport0");
            }
        }
    }
    private void CreateWarningRepresentation(vrNode3D iNode, vrScreen iScreen)
    {
        // Generate name and check if warning doesn't exist
        string warningName = iNode.GetName() + "_" + iScreen.GetName() + "_ProxiWarning";

        if (m_WarningRepresentationObjects.ContainsKey(warningName))
        {
            return;
        }

        // Retrieve the GameObjects
        GameObject nodeGameObject   = GameObject.Find(iNode.GetName());
        GameObject screenGameObject = GameObject.Find(iScreen.GetName());

        // Create and initialize the warning
        GameObject warningRepresentation = GameObject.Instantiate(WarningRepresentationPrefab) as GameObject;

        warningRepresentation.name                    = warningName;
        warningRepresentation.transform.parent        = screenGameObject.transform;
        warningRepresentation.transform.localPosition = Vector3.zero;
        warningRepresentation.transform.localRotation = Quaternion.identity;
        warningRepresentation.transform.localScale    = new Vector3(iScreen.GetWidth(), iScreen.GetHeight(), 1.0f);

        GameObject warningMesh = warningRepresentation.transform.GetChild(0).gameObject;
        Material   mat         = Material.Instantiate(warningMesh.GetComponent <Renderer>().material) as Material;

        warningMesh.GetComponent <Renderer>().material = mat;
        warningMesh.GetComponent <Renderer>().material.SetTextureScale("_MainTex", new Vector2(m_TextureScale * 0.8f * iScreen.GetWidth(), m_TextureScale * iScreen.GetHeight()));

        VRScreenWarningAnimation warningScript = warningMesh.GetComponent <VRScreenWarningAnimation>();

        warningScript.SetNodeToWatch(nodeGameObject);
        warningScript.SetNearDistance(WarningDistance);

        // Add the warning to list
        m_WarningRepresentationObjects[warningRepresentation.name] = warningRepresentation;
    }
Beispiel #8
0
    private void TestDisplay()
    {
        var displayMgr = MiddleVR.VRDisplayMgr;

        if (displayMgr != null)
        {
            vrNode3D node = displayMgr.GetNode("HeadNode");
            if (node != null)
            {
                MVRTools.Log("Found HeadNode");
            }

            vrCamera cam = displayMgr.GetCamera("Camera0");
            if (cam != null)
            {
                MVRTools.Log("Found Camera0");
            }

            vrCameraStereo sCam = displayMgr.GetCameraStereo("CameraStereo0");
            if (sCam != null)
            {
                MVRTools.Log("Found CameraStereo0");
            }

            vrScreen screen = displayMgr.GetScreen("Screen0");
            if (screen != null)
            {
                MVRTools.Log("Found Screen0");
            }

            vrViewport vp = displayMgr.GetViewport("Viewport0");
            if (vp != null)
            {
                MVRTools.Log("Found Viewport0");
            }
        }
    }
    private void DeleteWarningRepresentation(vrNode3D iNode, vrScreen iScreen)
    {
        // Generate name and check if warning exists
        string warningName = iNode.GetName() + "_" + iScreen.GetName() + "_ProxiWarning";
        if (!m_WarningRepresentationObjects.ContainsKey(warningName))
        {
            return;
        }

        // Remove from list
        m_WarningRepresentationObjects.Remove(warningName);

        // Destroy warning object
        GameObject warningObject = GameObject.Find(warningName);
        warningObject.SetActive(false);
        GameObject.Destroy(warningObject);
    }