Exemple #1
0
    public void HandleOut(Collider _collider)
    {
        if (_collider.gameObject.tag == "GameController")
        {
            return;
        }

        if (!inUse)
        {
            return;
        }

        if (touchedObj == null)
        {
            return;
        }

        if (inStretchMode)
        {
            return;
        }

        if (_collider == touchedObj.GetComponent <Collider> ())
        {
            m_CurrentInteractible.StopTouching(gameObject);
            m_CurrentInteractible = null;
            touchedObj            = null;
        }
    }
Exemple #2
0
    public void HandleOver(Collider _collider)
    {
        if (_collider.gameObject.tag == "GameController")
        {
            return;
        }

        if (!inUse)
        {
            return;
        }

        if (inStretchMode)
        {
            return;
        }

        // If we hit an interactive item
        if (_collider.gameObject.GetComponent <VRInteractiveObject> ())
        {
            DeviceVibrate();

            touchedObj            = _collider.gameObject;
            m_CurrentInteractible = touchedObj.GetComponent <VRInteractiveObject> ();
            m_CurrentInteractible.StartTouching(gameObject);
        }
    }
Exemple #3
0
    private void Reset()
    {
        if (inStretchMode)
        {
            ExitStretchMode();
        }

        if (m_CurrentInteractible)
        {
            m_CurrentInteractible.StopTouching(gameObject);
        }

        m_CurrentInteractible = null;
        touchedObj            = null;
    }
Exemple #4
0
    private void OnTriggerEnter(Collider collider)
    {
        Debug.Log("!");

        // ignore if it's another controller
        if (collider.gameObject.tag == "GameController")
        {
            return;
        }

        // ignore if already grabbing something
        if (grabSomething)
        {
            return;
        }

        // If we hit an interactive item
        if (collider.gameObject.GetComponent <VRInteractiveObject> ())
        {
            DeviceVibrate();
            //Debug.Log (gameObject.name + " touch " + collider.name);

            touchedObj            = collider.gameObject;
            m_CurrentInteractible = touchedObj.GetComponent <VRInteractiveObject> ();
            m_CurrentInteractible.StartTouching(gameObject);

            if (touchedObj.GetComponent <Rigidbody> ())
            {
                objHasRigidbody = true;

                if (touchedObj.GetComponent <Rigidbody> ().isKinematic)
                {
                    objIsKinematic = true;
                }
                else
                {
                    objIsKinematic = false;
                }
            }
            else
            {
                objHasRigidbody = false;
            }
        }
    }
Exemple #5
0
    public void HandleOut(Collider _collider)
    {
        if (_collider.gameObject.tag == "GameController")
        {
            return;
        }

        if (!inUse)
        {
            return;
        }

        if (touchedObj == null)
        {
            return;
        }

        // comment out???
        if (inStretchMode)
        {
            return;
        }

        if (_collider == touchedObj.GetComponent <Collider> ())
        {
            // checking cuz the parenting(aka non-physics) method will trigger this event for some reason :/
            if (!m_CurrentInteractible.HasRigidbody && grabSomething)
            {
                return;
            }

            // what if it's still grabbing?
            if (grabSomething)
            {
                ExitGrabMode(false);
            }

            //Debug.Log (gameObject.name + " exit touch " + collider.name);
            m_CurrentInteractible.StopTouching(gameObject);
            m_CurrentInteractible = null;
            touchedObj            = null;
        }
    }
Exemple #6
0
    private void Reset()
    {
        if (grabSomething)
        {
            ExitGrabMode(false);
        }

        if (inStretchMode)
        {
            ExitStretchMode();
        }

        if (m_CurrentInteractible)
        {
            m_CurrentInteractible.StopTouching(gameObject);
        }
        m_CurrentInteractible = null;
        touchedObj            = null;
        //glove.OnUp ();
    }
Exemple #7
0
    private void OnTriggerExit(Collider collider)
    {
        // ignore if it's another controller
        if (collider.gameObject.tag == "GameController")
        {
            return;
        }

        if (touchedObj == null)
        {
            return;
        }

        // what if it's still in stretching mode? => exit stretch mode
        if (inStretchMode && stretchObj == collider.gameObject)
        {
            ExitStretchMode();
        }

        if (collider == touchedObj.GetComponent <Collider> ())
        {
            // due to the parenting(aka non-physics) method will trigger this event for some reason :/
            if (!objHasRigidbody && grabSomething)
            {
                return;
            }

            //DeviceVibrate();

            // what if it's still grabbing?
            if (grabSomething)
            {
                ExitGrabMode(false);
            }

            //Debug.Log (gameObject.name + " exit touch " + collider.name);
            m_CurrentInteractible.StopTouching(gameObject);
            m_CurrentInteractible = null;
            touchedObj            = null;
        }
    }
