// Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationElastic(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_NavigationNode = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_ReferenceNode != null && m_NavigationNode != null && m_TurnAroundNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);

            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);

            m_it.SetDistanceThreshold(DistanceThreshold);
            m_it.SetAngleThreshold(AngleThreshold);

            m_it.SetUseRotationYaw(UseRotationYaw);

            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic: One or several nodes are missing.");
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionManipulationRay(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);

        if (m_HandNode != null)
        {
            m_it.SetGrabWandButton(WandGrabButton);
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionManipulationRay: One or several nodes are missing.");
        }

        m_Wand = this.GetComponent<VRWand>();
    }
Esempio n. 3
0
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionVirtualHandGogo(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        vrNode3D handNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);
        vrNode3D headNode = MiddleVR.VRDisplayMgr.GetNode(HeadNode);

        if (handNode != null && headNode != null)
        {
            m_it.SetHandNode(handNode);
            m_it.SetHeadNode(headNode);
            m_it.SetGogoStartDistance(GogoStartDistance);
            m_it.SetRealDistanceMax(RealDistanceMax);
            m_it.SetVirtualDistanceMax(VirtualDistanceMax);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionVirtualHandGogo: One or several nodes are missing.");
        }
    }
    private void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_VRMgr = GameObject.Find("VRManager").GetComponent <VRManagerScript>();

        m_it = new vrInteractionManipulationHomer(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);

        if (m_HandNode != null)
        {
            m_it.SetGrabWandButton(WandGrabButton);
            m_it.SetTranslationScale(TranslationScale);
            m_it.SetRotationScale(RotationScale);
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionManipulationHomer: One or several nodes are missing.");
        }

        m_Wand = this.GetComponent <VRWand>();
    }
    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;
    }
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationWandJoystick(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_NavigationNode         = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);
        m_TurnAroundNode         = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_DirectionReferenceNode != null && m_NavigationNode != null && m_TurnAroundNode != null)
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing.");
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationWandJoystick(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if( m_DirectionReferenceNode!= null && m_TurnAroundNode != null )
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog( 2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing." );
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationWandJoystick(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_TurnAroundNode         = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_DirectionReferenceNode != null && m_TurnAroundNode != null)
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing.");
        }
    }
    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;
    }
    private void Grab(GameObject iGrabbedObject)
    {
        if (iGrabbedObject == null)
        {
            return;
        }

        // Initialize manipulated node
        m_CurrentManipulatedObject = iGrabbedObject;
        VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>();

        m_ObjectPreviousSyncDir     = vrActorScript.SyncDirection;
        vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
        vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode();

        m_it.SetManipulatedNode(middleVRNode);

        // Save initial position
        m_ObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition;
        m_ObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation;

        // Deactivate selection during the manipulation
        vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection");

        if (selection != null)
        {
            m_PausedSelection = selection;
            MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection);
        }
    }
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationWandJoystick(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_NavigationNode = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if ( m_DirectionReferenceNode!= null && m_NavigationNode != null && m_TurnAroundNode != null )
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog( 2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing." );
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionManipulationRay(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);

        if (m_HandNode != null)
        {
            m_it.SetGrabWandButton(WandGrabButton);
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionManipulationRay: One or several nodes are missing.");
        }

        m_Wand = this.GetComponent <VRWand>();
    }
Esempio n. 13
0
    private void Grab(GameObject iGrabbedObject)
    {
        if (iGrabbedObject == null)
        {
            return;
        }

        m_CurrentManipulatedObject = iGrabbedObject;

        VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>();

        m_ObjectPreviousSyncDir     = vrActorScript.SyncDirection;
        vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
        vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode();

        m_it.SetManipulatedNode(middleVRNode);
        m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent <Collider>().bounds.center));

        // Save initial position
        m_ObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition;
        m_ObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation;

        // Deactivate selection during the manipulation
        vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection");

        if (selection != null)
        {
            m_PausedSelection = selection;
            MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection);
        }

        // Hide Wand
        m_VRMgr.ShowWandGeometry(false);
    }
    private void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_VRMgr = GameObject.Find("VRManager").GetComponent<VRManagerScript>();

        m_it = new vrInteractionManipulationHomer(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode( HandNode );

        if ( m_HandNode != null )
        {
            m_it.SetGrabWandButton( WandGrabButton );
            m_it.SetTranslationScale( TranslationScale );
            m_it.SetRotationScale( RotationScale );
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog( 2, "[X] VRInteractionManipulationHomer: One or several nodes are missing." );
        }

        m_Wand = this.GetComponent<VRWand>();
    }
 private void rotateScreen(vrNode3D screenParent, Vector3 angles)
 {
     //remove z componant (roll)
     angles.z = 0;
     screenParent.SetOrientationLocal(MVRTools.FromUnity(Quaternion.Euler(angles)));
     //screenParent.SetRollLocal(angles.x);
     //screenParent.SetYawLocal(angles.y);
     //screenParent.SetPitchLocal(angles.z);
 }
