예제 #1
0
    private void FixedUpdate()
    {
        // Handle modes
        if (isRecording)
        {
            record();
        }
        if (isPlaying)
        {
            play();
        }


        // Grab objects if the pump is currently on. Let go of objects if it's not
        grabUpdate();


        // If the user is currently grabbing the robots end-effector
        if (grabScript.GetGrabbingObject() != null)
        {
            GameObject            activeController = grabScript.GetGrabbingObject().gameObject;
            VRTK_ControllerEvents controllerState  = activeController.GetComponent <VRTK_ControllerEvents>();

            // If controller is clicked, turn on pump. If controller is not clicked, turn off pump.
            setPump(controllerState.triggerClicked);
        }
    }
예제 #2
0
        protected virtual void ForceReleaseGrab()
        {
            var grabbingObject = grabbedObjectScript.GetGrabbingObject();

            if (grabbingObject)
            {
                grabbingObject.GetComponent <VRTK_InteractGrab>().ForceRelease();
            }
        }
예제 #3
0
        private void OnAnyGrabStart(object sender, InteractableObjectEventArgs e)
        {
            if (!_isRoot)
            {
                return;
            }


            ControllerEvents = _vio.GetGrabbingObject().GetComponent <VRTK_ControllerEvents>();
        }
예제 #4
0
 public bool IsGrabbed()
 {
     if (interactableObject && interactableObject.GetGrabbingObject())
     {
         return(true);
     }
     return(false);
 }
예제 #5
0
        protected virtual ControlAnimationUseAttachEventArgs SetEventPayload(float frame)
        {
            ControlAnimationUseAttachEventArgs e;

            e.interactingObject = (grabbedObjectScript != null ? grabbedObjectScript.GetGrabbingObject() : null);
            e.currentFrame      = frame;
            return(e);
        }
예제 #6
0
        private IEnumerator DetectAbsorberEnumerator()
        {
            WaitForSeconds wait = new WaitForSeconds(INTERVAL_TIME);

            while (true)
            {
                if (!m_isAbsorbed)
                {
                    IAbsorber nearestAbsorber;
                    if (IsAnyMatchedAbsorberNearby(out nearestAbsorber))
                    {
                        if (!m_isHovered)
                        {
                            OnHoveredIn(this, new AbsorbTargetEventArgs(m_interObj.GetGrabbingObject(), nearestAbsorber));
                        }
                        if (!m_interObj.IsGrabbed() && !m_isAbsorbed)
                        {
                            OnAbsorbbed(this, new AbsorbTargetEventArgs(m_interObj.GetGrabbingObject(), nearestAbsorber));
                        }
                        else
                        {
                            //isn't matched so do nothing.
                        }
                    }
                    else
                    {
                        if (m_isHovered)
                        {
                            OnHoveredOut(this, new AbsorbTargetEventArgs(m_interObj.GetGrabbingObject(), m_hoveringAbsorber));
                        }
                    }
                }
                else
                {//IsAbsorbed
                    if (m_interObj.IsGrabbed() && m_isAbsorbed)
                    {
                        OnReleased(this, new AbsorbTargetEventArgs(m_interObj.GetGrabbingObject(), m_currentAbsorber));
                    }
                }
                yield return(wait);
            }
        }
예제 #7
0
    private void SetNormaliserPosition()
    {
        if (interactableObject.IsGrabbed())
        {
            float offset = parentAxis.CalculateLinearMapping(interactableObject.GetGrabbingObject().transform);
            offset = Mathf.Clamp(offset, 0, 1);

            if (myDirection == 1)
            {
                if (isMinHandle)
                {
                    parentChart.XNormaliser = new Vector2(offset, parentChart.XNormaliser.y);
                }
                else
                {
                    parentChart.XNormaliser = new Vector2(parentChart.XNormaliser.x, offset);
                }
            }
            else if (myDirection == 2)
            {
                if (isMinHandle)
                {
                    parentChart.YNormaliser = new Vector2(offset, parentChart.YNormaliser.y);
                }
                else
                {
                    parentChart.YNormaliser = new Vector2(parentChart.YNormaliser.x, offset);
                }
            }
            else if (myDirection == 3)
            {
                if (isMinHandle)
                {
                    parentChart.ZNormaliser = new Vector2(offset, parentChart.ZNormaliser.y);
                }
                else
                {
                    parentChart.ZNormaliser = new Vector2(parentChart.ZNormaliser.x, offset);
                }
            }

            Vector3 newPos = Vector3.Lerp(parentAxis.MinPosition, parentAxis.MaxPosition, offset);
            newPos.x = initX;
            newPos.z = 0;
            transform.localPosition = newPos;
            transform.localRotation = storedRotation;

            storedPosition = newPos;

            VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.075f);
        }
    }
