void UpdateReticle(GameObject previousGazedObject)
    {
        if (gazePointer == null)
        {
            return;
        }

        Camera     camera               = pointerData.enterEventCamera; // Get the camera
        GameObject gazeObject           = GetCurrentGameObject();       // Get the gaze target
        Vector3    intersectionPosition = GetIntersectionPosition();
        bool       isInteractive        = pointerData.pointerPress != null ||
                                          ExecuteEvents.GetEventHandler <IPointerClickHandler>(gazeObject) != null;

        if (gazeObject == previousGazedObject)
        {
            if (gazeObject != null)
            {
                gazePointer.OnGazeStay(camera, gazeObject, intersectionPosition, isInteractive);
            }
        }
        else
        {
            if (previousGazedObject != null)
            {
                gazePointer.OnGazeExit(camera, previousGazedObject);
            }

            if (gazeObject != null)
            {
                gazePointer.OnGazeStart(camera, gazeObject, intersectionPosition, isInteractive);
            }
        }
    }
Esempio n. 2
0
 public void OnGazeStart(Camera camera, GameObject targetObject, Vector3 intersectionPosition, bool isInteractive)
 {
     GazePointer.OnGazeStart(camera, targetObject, intersectionPosition, isInteractive);
     if (isInteractive)
     {
         Target = targetObject;
     }
     else
     {
         Target = null;
     }
 }
