Пример #1
0
        public override void Grabbed(GameObject currentGrabbingObject)
        {
            base.Grabbed(currentGrabbingObject);

            controllerEvents = currentGrabbingObject.GetComponent<VRTK_ControllerEvents>();
            controllerActions = currentGrabbingObject.GetComponent<VRTK_ControllerActions>();

            ToggleSlide(true);
            ToggleSafetySwitch(true);

            //Limit hands grabbing when picked up
            if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject) == VRTK_DeviceFinder.ControllerHand.Left)
            {
                allowedTouchControllers = AllowedController.Left_Only;
                allowedUseControllers = AllowedController.Left_Only;
                slide.allowedGrabControllers = AllowedController.Right_Only;
                safetySwitch.allowedGrabControllers = AllowedController.Right_Only;
            }
            else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject) == VRTK_DeviceFinder.ControllerHand.Right)
            {
                allowedTouchControllers = AllowedController.Right_Only;
                allowedUseControllers = AllowedController.Right_Only;
                slide.allowedGrabControllers = AllowedController.Left_Only;
                safetySwitch.allowedGrabControllers = AllowedController.Left_Only;
            }
        }
Пример #2
0
        public override void Ungrabbed(GameObject previousGrabbingObject)
        {
            base.Ungrabbed(previousGrabbingObject);

            ToggleSlide(false);
            ToggleSafetySwitch(false);

            //Unlimit hands
            allowedTouchControllers = AllowedController.Both;
            allowedUseControllers = AllowedController.Both;
            slide.allowedGrabControllers = AllowedController.Both;
            safetySwitch.allowedGrabControllers = AllowedController.Both;

            controllerEvents = null;
            controllerActions = null;
        }
Пример #3
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");
    }
Пример #4
0
    private void OnCollisionEnter(Collision collision)
    {
        VRTK_ControllerEvents events = collision.gameObject.GetComponent <VRTK_ControllerEvents>();

        controllerReference = VRTK_ControllerReference.GetControllerReference(events.gameObject);

        collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *impactMagnifier;
        var hapticStrength = collisionForce / maxCollisionForce;

        VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticStrength, 0.1f, 0.05f);
        float collisionMidi = ModelUtility.Remap(collisionForce, 0, 100, 70, 127);

        List <float> pianoData = new List <float>();

        pianoData.Add(midiNote);
        pianoData.Add(collisionMidi);

        OSCHandler.Instance.SendMessageToClient("myClient", "/pianoKey/" + keyNumber, pianoData);
        textComponent.text = "/pianoKey/" + keyNumber + ", " + midiNote + " , " + collisionMidi;
    }
Пример #5
0
        private void DoObjectGrab(object sender, InteractableObjectEventArgs e)
        {
            if (VRTK_SDK_Bridge.IsControllerLeftHand(e.interactingObject))
            {
                holdControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent<VRTK_ControllerEvents>();
                stringControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerEvents>();

                holdActions = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent<VRTK_ControllerActions>();
                stringActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerActions>();
            }
            else
            {
                stringControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent<VRTK_ControllerEvents>();
                holdControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerEvents>();

                stringActions = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent<VRTK_ControllerActions>();
                holdActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerActions>();
            }
            StartCoroutine("GetBaseRotation");
        }
Пример #6
0
        private void DoObjectGrab(object sender, InteractableObjectEventArgs e)
        {
            if (VRTK_DeviceFinder.IsControllerLeftHand(e.interactingObject))
            {
                holdControl   = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
                stringControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

                holdActions   = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>();
                stringActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>();
            }
            else
            {
                stringControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
                holdControl   = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

                stringActions = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>();
                holdActions   = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>();
            }
            StartCoroutine("GetBaseRotation");
        }