Esempio n. 16
0
    public void SetNavigationNode(GameObject iNavigationNode)
    {
        m_NavigationNode   = iNavigationNode;
        m_VRNavigationNode = MiddleVR.VRDisplayMgr.GetNode(iNavigationNode.name);

        if (m_VRNavigationNode == null)
        {
            MiddleVRTools.Log(2, "[X] VRHeadCollision: the navigation node to set doesn't have a corresponding vrNode3D in MiddleVR nodes.");
        }
    }
Esempio n. 17
0
 void Start()
 {
     centerNode = MiddleVR.VRDisplayMgr.GetNode("VRSystemCenterNode");
     //neckNode = MiddleVR.VRDisplayMgr.GetNode("Kinect0.User0.Neak");
     headNode = MiddleVR.VRDisplayMgr.GetNode("Kinect0.User0.Head");
     cameraNode = MiddleVR.VRDisplayMgr.GetNode("Camera0");
     rightHandNode = MiddleVR.VRDisplayMgr.GetNode("Kinect0.User0.Right_Hand_Node");
     //rightHandTracker = MiddleVR.VRDeviceMgr.GetTracker("Kinect0.User0.Right_Hand");
     projectile = GameObject.FindWithTag("Projectile");
 }
Esempio n. 18
0
    public void SetNavigationNode( GameObject iNavigationNode )
    {
        m_NavigationNode   = iNavigationNode;
        m_VRNavigationNode = MiddleVR.VRDisplayMgr.GetNode(iNavigationNode.name);

        if( m_VRNavigationNode == null )
        {
            MiddleVRTools.Log( 2, "[X] VRHeadCollision: the navigation node to set doesn't have a corresponding vrNode3D in MiddleVR nodes." );
        }
    }
Esempio n. 19
0
    // Use this for initialization
    void Start()
    {
        leftScreenOutput  = GameObject.Find("LeftCameraScreens").transform;
        rightScreenOutput = GameObject.Find("RightCameraScreens").transform;

        var displayMgr = MiddleVR.VRDisplayMgr;

        //get the screen nodes
        leftScreenParent  = displayMgr.GetNode("LeftCameraScreens");
        rightScreenParent = displayMgr.GetNode("RightCameraScreens");
    }
Esempio n. 20
0
    protected void Update()
    {
        if (!m_IsMenuUsed)
        {
            return;
        }

        if (m_Initializing)
        {
            // Attach to VRSystemCenterNode
            if (m_SystemCenterNode == null)
            {
                vrNode3D systemCenterNode = MiddleVR.VRDisplayMgr.GetNodeByTag("VRSystemCenter");
                m_SystemCenterNode = MVRNodesMapper.Instance.GetNode(systemCenterNode);
                if (m_SystemCenterNode == null)
                {
                    return;
                }
            }

            transform.parent = m_SystemCenterNode.transform;

            // Retrieve Head
            if (m_HeadNode == null)
            {
                m_HeadNode = GameObject.Find("HeadNode");
                if (m_HeadNode == null)
                {
                    return;
                }
            }

            // Retrieve Wand
            if (m_Wand == null)
            {
                m_Wand = GameObject.Find("VRWand");
                if (m_Wand == null)
                {
                    return;
                }
            }

            m_Initializing = false;
        }

        // Toggle visibility
        if (MiddleVR.VRDeviceMgr.IsWandButtonToggled((uint)HideShowWandButton))
        {
            ToggleVisiblity();
        }

        _VisibilityAnimation();
    }
