예제 #1
0
    // Update is called once per frame
    async void Update()
    {
        GvrPointerInputModule.Pointer = GvrLaserPointer;

        transform.GetChild(0).localScale = Vector3.zero;

        var device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);

        var otherCardSelected = BoardManager.AnyCardsSelected();

        if (Selected ||
            (GvrLaserPointer.CurrentRaycastResult.gameObject != null &&
             GvrLaserPointer.CurrentRaycastResult.gameObject == gameObject &&
             !otherCardSelected))
        {
            transform.GetChild(0).localScale = Vector3.one;

            if (device.GetButtonUp(GvrControllerButton.TouchPadButton))
            {
                Selected = true;
            }
        }

        if (Selected)
        {
            var deviceWorldPosition = Player.transform.TransformPoint(device.Position);

            if (!wasSelected)
            {
                distance = Vector3.Distance(deviceWorldPosition, transform.position);

                wasSelected = true;

                GetComponent <Rigidbody>().detectCollisions = false;
            }

            transform.position = GvrLaserPointer.GetPointAlongPointer(distance) + new Vector3(0, -0.5f, 0);

            distance = Mathf.Lerp(distance, 3.0f, Time.deltaTime * 2);

            if (GvrLaserPointer.CurrentRaycastResult.gameObject != null &&
                GvrLaserPointer.CurrentRaycastResult.gameObject.tag == SWIM_LANE_TAG &&
                device.GetButtonUp(GvrControllerButton.TouchPadButton))
            {
                await CardClient.MoveCardAsync(cardModel, GvrLaserPointer.CurrentRaycastResult.gameObject.GetComponent <SwimLane>().SwimLaneModel);
            }
        }
        else if (!otherCardSelected)
        {
            wasSelected = false;
        }
    }
예제 #2
0
    private void SetMenuLocation()
    {
        Vector3 laserEndPt = laserPointer.GetPointAlongPointer(menuDistance);

        // Center and orient the menu
        menuCenter = laserEndPt;
        Vector3 headRight = Camera.main.transform.right;

        headRight.y = 0.0f;
        headRight.Normalize();
        Vector3 cameraCenter  = Camera.main.transform.position;
        Vector3 rayFromCamera = (laserEndPt - cameraCenter).normalized;
        Vector3 up            = Vector3.Cross(rayFromCamera, headRight);

        menuOrientation = Quaternion.LookRotation(rayFromCamera, up);
    }
예제 #3
0
        private Vector3 GetBrushPosition()
        {
            GvrLaserPointer pointer = GvrPointerInputModule.Pointer as GvrLaserPointer;

            if (pointer == null)
            {
                return(Vector3.zero);
            }

            Vector3 pointerEndPoint;

            if (pointer.CurrentRaycastResult.gameObject != null)
            {
                pointerEndPoint = pointer.CurrentRaycastResult.worldPosition;
            }
            else
            {
                pointerEndPoint = pointer.GetPointAlongPointer(pointer.defaultReticleDistance);
            }

            Vector3 result = transform.InverseTransformPoint(pointerEndPoint);

            return(result);
        }
예제 #4
0
        private void SetMenuLocation()
        {
            Vector3 laserEndPt = laserPointer.GetPointAlongPointer(menuDistance);

            /* // Get the position and orientation from the arm model.
             * Vector3 pointerPosition = laserPointer.transform.position;
             * Vector3 ray = laserPointer.transform.rotation * Vector3.forward;
             *
             * // Calculate the intersection of the point with the head sphere.
             * laserEndPt = pointerPosition + ray * menuDistance;*/

            // Center and orient the menu
            menuCenter = laserEndPt;

            Vector3 headRight = Camera.main.transform.right;

            headRight.y = 0.0f;
            headRight.Normalize();
            Vector3 cameraCenter  = Camera.main.transform.position;
            Vector3 rayFromCamera = (laserEndPt - cameraCenter).normalized;
            Vector3 up            = Vector3.Cross(rayFromCamera, headRight);

            menuOrientation = Quaternion.LookRotation(rayFromCamera, up);
        }