Пример #7
0
        /**
         * {
         *
         * GameObject newpoint = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         * newpoint.transform.localScale = new Vector3(0.015f, 0.015f, 0.015f);
         * newpoint.transform.position = sphere.transform.position;
         * //newpoint.AddComponent<CloudChildCounter>();
         * newpoint.AddComponent<VRObjectCounter>();
         * GameObject text_object = new GameObject("Text");
         * text_object.transform.SetParent(newpoint.transform);
         * text_object.AddComponent<MeshRenderer>();
         * text_object.AddComponent<TextMesh>();
         * text_object.GetComponent<TextMesh>().text = id.ToString();
         * text_object.GetComponent<TextMesh>().anchor = TextAnchor.MiddleCenter;
         * text_object.GetComponent<TextMesh>().color = Color.red;
         *
         * text_object.transform.localPosition = Vector3.zero;
         * text_object.AddComponent<StaringLabel>();
         * text_object.transform.localScale = Vector3.one * 0.5f;
         * return newpoint;
         *
         * }
         **/
        public override void OnToolDeactivated()
        {
            objectplacementCanvas.SetActive(false);
            containerselectionCanvas.SetActive(false);

            CloudSelector.instance.OnSelectionChange -= ReloadContainers;
            CloudStorage.instance.OnCloudCreated     -= ReloadContainers;

            //TEst Feature
            Debug.Log("Test Feature OBjectPlamcement TOOl");
            int[] keys = new int[containersList.Count];
            containersList.Keys.CopyTo(keys, 0);
            foreach (var i in keys)
            {
                if (containersList[i].GetObjectCount() == 0)
                {
                    Destroy(containersList[i].gameObject);

                    containersList.Remove(i);
                }
            }

            //containersList.Clear();
            if (sphere != null)
            {
                Destroy(sphere);
            }

            if (_controller)
            {
                _controller.TouchpadPressed  -= OnTriggerClicked;
                _controller.TouchpadReleased -= OnTriggerReleased;
                _controller = null;
            }

            if (selectedGO)
            {
                selectedGO.GetComponent <VRObject>().OnUnselected();
                selectedGO = null;
            }
        }
Пример #8
0
        public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
        {
            base.Grabbed(currentGrabbingObject);

            controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();

            if (OVRInput.GetActiveController() != OVRInput.Controller.Touchpad)
            {
                //Limit hands grabbing when picked up
                if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
                {
                    allowedTouchControllers = AllowedController.LeftOnly;
                    allowedUseControllers   = AllowedController.LeftOnly;
                }
                else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
                {
                    allowedTouchControllers = AllowedController.RightOnly;
                    allowedUseControllers   = AllowedController.RightOnly;
                }
            }
        }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
#if UNITY_EDITOR_WIN
#else
        if (handController == null)
        {
            handController = GameObject.Find(handName);
        }

        if (handController != null)
        {
            if (controllerEvents == null)
            {
                controllerEvents = handController.transform.GetChild(2).GetComponent <VRTK_ControllerEvents>();
            }
            Debug.Log($"ControllerEvents {controllerEvents}");
            handController.transform.position = transform.position;
            //handController.transform.rotation = transform.rotation;
        }
#endif
    }
Пример #10
0
    public override void Ungrabbed(VRTK_InteractGrab previousGrabbingObject)
    {
        base.Ungrabbed(previousGrabbingObject);

        slideCollider.enabled = false;

        if (ammoTooltipGameObject != null)
        {
            ammoTooltipGameObject.SetActive(false);
        }

        ToggleSlide(false);

        slide.reloadAction -= Reloaded;

        allowedTouchControllers      = AllowedController.Both;
        allowedUseControllers        = AllowedController.Both;
        slide.allowedGrabControllers = AllowedController.Both;

        controllerEvents = null;
    }
Пример #11
0
    void OnEnable()
    {
        try {
            leftctrl = VRTK_DeviceFinder.GetControllerLeftHand();
        } catch (Exception e) {
            Debug.Log(e);
        }

        if (leftctrl == null)
        {
            leftctrl = GameObject.FindGameObjectWithTag("LeftController");
        }


        pointer   = leftctrl.GetComponent <VRTK_Pointer>();
        uiPointer = leftctrl.GetComponent <VRTK_UIPointer>();
        bezeierPointerRenderer  = leftctrl.GetComponent <VRTK_BezierPointerRenderer>();
        straightPointerRenderer = leftctrl.GetComponent <VRTK_StraightPointerRenderer>();
        //straightPointerRenderer = leftctrl.GetComponent<Custom_VRTK_UIStraightPointerRenderer>();
        controllerEvents = leftctrl.GetComponent <VRTK_ControllerEvents>();
    }
