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 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;
    }