Example #1
0
        protected override void OnGrabbing()
        {
            if (m_GrabData.AmIGrabbing)
            {
                if (!m_bIsAblePulling)
                {
                    Vector3 handWorldPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);

                    //m_vCurrentPullingPosition = handWorldPosition;
                    m_vPrevPullingPosition = handWorldPosition;
                    return;
                }
                if (m_PullType == PullType.Position)
                {
                    CalculatePosition();
                }
                else if (m_PullType == PullType.Rotation)
                {
                    CalculateRotation();
                }
                CheckLimitVlaue();
                onChangePullValue?.Invoke();
                TranslatePullingTarget(m_fPulledValue);

                if (m_comunicationData.IsAbleSend)
                {
                    SendPullData();
                }
            }
            else
            {
                float pullValue = Mathf.Lerp(m_fPrevPulledvalue, m_fPulledValue, m_comunicationData.UpdateDelta);
                TranslatePullingTarget(pullValue);
            }
        }
Example #2
0
        private void ExecuteIsDeviceOutOfBoundary()
        {
            if (g_refSelectedDetector == null)
            {
                return;
            }

            Vector3 head                    = VRInputManager.GetDevicePosition(VRInputManager.PositionType.HMD);
            Vector3 leftHand                = VRInputManager.GetControllerPosition(VRHand.eHandType.Left, VRInputManager.PositionType.CONTROLLER);
            Vector3 RightHand               = VRInputManager.GetControllerPosition(VRHand.eHandType.Right, VRInputManager.PositionType.CONTROLLER);
            bool    isInIgnoreZoneHead      = false;
            bool    isInIgnoreZoneLeftHand  = false;
            bool    isInIgnoreZoneRightHand = false;

            if (g_stIgnoreBoundaryArea != null)
            {
                isInIgnoreZoneHead      = g_stIgnoreBoundaryArea.Contains(head);
                isInIgnoreZoneLeftHand  = g_stIgnoreBoundaryArea.Contains(leftHand);
                isInIgnoreZoneRightHand = g_stIgnoreBoundaryArea.Contains(RightHand);
            }



            bool isInHead      = g_refSelectedDetector.IsPointInBoundary_Renewal(head);
            bool isInLeftHand  = g_refSelectedDetector.IsPointInBoundary_Renewal(leftHand);
            bool isInRightHand = g_refSelectedDetector.IsPointInBoundary_Renewal(RightHand);

            g_refBoundaryRenderer.SetLeftHandPosition(isInIgnoreZoneLeftHand, leftHand);
            g_refBoundaryRenderer.SetRightHandPosition(isInIgnoreZoneRightHand, RightHand);

            isInHead      = isInHead || isInIgnoreZoneHead;
            isInLeftHand  = isInLeftHand || isInIgnoreZoneLeftHand;
            isInRightHand = isInRightHand || isInIgnoreZoneRightHand;

            bool isInAll = isInHead && isInLeftHand && isInRightHand;

            if (m_bWasHeadInsideOfBoundary != isInHead)
            {
                onBoundHead?.Invoke(isInHead);
            }
            if (m_bWasLeftHandInsideOfBoundary != isInLeftHand)
            {
                onBoundLeftHand?.Invoke(isInLeftHand);
            }
            if (m_bWasRightHandInsideOfBoundary != isInRightHand)
            {
                onBoundRightHand?.Invoke(isInRightHand);
            }
            if (m_bWasAllInsideOfBoundary != isInAll)
            {
                onBoundAll?.Invoke(isInAll);
            }


            m_bWasHeadInsideOfBoundary      = isInHead;
            m_bWasLeftHandInsideOfBoundary  = isInLeftHand;
            m_bWasRightHandInsideOfBoundary = isInRightHand;
            m_bWasAllInsideOfBoundary       = isInAll;
        }
Example #3
0
        private void CalculatePosition()
        {
            m_fPrevPulledvalue = m_fPulledValue;
            //m_vPrevPullingPosition = m_vCurrentPullingPosition;
            Vector3 currentHandPosition = m_vCurrentPullingPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);
            Vector3 delta = currentHandPosition - m_vPrevPullingPosition;

            float dot = Vector3.Dot(m_vWorldPullingAxis, delta);

            m_vPrevPullingPosition = currentHandPosition;
            m_fPulledValue        += dot;
        }
Example #4
0
 protected override void OnGrab()
 {
     base.OnGrab();
     if (MyNetworkManager.IsMyID(m_GrabData.GrabberID))
     {
         Vector3 handWorldPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);
         m_vPrevPullingPosition    = /*m_vCurrentPullingPosition =*/ handWorldPosition;
         prevPullingTargetPosition = m_tmPullingTarget.position;
         MyNetworkManager.SendToServer_FloatValue(MyNetworkManager.NET_GAME_MESSAGE.MSG_SYNC_PULL_VALUE, UID, m_fPulledValue);
         m_comunicationData.Send();
     }
 }
Example #5
0
        private void CalculateRotation()
        {
            Vector3 currentHandPosition = m_vCurrentPullingPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);

            Vector3 prevDirection    = m_vPrevPullingPosition - prevPullingTargetPosition;
            Vector3 currentDirection = currentHandPosition - m_tmPullingTarget.position;

            Vector3 crossFromAxisToPrev = Vector3.Cross(prevDirection, m_vWorldPullingAxis);

            Vector3 crossFromAxisToCurrent = Vector3.Cross(currentDirection, m_vWorldPullingAxis);
            Vector3 crossPrevCurrent       = Vector3.Cross(crossFromAxisToPrev, crossFromAxisToCurrent).normalized;
            float   crossAngle             = Vector3.Angle(crossFromAxisToPrev, crossFromAxisToCurrent);

            float dot = Vector3.Dot(crossPrevCurrent, m_vWorldPullingAxis);

            float finalAngle = crossAngle * dot;

            m_fPrevPulledvalue        = m_fPulledValue;
            m_vPrevPullingPosition    = currentHandPosition;
            prevPullingTargetPosition = m_tmPullingTarget.position;
            m_fPulledValue           += finalAngle;
        }