Пример #12
0
    void Start()
    {
        valueF         = 0f;
        _objectIsHuman = false;
        _hasChosen     = false;
        string temp = "34.50";

        isPulling = false;
        //toggle = false;
        GameObject vrtkScripts = GameObject.FindGameObjectWithTag(VRTKSCRIPT);

        leftController  = vrtkScripts.transform.Find(LCONTR);
        rightController = vrtkScripts.transform.Find(RCONTR);
        leftEvents      = leftController.GetComponent <VRTK_ControllerEvents>();
        rightEvents     = rightController.GetComponent <VRTK_ControllerEvents>();
        sInjection      = leftController.GetComponent <SelectInjection>(); //the selectionInjection script should be always and ONLY on the left controller

        snapDrop           = this.GetComponentInChildren <VRTK_SnapDropZone>().transform;
        lcdText            = this.GetComponentInChildren <Text>();
        lcdCanvas          = this.GetComponentInChildren <Canvas>().transform;
        insideSyringe      = this.transform.GetChild(0).Find(INSIDESYRINGE);
        fillWater          = this.transform.GetChild(0).Find(FILLWATER);
        dAttraction        = this.transform.GetChild(0).GetComponent <DirectionAttraction>();
        beginPosition      = insideSyringe.localPosition;
        beginPositionWater = fillWater.localPosition;
        interactScript     = GetComponent <VRTK_InteractableObject>();

        lcdCanvas.gameObject.SetActive(false);

        interactScript.InteractableObjectUsed      += new InteractableObjectEventHandler(ObjectUsed);
        interactScript.InteractableObjectUnused    += new InteractableObjectEventHandler(ObjectUnused);
        interactScript.InteractableObjectGrabbed   += new InteractableObjectEventHandler(ObjectGrabbed);
        interactScript.InteractableObjectUngrabbed += new InteractableObjectEventHandler(ObjectUngrabbed);

        leftEvents.TouchpadPressed   += new ControllerInteractionEventHandler(LeftTouchpadPressed);
        leftEvents.TouchpadReleased  += new ControllerInteractionEventHandler(LeftTouchpadReleased);
        rightEvents.TouchpadPressed  += new ControllerInteractionEventHandler(RightTouchpadPressed);
        rightEvents.TouchpadReleased += new ControllerInteractionEventHandler(RightTouchpadReleased);
    }
Пример #13
0
    private void OnEnable()
    {
        controllerEvents = GetComponent <VRTK_ControllerEvents>();
        if (controllerEvents == null)
        {
            VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same"));
            return;
        }

        //Setup controller event listeners
        controllerEvents.TriggerPressed += DoTriggerPressed;

        controllerEvents.ButtonOnePressed  += DoButtonOnePressed;
        controllerEvents.ButtonOneReleased += DoButtonOneReleased;

        controllerEvents.ButtonTwoPressed  += DoButtonTwoPressed;
        controllerEvents.ButtonTwoReleased += DoButtonTwoReleased;

        controllerEvents.ControllerEnabled      += DoControllerEnabled;
        controllerEvents.ControllerDisabled     += DoControllerDisabled;
        controllerEvents.ControllerIndexChanged += DoControllerIndexChanged;
    }
Пример #14
0
    void Update()
    {
        Transform leftT   = leftController.GetComponent(typeof(Transform)) as Transform;
        Transform rightT  = rightController.GetComponent(typeof(Transform)) as Transform;
        Transform buttonT = button.GetComponent(typeof(Transform)) as Transform;

        VRTK_ControllerEvents leftControllerEvents = leftController.GetComponent <VRTK_ControllerEvents>();

        if (Vector3.Distance(rightT.position, buttonT.position) <= .1 || Vector3.Distance(leftT.position, buttonT.position) <= .1)
        {
            if (_startPressed == false)
            {
                _startPressed = true;
                StartCoroutine(turnOnLights());
            }
            startButtonAnim.SetBool("Press", true);
        }
        else
        {
            startButtonAnim.SetBool("Press", false);
        }
    }
