Example #1
0
    protected void Update()
    {
        VRSelection selection = m_SelectionMgr.GetSelection();

        // Send action if selection not null
        if (selection != null && selection.SelectedObject != null)
        {
            if (SendWandEvents)
            {
                // VRAction
                if ((!RepeatVRAction && MiddleVR.VRDeviceMgr.IsWandButtonToggled(0)) ||
                    (RepeatVRAction && MiddleVR.VRDeviceMgr.IsWandButtonPressed(0)))
                {
                    selection.SelectedObject.SendMessage("VRAction", selection, SendMessageOptions.DontRequireReceiver);
                }

                // Wand button pressed/released
                if (MiddleVR.VRDeviceMgr.IsWandButtonToggled(0))
                {
                    selection.SelectedObject.SendMessage("OnMVRWandButtonPressed", selection, SendMessageOptions.DontRequireReceiver);
                }
                else if (MiddleVR.VRDeviceMgr.IsWandButtonToggled(0, false))
                {
                    selection.SelectedObject.SendMessage("OnMVRWandButtonReleased", selection, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
Example #2
0
    void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            switch (m_State)
            {
            case InteractionState.Inactive:
                if (m_it.IsManipulationStarted())
                {
                    GrabInitialPosition(m_CurrentSelectedObject);
                    Grab(m_CurrentSelectedObject);
                    m_State = InteractionState.Running;
                }
                break;

            case InteractionState.Running:
                if (m_it.IsManipulationStopped())
                {
                    Ungrab();
                    m_State = InteractionState.Inactive;
                }
                break;
            }
        }
    }
Example #3
0
    private void _SendWandEvents()
    {
        if (!m_Wand.SendWandEvents)
        {
            return;
        }

        VRSelection selection = m_SelectionMgr.GetSelection();

        // Enter/exit events
        if (!VRSelection.Compare(m_LastSelection, selection))
        {
            // Selection changed

            // Exit last
            if (m_LastSelection != null)
            {
                m_LastSelection.SelectedObject.SendMessage("OnMVRWandExit", m_LastSelection, SendMessageOptions.DontRequireReceiver);
            }

            // Enter new
            if (selection != null)
            {
                selection.SelectedObject.SendMessage("OnMVRWandEnter", selection, SendMessageOptions.DontRequireReceiver);
            }
        }
        else
        {
            // Hover current
            if (selection != null)
            {
                selection.SelectedObject.SendMessage("OnMVRWandHover", selection, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
    protected void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            // Manipulation
            if (m_it.HasManipulationStarted())
            {
                // Try to grab
                Grab(m_CurrentSelectedObject);
            }
            else if (m_it.IsManipulationRunning() && m_CurrentManipulatedObject != null)
            {
                // Nothing to do here
            }
            else if (m_it.IsManipulationStopped())
            {
                Ungrab();
            }
        }
    }
Example #5
0
        protected void OnMVRWandButtonPressed(VRSelection iSelection)
        {
            if (!_animator.GetCurrentAnimatorStateInfo(0).IsTag("Idle"))
                return;

            _isOpen = !_isOpen;
            _animator.SetBool("IsOpen", _isOpen);
        }
Example #6
0
 public static bool Compare(VRSelection iFirst, VRSelection iSecond)
 {
     if (iFirst != null && iSecond != null)
     {
         return(iFirst.SelectedObject == iSecond.SelectedObject);
     }
     else if (iFirst == null && iSecond == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #7
0
    protected void _RefreshRayMesh()
    {
        VRSelection selection = m_SelectionMgr.GetSelection();

        if (selection != null)
        {
            m_Wand.SetRayColor(HoverColor);
            m_Wand.SetRayLength(selection.SelectionDistance);
        }
        else
        {
            m_Wand.SetRayColor(m_Wand.DefaultRayColor);
            m_Wand.SetRayLength(m_Wand.DefaultRayLength);
        }
    }
Example #8
0
 public static bool Compare(VRSelection iFirst, VRSelection iSecond)
 {
     if (iFirst != null && iSecond != null)
     {
         return iFirst.SelectedObject == iSecond.SelectedObject;
     }
     else if (iFirst == null && iSecond == null)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Example #9
0
    /// <summary>
    /// This gets call if the Wand enters a Scatterplot.
    /// Normally the colliders of the DataPoints are disabled.
    /// This is done because Unity can only handle so many colliders
    /// at once. If the user imports to many DataPoints, Unity
    /// throws an error. Because of this the colliders of the DataPoints
    /// are only enabled if the Wand enters their Scatterplot. The
    /// collider of this Scatterplot gets disabled so the Wand can
    /// interact with the DataPoints. Once another Scatterplot is entered
    /// by the Wand the collider of the previous entered Scatterplot is
    /// enabled again and the colliders of his included DataPoints are
    /// disabled. This reduces the amount of active colliders at a time
    /// dramatically.
    /// </summary>
    /// <param name="iSelection"></param>
    protected void OnMVRWandEnter(VRSelection iSelection)
    {
        foreach (Transform scatterplot in transform.parent)
        {
            Collider collider           = scatterplot.GetComponent <BoxCollider>();
            bool     previouslySelected = !collider.enabled;

            collider.enabled = previouslySelected;
            foreach (Transform dataPoint in scatterplot)
            {
                collider = dataPoint.GetComponent <SphereCollider>();
                if (null != collider)
                {
                    collider.enabled = !previouslySelected;
                }
            }
        }
    }
Example #10
0
 public void SetSelection(VRSelection iSelection)
 {
     m_Selection = iSelection;
 }
 protected void OnMVRWandButtonReleased(VRSelection iSelection)
 {
     SetVirtualMouseButtonReleased();
     SetVirtualMousePosition(iSelection.TextureCoordinate);
 }
Example #12
0
 protected void OnMVRWandButtonReleased(VRSelection iSelection)
 {
     print(name + ": OnMVRWandButtonReleased.");
 }
Example #13
0
 protected void OnMVRWandButtonPressed(VRSelection iSelection)
 {
     source.clip = clips[currentClipIndex];
     source.Play();
     SwitchClip();
 }
Example #14
0
 protected void OnMVRWandEnter(VRSelection iSelection)
 {
     _buttonRenderer.material.color = Color.green;
 }
Example #15
0
 /// <summary>
 /// Is triggered when Wand button 0 was
 /// </summary>
 protected void VRAction(VRSelection iSelection)
 {
     Activate();
 }
Example #16
0
 protected void OnMVRWandButtonReleased(VRSelection iSelection)
 {
     transform.parent = _parent;
 }
Example #17
0
 private void OnMVRWandEnter(VRSelection iSelection)
 {
     print(name + ": OnMVRWandEnter.");
 }
Example #18
0
 protected void OnMVRWandHover(VRSelection iSelection)
 {
     //print(name + ": OnMVRWandHover.");
 }
Example #19
0
    /// <summary>
    /// This is called when the user selects the DataPoint.
    /// The call is delegated to the ScatterplotMatrix so that it
    /// can be forwarded to all the Scatterplots.
    /// This way if a DataPoint with a given index is selected, the
    /// same DataPoint in other Scatterplots are highlighted as well.
    /// </summary>
    /// <param name="iSelection"></param>
    protected void VRAction(VRSelection iSelection)
    {
        ScatterplotMatrix scatterplotMatrix = scatterplot.GetComponentInParent <ScatterplotMatrix>();

        scatterplotMatrix.SelectDataPoint(index);
    }
    void Update()
    {
        if (IsActive())
        {
            // Retrieve selection result
            VRSelection selection = m_Wand.GetSelection();

            if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable)
            {
                return;
            }

            m_CurrentSelectedObject = selection.SelectedObject;

            switch (m_State)
            {
            case InteractionState.Inactive:
                if (m_it.IsManipulationStarted())
                {
                    GrabInitialPosition(m_CurrentSelectedObject);
                    var authorityRequest = RequestAssignClientAuthority(m_CurrentSelectedObject);
                    if (authorityRequest == AuthorityRequestState.Accepted)
                    {
                        Grab(m_CurrentSelectedObject);
                        m_State = InteractionState.Running;
                    }
                    else
                    {
                        m_State = InteractionState.AuthorityPending;
                    }
                }
                break;

            case InteractionState.AuthorityPending:
                if (m_it.IsManipulationStopped())
                {
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                else
                {
                    var authorityRequest = RequestAssignClientAuthority(m_CurrentSelectedObject);
                    if (authorityRequest == AuthorityRequestState.Accepted)
                    {
                        Grab(m_CurrentSelectedObject);
                        m_State = InteractionState.Running;
                    }
                }
                break;

            case InteractionState.Running:
                if (m_it.IsManipulationStopped())
                {
                    RequestRemoveClientAuthority(m_CurrentSelectedObject);
                    Ungrab();
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                break;

            case InteractionState.AuthorityDenied:
                if (m_it.IsManipulationStopped())
                {
                    ClearClientAuthorityRequest();
                    m_State = InteractionState.Inactive;
                }
                break;
            }
        }
    }
 void VRAction(VRSelection iSelection)
 {
     StartCoroutine(MakeVibrate());
 }
Example #22
0
    private void _RaySelection()
    {
        // Ray picking
        RaycastHit[] hits;
        Vector3      dir = transform.localToWorldMatrix * Vector3.forward;

        hits = Physics.RaycastAll(transform.position, dir, m_Wand.GetDefaultRayLength());

        bool  foundActor   = false;
        int   currentHitId = 0;
        int   foundHitId   = 0;
        float distance     = Mathf.Infinity;

        while (currentHitId < hits.Length)
        {
            RaycastHit hit = hits[currentHitId];

            if (hit.distance < distance && hit.collider.name != "VRWand")
            {
                if (hit.collider.GetComponent <VRActor>() == null)
                {
                    currentHitId++;
                    continue;
                }

                // Pass through empty/transparent GUI pixels
                VRWebView webView = hit.collider.GetComponent <VRWebView>();
                if (webView != null)
                {
                    if (!webView.GetComponent <Renderer>().enabled || webView.IsPixelEmpty(hit.textureCoord))
                    {
                        currentHitId++;
                        continue;
                    }
                }

                foundActor = true;
                foundHitId = currentHitId;
                distance   = hit.distance;
            }

            currentHitId++;
        }

        m_LastSelection = m_SelectionMgr.GetSelection();

        // If something found, select
        if (foundActor)
        {
            RaycastHit  selectionHit = hits[foundHitId];
            VRSelection newSelection = new VRSelection();
            newSelection.SourceWand        = m_Wand;
            newSelection.SelectedObject    = selectionHit.collider.gameObject;
            newSelection.TextureCoordinate = selectionHit.textureCoord;
            newSelection.SelectionDistance = selectionHit.distance;
            newSelection.SelectionContact  = selectionHit.point;
            newSelection.SelectionNormal   = selectionHit.normal;
            m_SelectionMgr.SetSelection(newSelection);
        }
        else
        {
            m_SelectionMgr.SetSelection(null);
        }
    }
Example #23
0
 public void SetSelection(VRSelection iSelection)
 {
     m_Selection = iSelection;
 }
Example #24
0
 private void OnMVRWandExit(VRSelection iSelection)
 {
     print(name + ": OnMVRWandExit.");
 }
Example #25
0
  protected void OnMVRWandEnter(VRSelection iSelection)
  {
      print(name + ": OnMVRWandEnter.");
 }
Example #26
0
 /// <summary>
 /// Is triggered when Wand button 0 was
 /// </summary>
 protected void VRAction(VRSelection iSelection)
 {
     Activate();
 }
Example #27
0
 private void OnMVRWandHover(VRSelection iSelection)
 {
     //print(name + ": OnMVRWandHover.");
 }
Example #28
0
    protected void _RaySelection()
    {
        // Ray picking
        Vector3 rayOrigin    = transform.position;
        Vector3 rayDirection = transform.TransformDirection(Vector3.forward);

        VRSelection newSelection = null;

        foreach (RaycastHit raycastHit in Physics.RaycastAll(rayOrigin, rayDirection, m_Wand.GetDefaultRayLength()))
        {
            if (newSelection != null && raycastHit.distance >= newSelection.SelectionDistance)
            {
                continue;
            }

            GameObject objectHit = raycastHit.collider.gameObject;

            if (objectHit.name != "VRWand")
            {
                // Ignore GameObject without the VRActor component
                if (objectHit.GetComponent <VRActor>() == null)
                {
                    continue;
                }

                VRWebView    webView     = objectHit.GetComponent <VRWebView>();
                VRRaycastHit completeHit = null;
                if (webView != null)
                {
                    completeHit = webView.RaycastMesh(rayOrigin, rayDirection);
                }
                else
                {
                    completeHit = new VRRaycastHit(raycastHit);
                }

                if (completeHit != null)
                {
                    // Special case : pass through transparent pixels of web views.
                    if (webView != null)
                    {
                        if (!webView.GetComponent <Renderer>().enabled || webView.IsPixelEmpty(completeHit.textureCoord))
                        {
                            continue;
                        }
                    }

                    // Create selection if it does not exist
                    if (newSelection == null)
                    {
                        newSelection = new VRSelection();
                    }

                    newSelection.SourceWand        = m_Wand;
                    newSelection.SelectedObject    = objectHit;
                    newSelection.TextureCoordinate = completeHit.textureCoord;
                    newSelection.SelectionDistance = completeHit.distance;
                    newSelection.SelectionContact  = completeHit.point;
                    newSelection.SelectionNormal   = completeHit.normal;
                }
            }
        }

        m_LastSelection = m_SelectionMgr.GetSelection();
        m_SelectionMgr.SetSelection(newSelection);
    }
Example #29
0
 private void OnMVRWandButtonPressed(VRSelection iSelection)
 {
     print(name + ": OnMVRWandButtonPressed.");
 }
Example #30
0
    protected void _RaySelection()
    {
        // Ray picking
        Vector3 rayOrigin = transform.position;
        Vector3 rayDirection = transform.TransformDirection(Vector3.forward);

        VRSelection newSelection = null;

        foreach (RaycastHit raycastHit in Physics.RaycastAll(rayOrigin, rayDirection, m_Wand.GetDefaultRayLength()))
        {
            if (newSelection != null && raycastHit.distance >= newSelection.SelectionDistance)
            {
                continue;
            }

            GameObject objectHit = raycastHit.collider.gameObject;

            if (objectHit.name != "VRWand")
            {
                // Ignore GameObject without the VRActor component
                if (objectHit.GetComponent<VRActor>() == null)
                {
                    continue;
                }

                VRWebView webView = objectHit.GetComponent<VRWebView>();
                VRRaycastHit completeHit = null;
                if (webView != null)
                {
                    completeHit = webView.RaycastMesh(rayOrigin, rayDirection);
                }
                else
                {
                    completeHit = new VRRaycastHit(raycastHit);
                }

                if (completeHit != null)
                {
                    // Special case : pass through transparent pixels of web views.
                    if (webView != null)
                    {
                        if (!webView.GetComponent<Renderer>().enabled || webView.IsPixelEmpty(completeHit.textureCoord))
                        {
                            continue;
                        }
                    }

                    // Create selection if it does not exist
                    if (newSelection == null)
                    {
                        newSelection = new VRSelection();
                    }

                    newSelection.SourceWand = m_Wand;
                    newSelection.SelectedObject = objectHit;
                    newSelection.TextureCoordinate = completeHit.textureCoord;
                    newSelection.SelectionDistance = completeHit.distance;
                    newSelection.SelectionContact = completeHit.point;
                    newSelection.SelectionNormal = completeHit.normal;
                }
            }
        }

        m_LastSelection = m_SelectionMgr.GetSelection();
        m_SelectionMgr.SetSelection(newSelection);
    }
Example #31
0
 protected void OnMVRWandButtonPressed(VRSelection iSelection)
 {
     Light.enabled = !Light.enabled;
 }
Example #32
0
 protected void VRAction(VRSelection iSelection)
 {
     print(name + ": VRAction.");
     this.GetComponent<Renderer>().material.color = Color.red;
 }
Example #33
0
 protected void OnMVRWandExit(VRSelection iSelection)
 {
     _buttonRenderer.material.color = Color.white;
 }
 protected void OnMVRWandEnter(VRSelection iSelection)
 {
     // Force show ray and save state
     m_WandRayWasVisible = iSelection.SourceWand.IsRayVisible();
     iSelection.SourceWand.ShowRay(true);
 }
Example #35
0
 protected void OnMVRWandHover(VRSelection iSelection)
 {
     //print(name + ": OnMVRWandHover.");
 }
Example #36
0
 protected void OnMVRWandExit(VRSelection iSelection)
 {
     print(name + ": OnMVRWandExit.");
 }
Example #37
0
 protected void OnMVRWandEnter(VRSelection iSelection)
 {
     print(name + ": OnMVRWandEnter.");
 }
Example #38
0
 protected void OnMVRWandButtonReleased(VRSelection iSelection)
 {
     print(name + ": OnMVRWandButtonReleased.");
 }
Example #39
0
 protected void OnMVRWandExit(VRSelection iSelection)
 {
     print(name + ": OnMVRWandExit.");
 }
Example #40
0
 protected void OnMVRWandEnter(VRSelection iSelection)
 {
     // Force show ray and save state
     m_WandRayWasVisible = iSelection.SourceWand.IsRayVisible();
     iSelection.SourceWand.ShowRay(true);
 }
Example #41
0
 protected void VRAction(VRSelection iSelection)
 {
     print(name + ": VRAction.");
     this.GetComponent <Renderer>().material.color = Color.red;
 }
Example #42
0
 protected void OnMVRWandHover(VRSelection iSelection)
 {
     SetVirtualMousePosition(iSelection.TextureCoordinate);
 }
 protected void OnMVRWandHover(VRSelection iSelection)
 {
     SetVirtualMousePosition(iSelection.TextureCoordinate);
 }
Example #44
0
 protected void OnMVRWandButtonReleased(VRSelection iSelection)
 {
     SetVirtualMouseButtonReleased();
     SetVirtualMousePosition(iSelection.TextureCoordinate);
 }
 protected void OnMVRWandExit(VRSelection iSelection)
 {
     // Unforce show ray
     iSelection.SourceWand.ShowRay(m_WandRayWasVisible);
 }
Example #46
0
 protected void OnMVRWandExit(VRSelection iSelection)
 {
     // Unforce show ray
     iSelection.SourceWand.ShowRay(m_WandRayWasVisible);
 }