Esempio n. 21
0
	// Update is called once per frame
	void Update () {
        if (m_Node == null && MiddleVR.VRDisplayMgr != null)
        {
            m_Node = MiddleVR.VRDisplayMgr.GetNode(VRNodeName);
        }

        if (m_Node != null)
        {
            transform.localPosition = MiddleVRTools.ToUnity(m_Node.GetPositionWorld());
            transform.localRotation = MiddleVRTools.ToUnity(m_Node.GetOrientationWorld());
        }
	}
    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 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);
        }
    }
Esempio n. 24
0
    protected void InitializeFromActiveNavigation()
    {
        // Search for navigation interaction parameters
        uint interactionNb = MiddleVR.VRInteractionMgr.GetInteractionsNb();

        if (interactionNb == 0)
        {
            MVRTools.Log(4, "[~] VRHeadCollision: no interaction found in Interaction Manager.");
            return;
        }

        bool     fly        = true;
        vrNode3D navNodeMVR = null;

        for (uint i = 0; i < interactionNb; ++i)
        {
            vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteractionByIndex(i);
            if (interaction.IsActive() && interaction.TagsContain("Navigation"))
            {
                // Get fly mode
                vrProperty flyProp = interaction.GetProperty("Fly");
                if (flyProp != null)
                {
                    fly = flyProp.GetBool();
                }

                // Get navigation node
                vrProperty navNodeProp = interaction.GetProperty("NavigationNode");
                if (navNodeProp != null)
                {
                    navNodeMVR = MiddleVR.VRDisplayMgr.GetNode(navNodeProp.GetObject().GetName());
                }

                break;
            }
        }

        if (navNodeMVR == null)
        {
            MVRTools.Log(2, "[X] VRNavigationCollision: impossible to retrieve navigation node.");
            return;
        }

        // Initialize parameters from found ones
        SetCollisionNode(GameObject.Find(CollisionNodeName));
        SetNavigationNode(navNodeMVR);
        SetFly(fly);

        // Try to start the collisions
        Initialize();
    }
Esempio n. 25
0
    protected void Update()
    {
        var displayMgr = MiddleVR.VRDisplayMgr;

        if (m_Node == null && displayMgr != null)
        {
            m_Node = displayMgr.GetNode(VRNodeName);
        }

        if (m_Node != null)
        {
            transform.position = MVRTools.ToUnity(m_Node.GetPositionVirtualWorld());
            transform.rotation = MVRTools.ToUnity(m_Node.GetOrientationVirtualWorld());
        }
    }
    protected void Update()
    {
        var displayMgr = MiddleVR.VRDisplayMgr;

        if (m_Node == null && displayMgr != null)
        {
            m_Node = displayMgr.GetNode(VRNodeName);
        }

        if (m_Node != null)
        {
            transform.position = MVRTools.ToUnity(m_Node.GetPositionVirtualWorld());
            transform.rotation = MVRTools.ToUnity(m_Node.GetOrientationVirtualWorld());
        }
    }
Esempio n. 27
0
    public vrNode3D CreateNode(string iNodeName, MVRNodesMapper.ENodesSyncDirection iSyncDirection)
    {
        vrNode3D node = null;

        if (iNodeName != "")
        {
            vrDisplayManager displayManager = MiddleVR.VRDisplayMgr;
            if (displayManager.GetNode(iNodeName) == null)
            {
                node = displayManager.CreateNode(iNodeName);
                // Copy transformation from gameObject to node3d
                _SetNode(node, MVRNodesMapper.ENodesSyncDirection.UnityToMiddleVR, iSyncDirection);
            }
        }

        return(node);
    }
    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);
            }
        }
    }