Пример #15
0
    // Start is called before the first frame update
    public void OnEnable()
    {
        useGun = false;

        info     = GameObject.Find("[INFO]").GetComponent <Info_Manager>();
        saveload = GameObject.Find("[SAVELOAD]").GetComponent <SaveLoad>();

        // Controller Events
        _events = GetComponent <VRTK_ControllerEvents>();
        _events.TriggerPressed  += onTriggerPressed;
        _events.TriggerReleased += onTriggerReleased;

        _events.GripPressed  += onGripPressed;
        _events.GripReleased += onGripReleased;

        // Grab Events
        _grabEvent = GetComponent <VRTK_InteractGrab>();
        _grabEvent.ControllerGrabInteractableObject        += onGrabObject;
        _grabEvent.ControllerStartUngrabInteractableObject += onGrabObjectRelease;

        Debug.Log("events start");
    }
Пример #16
0
    /// <summary>
    /// Set up event listeners from Controller and Pointer
    /// <returns></returns>
    ///
    void Awake()
    {
        //VRTK_ControllerEvents controller;

        //Set up event listeners
        pointer = GetComponent <VRTK_Pointer>();
        pointer.DestinationMarkerEnter += Pointer_DestinationMarkerEnter;
        pointer.DestinationMarkerExit  += Pointer_DestinationMarkerExit;

        controller = GetComponent <VRTK_ControllerEvents>();
        controller.TriggerPressed      += Controller_TriggerPressed;
        controller.TriggerReleased     += Controller_TriggerReleased;
        controller.TouchpadAxisChanged += Controller_TouchpadAxisChanged;
        controller.TouchpadReleased    += Controller_TouchpadReleased;
        controller.TouchpadPressed     += Controller_TouchpadPressed;
        controller.GripClicked         += Controller_GripClicked;

        lineRenderer                 = gameObject.AddComponent <LineRenderer>();
        lineRenderer.material        = new Material(Shader.Find("Sprites/Default"));
        lineRenderer.widthMultiplier = 0.02f;
        lineRenderer.positionCount   = 2;
        bundle  = true;
        sizeRay = 1;
        lineRenderer.material.color = Color.green;


        helpTooltip = gameObject.transform.GetChild(0).GetComponent <VRTK_ControllerTooltips>();
        helpTooltip.ToggleTips(false);


        dataToolTip = gameObject.transform.GetChild(1).GetComponent <VRTK_ControllerTooltips>();
        dataToolTip.ToggleTips(false);


        //Anonymous function to Update the dataToolTip text.
        changeText = delegate(string x) {
            dataToolTip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, x);
        };
    }
    private void InteractableObjectUngrabbed(object sender, InteractableObjectEventArgs e)
    {
        if (!controllerEvents)
        {
            return;
        }

        if (teleportDisabler)
        {
            teleportDisabler.RemoveDisabler(controllerEvents, gameObject);
        }
        else
        {
            foreach (var teleporter in controllerEvents.GetComponentsInChildren <VRTK_Pointer>())
            {
                teleporter.enabled = true;
            }
        }

        controllerEvents.TouchpadPressed -= ControllerEvents_TriggerClicked;
        controllerEvents = null;
    }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        GameObject vrtkScripts = GameObject.FindGameObjectWithTag(VRTKSCRIPT);

        leftController  = vrtkScripts.transform.Find(LCONTR);
        rightController = vrtkScripts.transform.Find(RCONTR);
        leftEvents      = leftController.GetComponent <VRTK_ControllerEvents>();
        rightEvents     = rightController.GetComponent <VRTK_ControllerEvents>();
        tray            = leftControllerSteam.transform.Find(TRAY);

        leftModel  = leftControllerSteam.transform.Find(CNTRLMODEL);
        rightModel = rightControllerSteam.transform.Find(CNTRLMODEL);

        leftEvents.ButtonTwoPressed  += new ControllerInteractionEventHandler(LeftBtnTwo);
        rightEvents.ButtonTwoPressed += new ControllerInteractionEventHandler(RightBtnTwo);

        isLeft    = true;
        isEnabled = false;

        startPosition    = tray.localPosition;
        startEulerAngles = tray.localEulerAngles;
    }