Exemple #8
0
    public void HandleOver(Collider _collider)
    {
        if (_collider.CompareTag("GameController"))
        {
            return;
        }

        if (!inUse)
        {
            return;
        }

        // ignore if in self-stretching mode
//		if (m_inSelfScalingMode || m_inSelfScalingSupportMode)
        if (isBusySelfScaling)
        {
            return;
        }

        // ignore if already grabbing something
        if (grabSomething)
        {
            return;
        }

        if (inStretchMode)
        {
            return;
        }

        // If we hit an interactive item
        if (_collider.gameObject.GetComponent <VRInteractiveObject> ())
        {
            DeviceVibrate();

            touchedObj            = _collider.gameObject;
            m_CurrentInteractible = touchedObj.GetComponent <VRInteractiveObject> ();
            m_CurrentInteractible.StartTouching(gameObject);
        }
    }
Exemple #9
0
    public void HandleStay(Collider _collider)
    {
        if (_collider.gameObject.tag == "GameController")
        {
            return;
        }

        // double check if after triggerExit, but still try to grab but not being able to do triggerEnter
        if (!inUse)
        {
            return;
        }

        // ignore if in self-stretching mode
//		if (m_inSelfScalingMode || m_inSelfScalingSupportMode)
        if (isBusySelfScaling)
        {
            return;
        }

        // ignore if already grabbing something
        if (grabSomething || touchedObj)
        {
            return;
        }

        // If we hit an interactive item
        if (_collider.gameObject.GetComponent <VRInteractiveObject> ())
        {
            DeviceVibrate();

            touchedObj            = _collider.gameObject;
            m_CurrentInteractible = touchedObj.GetComponent <VRInteractiveObject> ();
            m_CurrentInteractible.StartTouching(gameObject);
        }
    }
Exemple #10
0
    // Pointer Out + Trigger Up => hard Out
    public void OnPointerOut()
    {
        if (inStretchMode)
        {
            //Exit Stretch Mode
            inStretchMode = false;
            stretchObj    = null;
        }

        if (grabSomething && currArt)
        {
            //Exit Grab Mode

            //currArt.GetComponent<Collider>().enabled = true;
            laserPointer.OnToArt = false;

            prevArt       = currArt;
            currArt       = null;
            grabSomething = false;
            m_CurrentInteractible.LaserUp(laserPointer);
            //Debug.Log ("pointer left");
        }
        m_CurrentInteractible = null;
    }
Exemple #11
0
    // -------------------- Laser Pointer Callback --------------------
    public void OnPointerIn(object sender, OoniPointerEventArgs e)
    {
        // prepare to grab

        // ignore if already grabbing something
        if (grabSomething)
        {
            return;
        }

        // ignore if already stretching something
        if (inStretchMode)
        {
            return;
        }

        // if it's Art
        if (e.targetCollider.CompareTag("Art"))
        {
            if (currArt == null)
            {
                GameObject c_art = e.targetCollider.gameObject;
                m_CurrentInteractible = c_art.GetComponent <VRInteractiveObject> ();

                // if this Art is already being lasered
                if (m_CurrentInteractible.IsLasering)
                {
                    // Stretch mode!
                    inStretchMode = true;
                    stretchObj    = c_art;
                    originalScale = stretchObj.transform.localScale;

                    // distance between two lasers: 1.targetPos, 2.hitpoint
                    currLasersDistance = prevLasersDistance = (e.hitPoint - e.target.position).sqrMagnitude;
                    //Debug.Log ("pointer onto art & stretch start!");
                }
                else
                {
                    // Grab mode!
                    m_CurrentInteractible.LaserDown(laserPointer);

                    // Let laser shoot through Art
                    // v.1
                    // e.targetCollider.enabled = false;
                    //v.2
                    laserPointer.OnToArt = true;

                    currArt = e.target.gameObject;

                    if (prevArt != currArt)
                    {
                        posPercentage = 1f;
                    }

                    grabSomething = true;
                    //Debug.Log ("pointer onto art & grab start!");
                }

                laserPointer.DeviceVibrate();
            }
        }
    }