Ejemplo n.º 1
0
        void OnTriggerEnter(Collider other)
        {
            // Don't want palm
            if (other.name == "palm")
            {
                return;
            }
            if (other.transform.parent == null || other.transform.parent.parent == null)
            {
                return;
            }

            if (other.transform.parent.parent.name == "Hand_l")
            {
                m_leftHandFingerIn++;
            }
            else if (other.transform.parent.parent.name == "Hand_r")
            {
                m_rightHandFingerIn++;
            }

            // meaningless if it's already entered.
            if (m_entered)
            {
                return;
            }

            // if it's locked, don't change anything
            if (m_ableToExpand == false)
            {
                return;
            }

            if (m_leftHandFingerIn >= FINGER_THRESHOLD)
            {
                // Tell it to be grabbed
                if (m_grabObj != null)
                {
                    m_grabObj.OnGrabTriggerEnter(this, true);
                    m_entered = true;
                    Expand(other.transform.parent.parent);
                }
            }
            else if (m_rightHandFingerIn >= FINGER_THRESHOLD)
            {
                // Tell it to be grabbed
                if (m_grabObj != null)
                {
                    m_grabObj.OnGrabTriggerEnter(this, false);
                    m_entered = true;
                    Expand(other.transform.parent.parent);
                }
            }
        }
Ejemplo n.º 2
0
        void OnTriggerEnter(Collider other)
        {
            // Don't want palm
            if (other.name == "palm")
            {
                return;
            }
            if (other.transform.parent == null || other.transform.parent.parent == null)
            {
                return;
            }

            if (other.transform.parent.parent.name == "Hand_l")
            {
                if (other.transform.parent.name != "ring" && other.transform.parent.name != "pinky")
                {
                    m_leftHandFingerIn++;
                }
            }
            else if (other.transform.parent.parent.name == "Hand_r")
            {
                if (other.transform.parent.name != "ring" && other.transform.parent.name != "pinky")
                {
                    m_rightHandFingerIn++;
                }
            }

            // meaningless if it's already entered.
            if (m_entered)
            {
                return;
            }

            // if it's locked, don't change anything
            if (m_ableToExpand == false)
            {
                return;
            }

            // Jiaju FoamAR addition
            //if (!FoamUtils.IsGlobalGrabbing) return;
            if (FoamUtils.ShouldStopGrabCollider(this.transform.parent.gameObject))
            {
                return;
            }


            if (m_leftHandFingerIn >= FINGER_THRESHOLD)
            {
                // Jiaju
                Modelable model = _parentGameObject.GetComponent <Modelable>();
                if (model)
                {
                    model.SetAsSelected();
                }
            }
            else if (m_rightHandFingerIn >= FINGER_THRESHOLD)
            {
                // Jiaju
                Modelable model = _parentGameObject.GetComponent <Modelable>();
                if (model)
                {
                    model.SetAsSelected();
                }

                // Tell it to be grabbed
                if (m_grabObj != null)
                {
                    m_grabObj.OnGrabTriggerEnter(this, false);
                    m_entered = true;
                    Expand(other.transform.parent.parent);
                }
            }
        }