예제 #8
0
        private void RequestNoteSelector()
        {
            SetNoteSelectorHand(VRTK_ControllerReference.GetControllerReference(interactable.GetGrabbingObject()));

            int selectedNote = selectedNotes.Count > 0 ? selectedNotes[0] : -1;

            displayingNoteSelector = noteSelector.Request(noteSelectorHand, selectedNote);
            if (displayingNoteSelector)
            {
                noteSelector.NoteSelected += OnNoteSelectionChanged;
                SetRootNote(noteSelector.GetSelectedNote());
            }
        }
예제 #9
0
 protected virtual void ForceReleaseGrab()
 {
     if (grabbedObjectScript)
     {
         GameObject grabbingObject = grabbedObjectScript.GetGrabbingObject();
         if (grabbingObject != null)
         {
             VRTK_InteractGrab grabbingObjectScript = grabbingObject.GetComponentInChildren <VRTK_InteractGrab>();
             if (grabbingObjectScript != null)
             {
                 grabbingObjectScript.ForceRelease();
             }
         }
     }
 }
예제 #10
0
 void OnTriggerStay(Collider other)
 {
     if (other.gameObject.GetComponent <VRTK_InteractableObject>().IsGrabbed())
     {
         if (mWasTriggerEnteredSkipped)
         {
             OnTriggerEnter(other);
         }
         VRTK_InteractableObject heldInteractableObject = other.gameObject.GetComponent <VRTK_InteractableObject>();
         GameObject heldControllerGameObject            = heldInteractableObject.GetGrabbingObject();
         if (heldControllerGameObject != null)
         {
             VRTK_ControllerActions heldControllerActions = heldControllerGameObject.GetComponent <VRTK_ControllerActions>();
             heldControllerActions.TriggerHapticPulse(bagHapticVibration);
         }
     }
 }
예제 #11
0
 private void OnTriggerEnter(Collider other)
 {
     if (!IsCollectable)
     {
         return;
     }
     if (m_InteractableObject.IsGrabbed())
     {
         if (other.transform.parent.tag == "Player")
         {
             BackPackManager.Instance.CollectItem(type);
             m_InteractableObject.GetGrabbingObject().GetComponent <VRTK_InteractGrab>().ForceRelease();
             if (CustomDestroyGameObject != null)
             {
                 Destroy(CustomDestroyGameObject);
             }
             else
             {
                 Destroy(gameObject);
             }
         }
     }
 }
예제 #12
0
    private void OnTriggerEnter(Collider other)
    {
        if (isErasing)
        {
            if (other.gameObject.tag == "Line")
            {
                LineScript line = other.GetComponent <LineScript>();
                DataLogger.Instance.LogActionData(this, line.OriginalOwner, line.photonView.Owner, "Line erased", line.ID);

                PhotonNetwork.Destroy(other.gameObject);

                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.3f);
            }
        }
    }
예제 #13
0
    private void Update()
    {
        if (isDrawing && currentLine != null)
        {
            Vector3 tempFingerPos = markerTip.position;

            if (Vector3.Distance(tempFingerPos, fingerPositions[fingerPositions.Count - 1]) >= 0.005f)
            {
                CallUpdateLine(tempFingerPos);
            }

            if (isTouchingChart && currentLine.transform.parent == null)
            {
                currentLine.transform.SetParent(touchingChart.transform);
            }

            VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.025f);
        }
    }
예제 #14
0
        public void GrabRpc(bool grab, ushort viewId)
        {
            GameObject ioObject        = netvrkManager.GetViewById(viewId).gameObject;
            VRTK_InteractableObject io = ioObject.GetComponent <VRTK_InteractableObject>();

            if (grab)
            {
                io.isGrabbable = false;
                SDK_BaseController.ControllerHand hand = VRTK_DeviceFinder.GetControllerHand(io.GetGrabbingObject());
                if (hand == SDK_BaseController.ControllerHand.Left)
                {
                    ioObject.transform.SetParent(networkLeftHand);
                }
                else if (hand == SDK_BaseController.ControllerHand.Right)
                {
                    ioObject.transform.SetParent(networkRightHand);
                }
            }
            else
            {
                io.isGrabbable = true;
                ioObject.transform.SetParent(null);
            }
        }