private void Awake()
        {
            if (GetComponent<VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractUse is required to be attached to a SteamVR Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch = GetComponent<VRTK_InteractTouch>();
            controllerActions = GetComponent<VRTK_ControllerActions>();
        }
Exemplo n.º 2
0
    private void DoObjectGrab(object sender, InteractableObjectEventArgs e)
    {
        if (e.interactingObject == controllers.left)
        {
            holdControl = controllers.left.GetComponent<VRTK_ControllerEvents>();
            stringControl = controllers.right.GetComponent<VRTK_ControllerEvents>();

            holdActions = controllers.left.GetComponent<VRTK_ControllerActions>();
            stringActions = controllers.right.GetComponent<VRTK_ControllerActions>();
        }
        else
        {
            stringControl = controllers.left.GetComponent<VRTK_ControllerEvents>();
            holdControl = controllers.right.GetComponent<VRTK_ControllerEvents>();

            stringActions = controllers.left.GetComponent<VRTK_ControllerActions>();
            holdActions = controllers.right.GetComponent<VRTK_ControllerActions>();
        }
        StartCoroutine("GetBaseRotation");
    }
    private void Start()
    {
        if (GetComponent<VRTK_ControllerEvents>() == null)
        {
            Debug.LogError("VRTK_ControllerEvents_ListenerExample is required to be attached to a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
            return;
        }

        events = GetComponent<VRTK_ControllerEvents>();
        actions = GetComponent<VRTK_ControllerActions>();
        tooltips = GetComponentInChildren<VRTK_ControllerTooltips>();

        //Setup controller event listeners
        events.TriggerPressed += new ControllerInteractionEventHandler(DoTriggerPressed);
        events.TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);

        events.ApplicationMenuPressed += new ControllerInteractionEventHandler(DoApplicationMenuPressed);
        events.ApplicationMenuReleased += new ControllerInteractionEventHandler(DoApplicationMenuReleased);

        events.GripPressed += new ControllerInteractionEventHandler(DoGripPressed);
        events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased);

        events.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadPressed);
        events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased);

        tooltips.ShowTips(false);
    }
Exemplo n.º 4
0
 public override void Grabbed(GameObject grabbingObject)
 {
     base.Grabbed(grabbingObject);
     controllerActions = grabbingObject.GetComponent<VRTK_ControllerActions>();
 }
 private void Awake()
 {
     controllerEvents = GetComponent<VRTK_ControllerEvents>();
     controllerActions = GetComponent<VRTK_ControllerActions>();
     Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);
     destroyColliderOnDisable = false;
     defaultColliderPrefab = Resources.Load("ControllerColliders/HTCVive");
 }
 private void Awake()
 {
     trackedController = GetComponent<SteamVR_TrackedObject>();
     controllerActions = GetComponent<VRTK_ControllerActions>();
 }
Exemplo n.º 7
0
 private void Awake()
 {
     trackedController = GetComponent <SteamVR_TrackedObject>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
 }
Exemplo n.º 8
0
 protected virtual void Awake()
 {
     interactTouch     = GetComponent <VRTK_InteractTouch>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
     controllerEvents  = GetComponent <VRTK_ControllerEvents>();
 }