Пример #19
0
    /// <summary>
    /// 初始時將方塊放置到控制器上
    /// </summary>
    /// <returns></returns>
    private IEnumerator SetCubeOnController()
    {
        yield return(new WaitForSeconds(0.1f));

        deviceName = VRTK_SDKManager.instance.loadedSetup.gameObject.name;
        if (deviceName == "VRSimulator")
        {
            Center.transform.parent = SimulatorRightHand.transform;
        }
        if (deviceName == "SteamVR")
        {
            Center.transform.parent = SteamVRRightHand.transform;
        }

        // 產生一個方塊
        GameObject centerCube = Create(new Vector3(0, 0, 0), Quaternion.identity);

        centerCube.GetComponent <Renderer>().material.mainTexture = CubeCreator.instance.Fill(Color.cyan);
        centerCube.name = "Cube0";
        Center.transform.localPosition = new Vector3(0, 0, 0);
        controllerEvents = (controllerEvents ? GameObject.FindObjectOfType <VRTK.VRTK_ControllerEvents>() : controllerEvents);
    }
Пример #20
0
    // Start is called before the first frame update
    public override void Start()
    {
        RControllerEvents = RController.GetComponent <VRTK_ControllerEvents>();
        LControllerEvents = LController.GetComponent <VRTK_ControllerEvents>();

        textScreens[0].SetActive(true);

        // turn on table and goggles
        table.SetActive(true);
        goggles.SetActive(true);

        // turn on components to grab
        RController.GetComponent <VRTK_InteractGrab>().enabled  = true;
        RController.GetComponent <VRTK_InteractTouch>().enabled = true;

        tableAnim.SetBool("on", true);
        gogglesAnim.SetBool("on", true);

        buttons.SetActive(true);

        isDone = false;
    }
Пример #21
0
 void Start()
 {
     clickable = true;
     reset     = true;
     if (startOpen == false)
     {
         menuOpen = false;
     }
     else
     {
         menuOpen = true;
     }
     leftController     = GameObject.Find("LeftController");
     rightController    = GameObject.Find("RightController");
     controllerEventsL  = leftController.GetComponent <VRTK_ControllerEvents> ();
     controllerEventsR  = rightController.GetComponent <VRTK_ControllerEvents> ();
     controllerActionsL = leftController.GetComponent <VRTK_ControllerActions> ();
     controllerActionsR = rightController.GetComponent <VRTK_ControllerActions> ();
     //controllerEventsL.SubscribeToButtonAliasEvent (VRTK_ControllerEvents.ButtonAlias.Button_Two_Press, true, MenuButtonPressed);
     //controllerEventsR.SubscribeToButtonAliasEvent (VRTK_ControllerEvents.ButtonAlias.Button_Two_Press, true, MenuButtonPressed);
     levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader> ();
 }
Пример #22
0
    private void ObjectGrabbed(object sender, InteractableObjectEventArgs e)
    {
        if (firstController != null)
        {
            return;
        }

        firstController = e.interactingObject;

        controllerEvents = e.interactingObject.GetComponent <VRTK_ControllerEvents>();

        if (VRTK_DeviceFinder.GetControllerHand(e.interactingObject) == SDK_BaseController.ControllerHand.Left)
        {
            interactableObject.allowedUseControllers = VRTK_InteractableObject.AllowedController.LeftOnly;
        }
        else if (VRTK_DeviceFinder.GetControllerHand(e.interactingObject) == SDK_BaseController.ControllerHand.Right)
        {
            interactableObject.allowedUseControllers = VRTK_InteractableObject.AllowedController.RightOnly;
        }

        controllerEvents.TouchpadPressed += TouchpadPressed;
    }