Esempio n. 3
0
    private void HandleGaze()
    {
        // Retrieve GazePointer radius.
        float innerRadius = 0.0f;
        float outerRadius = 0.0f;

        if (pointer != null)
        {
            pointer.GetPointerRadius(out innerRadius, out outerRadius);
        }

        // Find what object the user is looking at.
        Vector3           intersectPosition;
        IGvrGazeResponder target       = null;
        GameObject        targetObject = FindGazeTarget(innerRadius, out target, out intersectPosition);

        // Found a target?
        if (targetObject != null)
        {
            lastIntersectPosition = intersectPosition;

            // Is the object new?
            if (targetObject != currentGazeObject)
            {
                if (pointer != null)
                {
                    pointer.OnGazeExit(cam, currentGazeObject);
                }
                if (currentTarget != null)
                {
                    // Replace with current object.
                    currentTarget.OnGazeExit();
                }

                // Save new object.
                currentTarget     = target;
                currentGazeObject = targetObject;

                // Inform pointer and target of gaze.
                if (pointer != null)
                {
                    pointer.OnGazeStart(cam, currentGazeObject, intersectPosition,
                                        currentTarget != null);
                }
                if (currentTarget != null)
                {
                    currentTarget.OnGazeEnter();
                }
            }
            else
            {
                // Same object, inform pointer of new intersection.
                if (pointer != null)
                {
                    pointer.OnGazeStay(cam, currentGazeObject, intersectPosition,
                                       currentTarget != null);
                }
            }
        }
        else
        {
            // Failed to find an object by inner radius.
            if (currentGazeObject != null)
            {
                // Already gazing an object? Check against outer radius.
                if (IsGazeNearObject(outerRadius, currentGazeObject, out intersectPosition))
                {
                    // Still gazing.
                    if (pointer != null)
                    {
                        pointer.OnGazeStay(cam, currentGazeObject, intersectPosition, currentTarget != null);
                    }
                }
                else
                {
                    // No longer gazing any object.
                    if (pointer != null)
                    {
                        pointer.OnGazeExit(cam, currentGazeObject);
                    }
                    if (currentTarget != null)
                    {
                        currentTarget.OnGazeExit();
                    }
                    currentTarget     = null;
                    currentGazeObject = null;
                }
            }
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        //find out the connection status of the controller

        //test code

        //all controller input
        controllerOR            = GvrController.Orientation;
        appButtonPressDown      = GvrController.AppButtonDown;
        touchpaddown            = GvrController.TouchDown;
        clickpress              = GvrController.ClickButton;
        clickPressDown          = GvrController.ClickButtonDown;
        clickpressup            = GvrController.ClickButtonUp;
        appbuttoncontinuedpress = GvrController.AppButton;
        touchpadcontinuedpress  = GvrController.IsTouching;
        //old code isn't used


        //touchpad
        touchpadxy = GvrController.TouchPos;
        //movement
        controlleraccel = GvrController.Accel;
        //controller orientation
        maincontrol.localRotation = controllerOR;


        //raycast
        //	Debug.DrawRay(diamondfrontpoint.position,diamondfrontpoint.forward * Mathf.Infinity,Color.red,.5f);

        if (Physics.Raycast(diamondfrontpoint.position, diamondfrontpoint.forward, out rhit, raydistance, pmask) && areaready)
        {
            hit = rhit.transform;
            raybox.SetActive(true);
            hitdistance = rhit.distance;
            lookedatobj = hit.gameObject;
            point       = rhit.point;
            raybox.transform.position   = (raybox.transform.parent.transform.position + point.Value) / 2f;
            raybox.transform.localScale = new Vector3(raybox.transform.localScale.x, raybox.transform.localScale.y, Vector3.Distance(diamondfrontpoint.position, point.Value));

            //testing with gaze input
            gazer.OnGazeStart(GetComponent <Camera>(), hit.gameObject, rhit.point, true);
        }
        else
        {
            raybox.SetActive(false);
            point       = null;
            hit         = null;
            lookedatobj = null;
        }
        //raycast

        if (newimputsystem)
        {
            if (clickPressDown && hit != null)
            {
                switch (hit.tag)
                {
                case "element":
                    currentrecmat = newrecmat;
                    elementcollector(hit);
                    break;

                case "corecenter":
                    currentrecmat = newrecmat;
                    elementcenter(hit);
                    break;

                case "cellholeloc":
                    cellholecenterlocaction(hit);
                    break;

                case "bulb":
                    currentrecmat = newrecmat;
                    bulblookat(hit);
                    break;

                case "jumppoint":
                    newlocationjump(hit);
                    break;

                case "outsphere":
                    gotocell(hit);
                    break;

                case "returner":
                    leavecell(hit);
                    break;

                case "enemy":
                    positiveshot(hit);
                    break;

                case "helperA":
                    positiveshot(hit);
                    break;

                case "gatherer":
                    startGatheringObjs(hit);
                    break;

                case "rotator":
                    startRotateCell(hit);
                    break;

                case "UIexit":
                    stopRotateCell(hit);
                    break;
                }
            }

            if (appButtonPressDown && hit != null)
            {
                switch (hit.tag)
                {
                case "cell":
                    celloptionaction(hit);
                    break;
                }
            }

            if (touchpadcontinuedpress && hit != null && !clickPressDown)
            {
                touchingTouchPadtime += Time.deltaTime;
                if (touchingTouchPadtime > touchingTouchPadTimeLimit)
                {
                    switch (hit.tag)
                    {
                    case "element":
                        elementcleansing(hit);
                        break;

                    case "corecenter":
                        touchpadactioncenterobj();
                        break;
                    }
                }
            }
        }
        else
        {
            if (appButtonPressDown && hit != null)
            {
                switch (hit.tag)
                {
                case "element":
                    elementcollector(hit);
                    break;

                case "corecenter":
                    elementcenter(hit);
                    break;

                case "cellholeloc":
                    cellholecenterlocaction(hit);
                    break;

                case "bulb":
                    bulblookat(hit);
                    break;

                case "jumppoint":
                    newlocationjump(hit);
                    break;

                case "outsphere":
                    gotocell(hit);
                    break;

                case "returner":
                    leavecell(hit);
                    break;

                case "enemy":
                    positiveshot(hit);
                    break;

                case "helperA":
                    positiveshot(hit);
                    break;

                case "gatherer":

                    break;

                case "rotator":

                    break;

                case "UIexit":

                    break;
                }
            }

            if (clickpress && hit != null)
            {
                switch (hit.tag)
                {
                case "cell":
                    cellrotation(rhit.point, hit);
                    break;
                }
            }

            if (clickpressup && hit != null)
            {
                switch (hit.tag)
                {
                case "cell":
                    resetcellrotation(hit);
                    break;
                }
            }

            if (touchpaddown && hit != null)
            {
                switch (hit.tag)
                {
                case "element":
                    elementcleansing(hit);
                    break;

                case "corecenter":
                    touchpadactioncenterobj();
                    break;
                }
            }
        }
    }