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;
    }
    protected void Initialize()
    {
        GameObject vrSystemCenterNode = null;

        if (GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode != null)
        {
            vrSystemCenterNode = GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode;
        }
        else
        {
            vrNode3D vrSystemMVRNode = MiddleVR.VRDisplayMgr.GetNodeByTag(MiddleVR.VR_SYSTEM_CENTER_NODE_TAG);
            if (vrSystemMVRNode != null)
            {
                vrSystemCenterNode = GameObject.Find(vrSystemMVRNode.GetName());
            }
        }

        if (vrSystemCenterNode == null)
        {
            return;
        }

        // If our navigation node has a parent, we want to move relatively to this vehicule
        if (vrSystemCenterNode.transform.parent != null)
        {
            m_NavRefNode = vrSystemCenterNode.transform.parent.gameObject;
            if (m_NavRefNode != null)
            {
                VRNode3DSynchronization nodeSyncComponent = m_NavRefNode.AddComponent <VRNode3DSynchronization>();
                m_it.SetNavigationReferentialNode(nodeSyncComponent.Node);
            }
        }

        m_Initialized = true;
    }
Example #3
0
    protected virtual void _SetSyncDirection(MVRNodesMapper.ENodesSyncDirection iSyncDirection)
    {
        m_SyncDirIsSet  = true;
        m_SyncDirection = iSyncDirection;

        var nodesMapper = MVRNodesMapper.Instance;

        if (iSyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
        {
            // Set new MiddleVR - Unity nodes mapping if needed
            m_MiddleVRNode = nodesMapper.AddMapping(this.gameObject, MiddleVRNodeName, iSyncDirection);
        }
        else if (m_MiddleVRNode != null)
        {
            // No synchronization and existing mvrNode: stop node synchronization
            nodesMapper.RemoveMapping(m_MiddleVRNode.GetName());

            m_MiddleVRNode = null;
        }
    }
    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;
    }
    void Update()
    {
        if (IsActive())
        {
            if (!m_Initialized)
            {
                if (GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode != null)
                {
                    m_VRSystemCenterNode = GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode.transform;
                }
                else
                {
                    vrNode3D vrSystemMVRNode = MiddleVR.VRDisplayMgr.GetNodeByTag(MiddleVR.VR_SYSTEM_CENTER_NODE_TAG);
                    if (vrSystemMVRNode != null)
                    {
                        m_VRSystemCenterNode = GameObject.Find(vrSystemMVRNode.GetName()).transform;
                    }
                }

                m_Initialized = true;
            }

            if (ElasticRepresentationPrefab == null)
            {
                MVRTools.Log("[X] VRInteractionNavigationElastic error: bad elastic prefab reference");
                return;
            }

            if (m_it.HasNavigationStarted())
            {
                m_ElasticRepresentationObject = (GameObject)GameObject.Instantiate(ElasticRepresentationPrefab);
                m_ElasticRepresentationObject.transform.parent = m_VRSystemCenterNode;
                m_ElasticRepresentation = m_ElasticRepresentationObject.GetComponent <VRElasticRepresentation>();
                UpdateElasticRepresentation();
            }
            else if (m_it.IsNavigationRunning())
            {
                UpdateElasticRepresentation();
            }
            else if (m_it.IsNavigationStopped() && m_ElasticRepresentation != null)
            {
                GameObject.Destroy(m_ElasticRepresentationObject);
            }
        }
    }
    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);
    }
Example #7
0
    public vrNode3D InitNode()
    {
        // Check for grabbed nodes
        MVRNodesMapper nodesMapper = MVRNodesMapper.Instance;

        if (nodesMapper != null)
        {
            vrNode3D node = nodesMapper.GetNode(gameObject);
            if (node != null)
            {
                m_Node          = node;
                m_NodeName      = m_Node.GetName();
                m_SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
                m_IsNodeGrabbed = true;
                return(m_Node);
            }
        }

        return(CreateNode(m_NodeName, MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity));
    }
    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);
    }
Example #9
0
    private void _SetNode(vrNode3D iNode3D, MVRNodesMapper.ENodesSyncDirection iInitialSyncDirection, MVRNodesMapper.ENodesSyncDirection iSyncDirection)
    {
        // Check if iNode3D and m_Node3D are the same
        if (m_Node == iNode3D || (m_Node != null && iNode3D != null && m_Node.GetId() == iNode3D.GetId()))
        {
            // Same node, return.
            return;
        }

        MVRNodesMapper nodesMapper = MVRNodesMapper.Instance;

        // Cleanup old node
        if (m_Node != null && !m_IsNodeGrabbed)
        {
            if (m_EventListener != null)
            {
                m_Node.RemoveEventListener(m_EventListener);
            }

            if (m_SyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
            {
                nodesMapper.RemoveMapping(gameObject, true);
            }
        }

        m_IsNodeGrabbed = false;
        m_Node          = iNode3D;

        // Setup new node
        if (m_Node != null)
        {
            // First mapping will copy the object's transform
            if (iInitialSyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
            {
                nodesMapper.AddMapping(gameObject, m_Node, iInitialSyncDirection);
            }

            if (iInitialSyncDirection != iSyncDirection)
            {
                if (iInitialSyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
                {
                    nodesMapper.RemoveMapping(gameObject, false);
                }

                if (iSyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
                {
                    nodesMapper.AddMapping(gameObject, m_Node, iSyncDirection);
                }
            }

            m_NodeName      = m_Node.GetName();
            m_SyncDirection = iSyncDirection;

            if (m_EventListener == null)
            {
                m_EventListener = new vrEventListener(_OnNodeEvent);
            }

            m_Node.AddEventListener(m_EventListener);
        }
        else
        {
            m_NodeName = "";
        }
    }
Example #10
0
    private void _SetNode3D(vrNode3D iNode3D, bool iIsNodeOwned)
    {
        // check if iNode3D and m_Node3D are the same
        if (m_Node3D == iNode3D || (m_Node3D != null && iNode3D != null && m_Node3D.GetId() == iNode3D.GetId()))
        {
            return;
        }

        MVRNodesMapper nodesMapper = MVRNodesMapper.Instance;

        if (m_Node3D != null)
        {
            if (m_SyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
            {
                nodesMapper.RemoveMapping(gameObject, m_IsNodeOwned);
            }

            if (m_IsNodeOwned && MiddleVR.VRDisplayMgr != null)
            {
                MiddleVR.VRDisplayMgr.DestroyNode(m_Node3D);
            }
        }

        m_Node3D = iNode3D;
        m_IsNodeOwned = iIsNodeOwned;

        if (m_Node3D != null && m_SyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
        {
            nodesMapper.AddMapping(gameObject, m_Node3D, m_SyncDirection);
        }

        if (m_Node3D != null)
        {
            m_Node3DName = m_Node3D.GetName();
        }
        else
        {
            m_Node3DName = "";
        }
    }