Exemplo n.º 9
0
    void Update()
    {
        // calcul de la progression du fondu au noir
        float oldProgression = blackoutProgression;

        if (viewmasterObject.IsGrabbed())
        {
            float distance = 999;
            foreach (Transform anchorPoint in viewmasterObjectAnchors)
            {
                distance = Mathf.Min(distance, Vector3.Distance(anchorPoint.position, Camera.main.transform.position));
            }
            float range = maxDistance - minDistance;
            blackoutProgression = (distance - minDistance) / range;
        }
        else
        {
            blackoutProgression += Time.deltaTime;
        }
        blackoutProgression = Mathf.Clamp(blackoutProgression, 0, 1);
        Color matCol = blackoutMesh.material.color;

        matCol.a = 1 - blackoutProgression * .9f;
        blackoutMesh.material.color = matCol;

        renderCam.enabled = blackoutProgression <= 1;
        if (blackoutProgression < 1 && oldProgression >= 1)
        {
            // calcul de la position de l'image en fonction de la tête du joueur
            portraitOrientation.localPosition = renderCam.transform.localPosition + new Vector3(0, -.1f, 0);
            portraitOrientation.localRotation = Quaternion.Euler(
                portraitOrientation.localEulerAngles.x,
                renderCam.transform.localEulerAngles.y,
                portraitOrientation.localEulerAngles.z);
            // désactivation TP
            teleportHandler.enabled = false;
        }
        else if (blackoutProgression >= 1 && oldProgression < 1)
        {
            teleportHandler.enabled = true;
        }

        // calcul de la progression du fondu de l'image
        if (blackoutProgression <= 0)
        {
            canvasProgression += Time.deltaTime;
        }
        else
        {
            canvasProgression -= Time.deltaTime * 7;
        }

        canvasProgression    = Mathf.Clamp(canvasProgression, 0, 1);
        portraitsGroup.alpha = canvasProgression;

        if (blackoutProgression <= 0)
        {
            float angleBetweenPictures = 30;
            if (currentClip != null)
            {
                angleBetweenPictures = 180f / currentClip.images.Length;
            }
            // float angleBetweenPictures = 30; // à n'utiliser que si l'autre n'est pas assez intuitif

            GameObject grabbingObj = viewmasterObject.GetGrabbingObject();
            if (grabbingObj != null)
            {
                VRTK.VRTK_ControllerEvents eventCtrl = grabbingObj.GetComponent <VRTK.VRTK_ControllerEvents>();
                lastControllerActions = grabbingObj.GetComponent <VRTK.VRTK_ControllerActions>();
                if (eventCtrl != null)
                {
                    // on est en train de visionner l'image, on récupère la manette en train de tenir le VM afin de récupérer les swipes sur le pavé tactile
                    eventCtrl.axisFidelity = 5;
                    bool wasPressing = pressingButton;
                    pressingButton = eventCtrl.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.Touchpad_Touch);
                    if (pressingButton && !wasPressing)
                    {
                        lastRotation = eventCtrl.GetTouchpadAxisAngle();
                    }
                    float trigger = eventCtrl.GetTriggerAxis();
                    if (trigger != 1)
                    {
                        ignoreTrigger = false;
                    }
                    if (trigger == 1 && !ignoreTrigger)
                    {
                        ignoreTrigger         = true;
                        autoMoveToNextPicture = true;
                        StartCoroutine(TriggerHapticCoroutine());
                    }
                    if (pressingButton && trigger == 0 && false)
                    {
                        float oldPortraitRotation = currentPortraitRotation;
                        // en train de faire un swipe
                        float currentPadRotation = eventCtrl.GetTouchpadAxisAngle();
                        if (lastRotation - currentPadRotation < 180 && lastRotation - currentPadRotation > -180)
                        {
                            currentPortraitRotation += (lastRotation - currentPadRotation) * rotateSensitivity;
                        }
                        if (lastControllerActions != null && ((int)(currentPadRotation) / 35) != ((int)(lastRotation) / 35))
                        {
                            lastControllerActions.TriggerHapticPulse(.05f);
                        }
                        if (currentPortraitRotation > angleBetweenPictures / 2 && oldPortraitRotation < angleBetweenPictures / 2)
                        {
                            StartCoroutine(TriggerHapticCoroutine());
                        }
                        if (currentPortraitRotation < -angleBetweenPictures / 2 && oldPortraitRotation > -angleBetweenPictures / 2)
                        {
                            StartCoroutine(TriggerHapticCoroutine());
                        }
                        lastRotation = currentPadRotation;
                    }
                }
            }

            if (!pressingButton || autoMoveToNextPicture)
            {
                if (autoMoveToNextPicture)
                {
                    currentPortraitRotation += Time.deltaTime * (angleBetweenPictures + .01f - currentPortraitRotation) * 10;
                }
                else
                {
                    // retour à l'image la plus proche
                    if (currentPortraitRotation > angleBetweenPictures / 2)
                    {
                        currentPortraitRotation += Time.deltaTime * (angleBetweenPictures + .01f - currentPortraitRotation) * 10;
                    }
                    else if (currentPortraitRotation < -angleBetweenPictures / 2)
                    {
                        currentPortraitRotation += Time.deltaTime * -(angleBetweenPictures + .01f + currentPortraitRotation) * 10;
                    }
                    else
                    {
                        currentPortraitRotation -= Time.deltaTime * currentPortraitRotation * 10;
                    }
                }
            }

            if (currentPortraitRotation > angleBetweenPictures)
            {
                currentPortraitRotation -= angleBetweenPictures;
                nextImage();
            }
            if (currentPortraitRotation < -angleBetweenPictures)
            {
                currentPortraitRotation += angleBetweenPictures;
                previousImage();
            }

            // rotation de l'image
            leftImageTransform.transform.localRotation      = Quaternion.Euler(0, 0, currentPortraitRotation);
            rightImageTransform.transform.localRotation     = Quaternion.Euler(0, 0, currentPortraitRotation);
            leftImageTransformNext.transform.localRotation  = Quaternion.Euler(0, 0, currentPortraitRotation + angleBetweenPictures);
            leftImageTransformPrev.transform.localRotation  = Quaternion.Euler(0, 0, currentPortraitRotation - angleBetweenPictures);
            rightImageTransformNext.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation + angleBetweenPictures);
            rightImageTransformPrev.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation - angleBetweenPictures);
        }
        else
        {
            // rotation du disque du grabbable, pas de la vue.

            GameObject grabbingObj = viewmasterObject.GetGrabbingObject();
            if (grabbingObj != null)
            {
                VRTK.VRTK_ControllerEvents eventCtrl = grabbingObj.GetComponent <VRTK.VRTK_ControllerEvents>();
                lastControllerActions = grabbingObj.GetComponent <VRTK.VRTK_ControllerActions>();
                if (eventCtrl != null)
                {
                    // on est en train de visionner l'image, on récupère la manette en train de tenir le VM afin de récupérer les swipes sur le pavé tactile
                    eventCtrl.axisFidelity = 5;
                    bool wasPressing = pressingButton;
                    pressingButton = eventCtrl.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.Touchpad_Touch);
                    if (pressingButton && !wasPressing)
                    {
                        lastRotation = eventCtrl.GetTouchpadAxisAngle();
                    }
                    if (pressingButton && false)
                    {
                        // en train de faire un swipe
                        float currentPadRotation = eventCtrl.GetTouchpadAxisAngle();
                        if (lastRotation - currentPadRotation < 180 && lastRotation - currentPadRotation > -180)
                        {
                            currentClipRotation += (lastRotation - currentPadRotation) * rotateSensitivity;
                        }
                        if (lastControllerActions != null && ((int)(currentPadRotation) / 275) != ((int)(lastRotation) / 275))
                        {
                            triggerAnimator.SetTrigger("Trigger");
                        }
                        lastRotation = currentPadRotation;

                        viewmasterGrabbableClipRotation.transform.localRotation = Quaternion.Euler(currentClipRotation, 0, 0);
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
 private void Awake()
 {
     interactTouch     = GetComponent <VRTK_InteractTouch>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
     controllerEvents  = GetComponent <VRTK_ControllerEvents>();
 }
        private void Awake()
        {
            controllerActions = transform.parent.GetComponent<VRTK_ControllerActions>();
            triggerInitialised = false;
            gripInitialised = false;
            touchpadInitialised = false;
            appMenuInitialised = false;

            availableButtons = new TooltipButtons[]
            {
                TooltipButtons.TriggerTooltip,
                TooltipButtons.GripTooltip,
                TooltipButtons.TouchpadTooltip,
                TooltipButtons.AppMenuTooltip
            };

            buttonTooltips = new GameObject[availableButtons.Length];
            tooltipStates = new bool[availableButtons.Length];

            for (int i = 0; i < availableButtons.Length; i++)
            {
                buttonTooltips[i] = transform.FindChild(availableButtons[i].ToString()).gameObject;
            }

            InitialiseTips();
        }