Пример #23
0
    //void SpawnDecal(RaycastHit hit)
    //{
    //    if (hit.collider.sharedMaterial != null)
    //    {
    //        string materialName = hit.collider.sharedMaterial.name;

    //        switch (materialName)
    //        {
    //            //case "Metal":
    //            //    SpawnDecal(hit, metalHitEffect);
    //            //    break;
    //            //case "Sand":
    //            //    SpawnDecal(hit, sandHitEffect);
    //            //    break;
    //            //case "Stone":
    //            //    SpawnDecal(hit, stoneHitEffect);
    //            //    break;
    //            //case "WaterFilled":
    //            //    SpawnDecal(hit, waterLeakEffect);
    //            //    SpawnDecal(hit, metalHitEffect);
    //            //    break;
    //            //case "Wood":
    //            //    SpawnDecal(hit, woodHitEffect);
    //            //    break;
    //            //case "Meat":
    //            //    SpawnDecal(hit, fleshHitEffects[Random.Range(0, fleshHitEffects.Length)]);
    //            //    break;
    //            //case "Character":
    //            //    SpawnDecal(hit, fleshHitEffects[Random.Range(0, fleshHitEffects.Length)]);
    //            //    break;
    //            //case "WaterFilledExtinguish":
    //            //    SpawnDecal(hit, waterLeakExtinguishEffect);
    //            //    SpawnDecal(hit, metalHitEffect);
    //              //  break;
    //        }
    //    }



    //    //GameObject spawnedDecal = GameObject.Instantiate(prefab, hit.point,
    //    //    Quaternion.LookRotation(hit.normal));
    //    //// Quaternion.FromToRotation(Vector3.up, hit.normal));
    //    //spawnedDecal.transform.SetParent(hit.collider.transform);
    //}


    public override void Grabbed(VRTK_InteractGrab currentGrabbingObject)
    {
        base.Grabbed(currentGrabbingObject);
        controllerEvents = currentGrabbingObject.GetComponent <VRTK_ControllerEvents>();

        // ToggleSlide(true);


        //Limit hands grabbing when picked up
        if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Left)
        {
            allowedTouchControllers = AllowedController.LeftOnly;
            allowedUseControllers   = AllowedController.LeftOnly;
            //  _slide.allowedGrabControllers = AllowedController.RightOnly;
        }
        else if (VRTK_DeviceFinder.GetControllerHand(currentGrabbingObject.controllerEvents.gameObject) == SDK_BaseController.ControllerHand.Right)
        {
            allowedTouchControllers = AllowedController.RightOnly;
            allowedUseControllers   = AllowedController.RightOnly;
            //_slide.allowedGrabControllers = AllowedController.LeftOnly;
        }
    }
        private void OnEnable()
        {
            if (GetComponent <VRTK_ControllerEvents>() == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerAppearance_Example", "VRTK_ControllerEvents", "the same"));
                return;
            }

            events            = GetComponent <VRTK_ControllerEvents>();
            highligher        = GetComponent <VRTK_ControllerHighlighter>();
            tooltips          = GetComponentInChildren <VRTK_ControllerTooltips>();
            currentPulseColor = pulseColor;
            highlighted       = false;

            //Setup controller event listeners
            events.TriggerPressed      += DoTriggerPressed;
            events.TriggerReleased     += DoTriggerReleased;
            events.ButtonOnePressed    += DoButtonOnePressed;
            events.ButtonOneReleased   += DoButtonOneReleased;
            events.ButtonTwoPressed    += DoButtonTwoPressed;
            events.ButtonTwoReleased   += DoButtonTwoReleased;
            events.ButtonThreePressed  += DoButtonThreePressed;
            events.ButtonThreeReleased += DoButtonThreeReleased;
            events.ButtonFourPressed   += DoButtonFourPressed;
            events.ButtonFourReleased  += DoButtonFourReleased;
            events.ButtonFivePressed   += DoButtonFivePressed;
            events.ButtonFiveReleased  += DoButtonFiveReleased;
            events.ButtonSixPressed    += DoButtonSixPressed;
            events.ButtonSixReleased   += DoButtonSixReleased;
            events.StartMenuPressed    += DoStartMenuPressed;
            events.StartMenuReleased   += DoStartMenuReleased;
            events.GripPressed         += DoGripPressed;
            events.GripReleased        += DoGripReleased;
            events.TouchpadPressed     += DoTouchpadPressed;
            events.TouchpadReleased    += DoTouchpadReleased;

            tooltips.ToggleTips(false);
        }