Esempio n. 29
0
    public void SetNavigationNode( vrNode3D iNavigationNode )
    {
        if (m_VRNavigationNode == null)
        {
            MVRTools.Log(2, "[X] VRNavigationCollision: MiddleVR navigation node is null.");
        }

        m_VRNavigationNode = iNavigationNode;

        GameObject unityNavigationNode = MVRNodesMapper.Instance.GetNode(iNavigationNode);
        if (unityNavigationNode == null)
        {
            MVRTools.Log(2, "[X] VRNavigationCollision: impossible to retrieve navigation node GameObject.");
            return;
        }

        m_NavigationNode = unityNavigationNode;
    }
    private void Grab(GameObject iGrabbedObject)
    {
        if (iGrabbedObject == null)
        {
            return;
        }

        if (OnGrab != null)
        {
            OnGrab(this, e_GrabStatus.GRABBED);
        }

        // Initialize manipulated node
        m_CurrentManipulatedObject = iGrabbedObject;
        VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>();

        m_ObjectPreviousSyncDir     = vrActorScript.SyncDirection;
        vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.BothDirections;
        vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode();

        m_it.SetManipulatedNode(middleVRNode);

        // Save initial position
        m_ManipulatedObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition;
        m_ManipulatedObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation;

        // Pause rigidbody acceleration
        Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent <Rigidbody>();

        if (manipulatedRigidbody != null)
        {
            m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic;
            manipulatedRigidbody.isKinematic      = true;
        }

        // Deactivate selection during the manipulation
        vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection");

        if (selection != null)
        {
            m_PausedSelection = selection;
            MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection);
        }
    }
Esempio n. 31
0
    public void SetNavigationNode(vrNode3D iNavigationNode)
    {
        if (m_VRNavigationNode == null)
        {
            MVRTools.Log(2, "[X] VRNavigationCollision: MiddleVR navigation node is null.");
        }

        m_VRNavigationNode = iNavigationNode;

        GameObject unityNavigationNode = MVRNodesMapper.Instance.GetNode(iNavigationNode);

        if (unityNavigationNode == null)
        {
            MVRTools.Log(2, "[X] VRNavigationCollision: impossible to retrieve navigation node GameObject.");
            return;
        }

        m_NavigationNode = unityNavigationNode;
    }
    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);
    }
Esempio n. 33
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");
            }
        }
    }
Esempio n. 34
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;
        }
    }
Esempio n. 35
0
    private 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;
        }
    }
Esempio n. 36
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));
    }
Esempio n. 37
0
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationGrabWorld(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_NavigationNode = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);

        if (m_ReferenceNode != null && m_NavigationNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationGrabWorld: One or several nodes are missing.");
        }
    }
