コード例 #1
0
    private bool EventListener(vrEvent iEvent)
    {
        // Catch interaction events
        vrInteractionEvent interactionEvt = vrInteractionEvent.Cast(iEvent);

        if (interactionEvt != null)
        {
            vrInteraction interaction = interactionEvt.GetInteraction();

            bool needLabelRefresh = false;

            // Identify interaction
            // If existing in the Menu, update the menu
            if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Activated)
            {
                vrWidgetToggleButton interactionButton;

                if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton))
                {
                    interactionButton.SetChecked(true);
                }

                needLabelRefresh = true;
            }
            else if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Deactivated)
            {
                vrWidgetToggleButton interactionButton;

                if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton))
                {
                    interactionButton.SetChecked(false);
                }

                needLabelRefresh = true;
            }

            // Refresh interaction menu label if activated or deactivated
            if (needLabelRefresh)
            {
                if (interaction.TagsContain("ContinuousNavigation"))
                {
                    _RefreshNavigationMenuName();
                }
                else if (interaction.TagsContain("ContinuousManipulation"))
                {
                    _RefreshManipulationMenuName();
                }
                else if (interaction.TagsContain("VirtualHand"))
                {
                    _RefreshVirtualHandMenuName();
                }
            }
        }

        return(true);
    }
コード例 #2
0
    private vrInteraction _GetNextInteraction(string iTag)
    {
        vrInteraction nextInteraction = null;

        vrInteraction activeInteraction = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousNavigation");

        if (activeInteraction != null)
        {
            // Found active interaction, search for the next one
            uint interactionsNb = MiddleVR.VRInteractionMgr.GetInteractionsNb();
            uint index          = MiddleVR.VRInteractionMgr.GetInteractionIndex(activeInteraction);

            for (uint i = 0; i < interactionsNb - 1; ++i)
            {
                // We loop in the interactions list to find the next interaction with the right tag
                uint nextIndex = (index + 1 + i) % interactionsNb;

                vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteractionByIndex(nextIndex);

                if (interaction != null && interaction.TagsContain("ContinuousNavigation"))
                {
                    nextInteraction = interaction;
                    break;
                }
            }
        }
        else
        {
            // No active interaction, try to activate the first if existing
            nextInteraction = MiddleVR.VRInteractionMgr.GetInteractionByTag("ContinuousNavigation", 0);
        }

        return(nextInteraction);
    }
コード例 #3
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();
    }