Пример #25
0
    // Use this for initialization
    void Start()
    {
        shooter    = GetComponent <SeedShooter>();
        controller = GetComponent <VRTK_ControllerEvents>();

        if (!shooter)
        {
            Debug.LogError("No SeedShooter found! Please attach a SeedShooter script.");
        }
        //else {
        //    controller = shooter.Controller; // .TriggerClicked += new ControllerInteractionEventHandler(OnGripPress);
        //}

        Image[] imgs = GetComponentsInChildren <Image>();
        seedImg = imgs[imgs.Length - 1];
        if (!seedImg)
        {
            Debug.LogError("Couldn't find Seed UI Image!");
        }

        SetSeed();
        bEventAttached = BindEvent();
    }
Пример #26
0
    private void Start()
    {
        if (GetComponent <VRTK_SimplePointer>() == null || GetComponent <VRTK_ControllerEvents>() == null)
        {
            Debug.LogError("PointerEventListener is required to be attached to a SteamVR Controller that has the VRTK_SimplePointer script attached to it");
            return;
        }

        pointer    = GetComponent <VRTK_SimplePointer>();
        controller = GetComponent <VRTK_ControllerEvents>();

        //Setup pointer event listeners
        pointer.DestinationMarkerEnter += new DestinationMarkerEventHandler(selectObject);
        pointer.DestinationMarkerExit  += new DestinationMarkerEventHandler(deselectObject);
        pointer.DestinationMarkerSet   += new DestinationMarkerEventHandler(DoAction);

        //Setup controller button event Listener;
        controller.TriggerPressed  += new ControllerInteractionEventHandler(triggerPressed);
        controller.TriggerReleased += new ControllerInteractionEventHandler(triggerReleased);

        //initial mode
        MenuAction = defaultMenuAction;
    }
Пример #27
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag != "Pad" && collision.gameObject.GetComponent <VRTK_ControllerEvents>() != null)
        {
            VRTK_ControllerEvents events = collision.gameObject.GetComponent <VRTK_ControllerEvents>();
            controllerReference = VRTK_ControllerReference.GetControllerReference(events.gameObject);

            collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *impactMagnifier;
            var hapticStrength = collisionForce / maxCollisionForce;
            VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticStrength, 0.1f, 0.05f);
            float collisionMidi = ModelUtility.Remap(collisionForce, 0, 100, 70, 127);

            List <float> padData = new List <float>();
            padData.Add(padY);
            padData.Add(padX);
            padData.Add(midiNote);
            padData.Add(collisionMidi);

            OSCHandler.Instance.SendMessageToClient("myClient", "/drumPad", padData);
            textComponent.text = "/drumPad: " + padData[0] + ", " + padData[1] + ", " + midiNote + " , " + collisionMidi;
        }
        StartCoroutine(Reposition());
    }
Пример #28
0
        void Awake()
        {
            // NB: This CANNOT be static! (Each function can operate on exactly one controller)
            funcs = new Dictionary <Type, IHandFunction> {
                [typeof(CameraFunction)]      = new CameraFunction(),
                [typeof(FlyFunction)]         = new FlyFunction(),
                [typeof(GrabFunction)]        = new GrabFunction(),
                [typeof(MeasureFunction)]     = new MeasureFunction(),
                [typeof(ModeControlFunction)] = new ModeControlFunction(this),
                [typeof(ModeMenuFunction)]    = new ModeMenuFunction(this),
                [typeof(OrientFunction)]      = new OrientFunction(),
                [typeof(PointFunction)]       = new PointFunction(),
                [typeof(TeleportFunction)]    = new TeleportFunction(),
            };

            activeFuncs     = new HashSet <Type>();
            events          = GetComponent <VRTK_ControllerEvents>();
            tooltips        = GetComponentInChildren <VRTK_ControllerTooltips>();
            currPrimaryMode = currGripMode = 0;

            tooltips.SendMessage("Awake"); // This is super dumb but it prevents an exception from being thrown

            SetEnabled();
        }