Esempio n. 38
0
    private bool _OnNodeEvent(vrEvent iEvent)
    {
        if (!m_IsNodeGrabbed)
        {
            vrObjectEvent objectEvent = vrObjectEvent.Cast(iEvent);
            if (objectEvent != null && objectEvent.GetEventType() == (int)VRObjectEventEnum.VRObjectEvent_Destroy)
            {
                MVRNodesMapper nodesMapper = MVRNodesMapper.Instance;

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

                SetSyncDirection(MVRNodesMapper.ENodesSyncDirection.NoSynchronization);
                m_Node = null;

                // Destroys the object later this frame, before rendering
                UnityEngine.Object.Destroy(gameObject);
            }
        }
        return(true);
    }
    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 Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationElastic(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if ( m_ReferenceNode!= null && m_TurnAroundNode != null )
        {
            m_it.SetActionButton( WandActionButton );

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);

            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);

            m_it.SetDistanceThreshold( DistanceThreshold );
            m_it.SetAngleThreshold(AngleThreshold);

            m_it.SetUseRotationYaw(UseRotationYaw);

            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog( 2, "[X] VRInteractionNavigationElastic: One or several nodes are missing." );
        }
    }
    private void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationElastic(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_ReferenceNode != null && m_TurnAroundNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);

            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);

            m_it.SetDistanceThreshold(DistanceThreshold);
            m_it.SetAngleThreshold(AngleThreshold);

            m_it.SetUseRotationYaw(UseRotationYaw);

            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic: One or several nodes are missing.");
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationGrabWorld(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);

        if ( m_ReferenceNode!= null )
        {
            m_it.SetActionButton(WandActionButton);
            m_it.SetReferenceNode(m_ReferenceNode);
        }
        else
        {
            MiddleVR.VRLog( 2, "[X] VRInteractionNavigationGrabWorld: One or several nodes are missing." );
        }
    }
 // Use this for initialization
 void Start()
 {
     offsetNode = MiddleVR.VRDisplayMgr.GetNode("GunNode");
     rotOffset = new Vector3(offsetNode.GetRollLocal(), offsetNode.GetPitchLocal(), offsetNode.GetYawLocal());
 }
    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)
            {
                VRActor vrActorScript = m_NavRefNode.AddComponent<VRActor>();
                m_NavRefVrNode = vrActorScript.GetMiddleVRNode();
                m_it.SetNavigationReferentialNode(m_NavRefVrNode);
            }
        }

        m_Initialized = true;
    }
Esempio n. 45
0
    private void OnDestroy()
    {
        if (m_Node3D != null)
        {
            // Test for VRDisplayMgr existence in case VRManagerScript is destroyed before this script
            if (MiddleVR.VRDisplayMgr != null)
            {
                if (m_SyncDirection != MVRNodesMapper.ENodesSyncDirection.NoSynchronization)
                {
                    MVRNodesMapper.Instance.RemoveMapping(gameObject, false);
                }

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

            m_Node3D = null;
        }
    }
Esempio n. 46
0
    private void _Initialize()
    {
        vrNode3D node = MVRNodesMapper.Instance.GetNode(gameObject);

        if (node != null)
        {
            m_SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
            m_Node3DName = node.GetName();
            m_Node3D = node;

            m_IsNodeOwned = false;
        }

        if (m_Node3D == null && m_Node3DName.Length > 0)
        {
            node = MiddleVR.VRDisplayMgr.GetNode(m_Node3DName);
            if (node == null)
            {
                MVRNodesMapper.ENodesSyncDirection oldDirection = m_SyncDirection;
                m_SyncDirection = MVRNodesMapper.ENodesSyncDirection.UnityToMiddleVR;
                _SetNode3D(MiddleVR.VRDisplayMgr.CreateNode(m_Node3DName), true);
                _SetSyncDirection(oldDirection);
            }
            else
            {
                _SetNode3D(node, false);
            }
        }

        m_IsInitialized = true;
    }
Esempio n. 47
0
    public vrNode3D GetOrCreateNode3D()
    {
        if (!m_IsInitialized)
        {
            _Initialize();
        }

        if (m_Node3D == null)
        {
            vrNode3D node = MVRNodesMapper.Instance.GetNode(gameObject);

            if (node != null)
            {
                m_SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
                m_Node3DName = node.GetName();
                m_Node3D = node;

                m_IsNodeOwned = false;
            }

        }

        if (m_Node3D == null)
        {
            MVRNodesMapper.ENodesSyncDirection oldDirection = m_SyncDirection;
            m_SyncDirection = MVRNodesMapper.ENodesSyncDirection.UnityToMiddleVR;
            _SetNode3D(MiddleVR.VRDisplayMgr.CreateNode(gameObject.name + "_" + gameObject.GetInstanceID().ToString()), true);
            _SetSyncDirection(oldDirection);
        }

        return m_Node3D;
    }
    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);
    }
Esempio n. 49
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 = "";
        }
    }