Esempio n. 1
0
        /// <summary>
        /// Stop to grab
        /// </summary>
        private void EndGrab()
        {
            // unexpected call
            if (!m_isGrabbing || m_selectObj == null)
            {
                return;
            }

            Debug.Log("EndGrab()");
            m_selectObj.OnGrabStop(m_grabInfo.ReleaseRawVelocity);
            m_isGrabbing     = false;
            m_regrabCooldown = REGRAB_COOLDOWN;

            //Jiaju change
            if (m_selectObj)
            {
                Selectable select = m_selectObj.gameObject.GetComponent <Selectable>();
                if (select)
                {
                    select.ResetColliderSizeToOG();
                }
            }
            //Jiaju change end

            m_lastGrabObject = m_selectObj;
            OnRelease(m_selectObj.IsLeftHanded ? m_tLeftHand.Find("palm") : m_tRightHand.Find("palm"), m_selectObj);
        }
Esempio n. 2
0
        // Use this for initialization
        void Start()
        {
            // Set kinematic in order to avoid physics
            Rigidbody rb = GetComponent <Rigidbody>();

            if (!rb.isKinematic)
            {
                rb.isKinematic = true;
            }

            // If the collider is mesh collider, make sure to use convex one.
            Collider collider = GetComponent <Collider>();

            if (collider.isTrigger == false)
            {
                collider.isTrigger = true;
            }
            if (collider is MeshCollider)
            {
                MeshCollider mcd = (MeshCollider)collider;
                if (mcd.convex == false)
                {
                    mcd.convex = true;
                }
            }

            if (m_grabObj == null && transform.parent != null)
            {
                m_grabObj = transform.parent.GetComponent <Grabable>();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Select an object.
        /// </summary>
        /// <param name="obj"></param>
        private void SelectObj(Grabable obj)
        {
            if (obj != null)
            {
                m_selectObj = obj;
                obj.OnSelected();

                // when select new object, cancel regrab cooldown
                m_regrabCooldown = -1f;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Deselect an object.
 /// </summary>
 /// <param name="obj"></param>
 private void DeSelectObj(Grabable obj)
 {
     if (m_selectObj == obj)
     {
         if (m_isGrabbing)
         {
             EndGrab();
         }
         m_selectObj = null;
         obj.OnDeSelected();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Stop to grab
        /// </summary>
        private void EndGrab()
        {
            // unexpected call
            if (!m_isGrabbing || m_selectObj == null)
            {
                return;
            }

            Debug.Log("EndGrab()");
            m_selectObj.OnGrabStop(m_grabInfo.ReleaseRawVelocity);
            m_isGrabbing     = false;
            m_regrabCooldown = REGRAB_COOLDOWN;

            OnRelease(m_selectObj.IsLeftHanded ? m_tLeftHand.Find("palm") : m_tRightHand.Find("palm"), m_selectObj);
            m_lastGrabObject = m_selectObj;
        }
Esempio n. 6
0
        /// <summary>
        /// The obj notifies that it is no longer grabable
        /// </summary>
        /// <param name="obj">The grabable obj</param>
        internal void ExitGrabbingQueue(Grabable obj)
        {
            if (obj == null)
            {
                return;
            }

            DeSelectObj(obj);

            if (obj.IsLeftHanded)
            {
                m_leftHandQueue.Remove(obj);
            }
            else
            {
                m_rightHandQueue.Remove(obj);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Tell system that obj is ready for being grabbed
 /// </summary>
 /// <param name="obj">the grabable obj</param>
 internal void WaitForGrabbing(Grabable obj)
 {
     // check hand type to add to the corresponding queue.
     if (obj == null)
     {
         return;
     }
     if (obj.IsLeftHanded)
     {
         // check if left hand queue has this obj
         if (!m_leftHandQueue.Contains(obj))
         {
             m_leftHandQueue.Add(obj);
         }
     }
     else
     {
         if (!m_rightHandQueue.Contains(obj))
         {
             m_rightHandQueue.Add(obj);
         }
     }
 }