Пример #29
0
    private void SDK_Loaded(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e)
    {
        VRTK_SDKSetup setup = e.currentSetup;

        // When switching scenes, we can get a non-existent SDK for some reason
        if (setup == null)
        {
            return;
        }

        // TODO: Obtain actual controller references somehow (VRTK_ControllerReference.GetControllerReference does not get the actual reference)
        leftController  = setup.modelAliasLeftController;
        rightController = setup.modelAliasRightController;

        InputManager.AddUserController(setup.modelAliasLeftController);
        InputManager.AddUserController(setup.modelAliasRightController);

        VRTK_ControllerEvents[] events = new VRTK_ControllerEvents[] { leftControllerEvent, rightControllerEvent };

        foreach (VRTK_ControllerEvents controllerEvents in events)
        {
            controllerEvents.ButtonTwoReleased += OnMenuRelease;
            controllerEvents.ButtonTwoPressed  += OnMenuPress;

            controllerEvents.TouchpadPressed  += OnTouchpadPress;
            controllerEvents.TouchpadReleased += OnTouchpadRelease;

            controllerEvents.GripClicked   += OnGripPress;
            controllerEvents.GripUnclicked += OnGripRelease;

            controllerEvents.TriggerAxisChanged += OnTriggerChange;

            controllerEvents.TriggerPressed  += OnTriggerPressed;
            controllerEvents.TriggerReleased += OnTriggerReleased;
        }
    }
Пример #30
0
        public override void Grabbed(VRTK_InteractGrab grabbingObject)
        {
            base.Grabbed(grabbingObject);
            ControllerEvents                   = grabbingObject.controllerEvents;
            ControllerEvents.GripPressed      += DestroyObject;
            ControllerEvents.StartMenuPressed += DestroyObject;
            ControllerEvents.TriggerPressed   += UseObject;
            grabOverrideButton                 =
                VRTK_ControllerEvents.ButtonAlias
                .StartMenuPress;     //Bo kontroller sie pokazuje na ungrab jak sie zostawi domyslnie

            if (UseOnAwake == ColliderType.AllToTrigger)
            {
                SetAllColliders(transform, false);
            }
            if (UseOnAwake == ColliderType.MainToTrigger)
            {
                SetMainCollider(false);
            }
            if (UseOnAwake == ColliderType.FirstChildToTrigger)
            {
                SetFirstChildCollider(false);
            }
        }
Пример #31
0
 private void InteractableObjectGrabbed(object sender, InteractableObjectEventArgs e)
 {
     controllerEvents = e.interactingObject.GetComponent <VRTK_ControllerEvents>();
 }
Пример #32
0
 public override void StopUsing(GameObject previousUsingObject)
 {
     base.StopUsing(previousUsingObject);
     controllerEvents  = null;
     controllerActions = null;
 }
 public override void StopUsing(GameObject previousUsingObject)
 {
     base.StopUsing(previousUsingObject);
     controllerEvents = null;
     controllerActions = null;
 }
 public override void StartUsing(GameObject usingObject)
 {
     base.StartUsing(usingObject);
     controllerEvents = usingObject.GetComponent<VRTK_ControllerEvents>();
     controllerActions = usingObject.GetComponent<VRTK_ControllerActions>();
 }
Пример #35
0
 public override void Grabbed(GameObject grabbingObject)
 {
     base.Grabbed(grabbingObject);
     controllerActions = grabbingObject.GetComponent<VRTK_ControllerActions>();
     controllerEvents = grabbingObject.GetComponent<VRTK_ControllerEvents>();
 }
Пример #36
0
 public override void Grabbed(GameObject grabbingObject)
 {
     base.Grabbed(grabbingObject);
     controllerActions = grabbingObject.GetComponent <VRTK_ControllerActions>();
     controllerEvents  = grabbingObject.GetComponent <VRTK_ControllerEvents>();
 }
        private void Start()
        {
            if (GetComponent<VRTK_ControllerEvents>() == null)
            {
                Debug.LogError("VRTK_ControllerEvents_ListenerExample is required to be attached to a 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.ToggleTips(false);
        }