Ejemplo n.º 1
0
 private void Button_down_onState(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     if (smooth_Y)
     {
         defaultActionSet.Deactivate();
         transform.Translate(Vector3.down * up_down_speed * Time.deltaTime);
         player.trackingOriginTransform.Translate(Vector3.down * up_down_speed * Time.deltaTime);
     }
 }
Ejemplo n.º 2
0
 private void updateLasersActionSetState()
 {
     if (!mainActionSet.IsActive())
     {
         laserActionSet.Deactivate();
         return;
     }
     if (laserActionSet.IsActive() && VRPlayer.activePointer == null)
     {
         laserActionSet.Deactivate();
     }
     else if (!laserActionSet.IsActive() && VRPlayer.activePointer != null)
     {
         laserActionSet.Activate(SteamVR_Input_Sources.Any, 1 /* Higher priority than main action set */);
     }
 }
Ejemplo n.º 3
0
        protected virtual void OnDetachedFromHand(Hand hand)
        {
            if (activateActionSetOnAttach != null)
            {
                if (hand.otherHand == null || hand.otherHand.currentAttachedObjectInfo.HasValue == false ||
                    (hand.otherHand.currentAttachedObjectInfo.Value.interactable != null &&
                     hand.otherHand.currentAttachedObjectInfo.Value.interactable.activateActionSetOnAttach != this.activateActionSetOnAttach))
                {
                    activateActionSetOnAttach.Deactivate(hand.handType);
                }
            }

            if (onDetachedFromHand != null)
            {
                onDetachedFromHand.Invoke(hand);
            }


            if (skeletonPoser != null)
            {
                if (hand.skeleton != null)
                {
                    hand.skeleton.BlendToSkeleton(releasePoseBlendTime);
                }
            }

            attachedToHand = null;

            //Here is the object released
        }
Ejemplo n.º 4
0
        protected virtual void OnDetachedFromHand(Hand hand)
        {
            if (activateActionSetOnAttach != null)
            {
                if (hand.otherHand == null || hand.otherHand.currentAttachedObjectInfo.HasValue == false ||
                    (hand.otherHand.currentAttachedObjectInfo.Value.interactable != null &&
                     hand.otherHand.currentAttachedObjectInfo.Value.interactable.activateActionSetOnAttach != this.activateActionSetOnAttach))
                {
                    activateActionSetOnAttach.Deactivate(hand.handType);
                }
            }

            if (onDetachedFromHand != null)
            {
                onDetachedFromHand.Invoke(hand);
            }


            if (skeletonPoser != null)
            {   // detach child object from interactable
                if (childToAttach != null)
                {
                    childToAttach.transform.parent = childObjectOrigin;
                }
                if (hand.skeleton != null)
                {
                    hand.skeleton.BlendToSkeleton(releasePoseBlendTime);
                }
            }

            attachedToHand = null;
        }
Ejemplo n.º 5
0
 private void OnDetachedFromHand(Hand hand)
 {
     if (actionsetEnableOnGrab)
     {
         actionsetEnableOnGrab.Deactivate();
     }
 }
Ejemplo n.º 6
0
    public virtual void OnDrop(MyHand hand)
    {
        // deactivate ActionSet
        if (activateActionSet != null)
        {
            activateActionSet.Deactivate(hand.handType);
        }
        // enable controller model
        if (hideControllerModelOnPickUp)
        {
            hand.controllerRenderer.SetMeshRendererState(true);
        }
        // enable hand model
        if (hideHandModelOnPickUp)
        {
            hand.handRenderer.enabled = true;
        }

        // blend to normal skeleton
        if (skeletonPoser != null)
        {
            if (hand.skeleton != null)
            {
                hand.skeleton.BlendToSkeleton(releasePoseBlendTime);
            }
        }
    }
Ejemplo n.º 7
0
    private void Interactable_onDetachedFromHand(Hand hand)
    {
        if (hand.otherHand.currentAttachedObject != null && (hand.otherHand.currentAttachedObject.GetComponent <SquishyToy>() != null || hand.otherHand.currentAttachedObject.GetComponent <turret>() != null))
        {
            return;
        }

        actionSet.Deactivate();
    }
Ejemplo n.º 8
0
    private void Interactable_onDetachedFromHand(Hand hand)
    {
        if (hand.otherHand.currentAttachedObject != null && hand.otherHand.currentAttachedObject.GetComponent <grenade>() != null)
        {
            return;
        }

        actionSet.Deactivate();
    }
Ejemplo n.º 9
0
 public virtual void OnDrop(MyHand hand)
 {
     // deactivate ActionSet
     if (activateActionSet != null)
     {
         activateActionSet.Deactivate(hand.handType);
     }
     // enable Hand model
     if (hideHandModelOnPickUp)
     {
         hand.transform.GetChild(0).gameObject.SetActive(true);
     }
 }
Ejemplo n.º 10
0
        private void updateMainActionSetState()
        {
            bool useVrControls = VHVRConfig.UseVrControls();

            if (!useVrControls && mainActionSet.IsActive())
            {
                mainActionSet.Deactivate();
            }
            else if (useVrControls && !mainActionSet.IsActive())
            {
                mainActionSet.Activate();
            }
        }
Ejemplo n.º 11
0
 private void ActionSetStartViewEnabled(bool enabled)
 {
     if (_action_set_start_view != null)
     {
         if (enabled)
         {
             _action_set_start_view.Activate();
         }
         else
         {
             _action_set_start_view.Deactivate();
         }
     }
 }
Ejemplo n.º 12
0
    void UpdateDisplay()
    {
        ui_actionInput.SetActive(drawActionInput);
        ui_rawInput.SetActive(drawRawInput);

        if (drawRawInput)
        {
            rawActionSet.Activate();
        }
        else
        {
            rawActionSet.Deactivate();
        }
    }
Ejemplo n.º 13
0
 private void ActionSetPointcloudViewEnabled(bool enabled)
 {
     if (_action_set_pointcloud_view != null)
     {
         if (enabled)
         {
             _action_set_pointcloud_view.Activate();
         }
         else
         {
             _action_set_pointcloud_view.Deactivate();
         }
     }
 }
Ejemplo n.º 14
0
 void SelectActionSet()
 {
     if (inZone == true)
     {
         //Debug.Log(string.Format("[SteamVR] Activating {0} action set.", actionSet.fullPath));
         dartsActionSet.Activate(forSources, 0, disableAllOtherActionSets);
         //defaultActionSet.Deactivate(forSources);
     }
     else
     {
         dartsActionSet.Deactivate(forSources); // Disable darts action set
         //defaultActionSet.Activate(forSources);
     }
 }
Ejemplo n.º 15
0
        protected override void Update()
        {
            base.Update();

            if (attachedToHand)
            {
                if (!was_attached)
                {
                    actionSet.ActivatePrimary();
                }
            }
            else
            {
                if (was_attached)
                {
                    actionSet.Deactivate();
                }
            }
            was_attached = attachedToHand != null;


            if (attachedToHand)
            {
                hand = attachedToHand.handType;
                Vector2 m = a_move.GetAxis(hand);
                movement = new Vector3(m.x, 0, m.y);

                jump = a_jump.GetStateDown(hand);
                glow = Mathf.Lerp(glow, a_jump.GetState(hand) ? 1.5f : 1.0f, Time.deltaTime * 20);
            }
            else
            {
                movement = Vector2.zero;
                jump     = false;
                glow     = 0;
            }

            Joystick.localPosition = movement * joyMove;

            float rot = transform.eulerAngles.y;

            movement = Quaternion.AngleAxis(rot, Vector3.up) * movement;

            jumpHighlight.sharedMaterial.SetColor("_EmissionColor", Color.white * glow);

            character.Move(movement * 2, jump);
        }
Ejemplo n.º 16
0
        private void OnDetachedFromHand(Hand hand)
        {
            if (activateActionSetOnAttach != null)
            {
                if (hand.otherHand.currentAttachedObjectInfo.HasValue == false || (hand.otherHand.currentAttachedObjectInfo.Value.interactable != null &&
                                                                                   hand.otherHand.currentAttachedObjectInfo.Value.interactable.activateActionSetOnAttach != this.activateActionSetOnAttach))
                {
                    activateActionSetOnAttach.Deactivate();
                }
            }

            if (onDetachedFromHand != null)
            {
                onDetachedFromHand.Invoke(hand);
            }

            attachedToHand = null;
        }
Ejemplo n.º 17
0
    void Update()
    {
        if (openMenuAction.GetStateUp(m_TargetSource) || closeMenuAction.GetStateUp(m_TargetSource))
        {
            if (menu.enabled == false)
            {
                menu.enabled = true;

                menuActions.Activate();
                graphActions.Deactivate();
            }
            else
            {
                menu.enabled = false;

                graphActions.Activate();
                menuActions.Deactivate();
            }
        }
    }
Ejemplo n.º 18
0
 void OnDisable()
 {
     //remove actions
     if (gripAction != null)
     {
         gripAction.RemoveOnChangeListener(OnGripActionChange, Hand_InputSource);
     }
     if (touchAction != null)
     {
         touchAction.RemoveOnChangeListener(OnTouchActionChange, Hand_InputSource);
     }
     if (pressAction != null)
     {
         pressAction.RemoveOnChangeListener(OnPressActionChange, Hand_InputSource);
     }
     if (menuAction != null)
     {
         menuAction.RemoveOnChangeListener(OnMenuActionChange, Hand_InputSource);
     }
     if (CVR_ActionSet != null)
     {
         CVR_ActionSet.Deactivate(Hand_InputSource);
     }
 }
Ejemplo n.º 19
0
 private void Interactable_onDetachedFromHand(Hand hand)
 {
     setToActivate.Deactivate();
 }
Ejemplo n.º 20
0
    private void ActionActivityController()
    {
        if (dimExplorer.dimensionExpLorerLoaded)
        {
            dimExplorerActions.Activate();
            vizNavActions.Deactivate();
        }
        else if (vizController.vizFullyLoaded)
        {
            vizNavActions.Activate();
            dimExplorerActions.Deactivate();
        }


        if (dimExplorer.dimExKeyboard.keyboardLoaded)
        {
            dimExplorerActions.Activate();
            vizNavActions.Deactivate();
        }


        if (dimExplorer.dimExKeyboard.keyboardMoving)
        {
            dimExplorerActions.Deactivate();
            vizNavActions.Deactivate();
        }


        if (timeline.timelineLoaded)
        {
            timelineActions.Activate();
        }
        else
        {
            timelineActions.Deactivate();
        }

        menuInteractionActions.Activate();


        // debugging
        if (false)
        {
            //Debug.Log("dimensionExpLorerLoaded: " + dimExplorer.dimensionExpLorerLoaded + " | vizFullyLoaded: " + vizController.vizFullyLoaded + " | keyboardLoaded: " + dimExplorer.dimExKeyboard.keyboardLoaded + " | keyboardMoving: " + dimExplorer.dimExKeyboard.keyboardMoving);

            string activeSetDebug = "Active Sets:";
            if (defaultActions.IsActive())
            {
                activeSetDebug += " | default";
            }
            if (vizNavActions.IsActive())
            {
                activeSetDebug += " | viz";
            }
            if (dimExplorerActions.IsActive())
            {
                activeSetDebug += " | dimEx";
            }
            if (menuInteractionActions.IsActive())
            {
                activeSetDebug += " | menu";
            }
            if (timelineActions.IsActive())
            {
                activeSetDebug += " | timeline";
            }
            Debug.Log(activeSetDebug);
        }
    }
Ejemplo n.º 21
0
    void Update()
    {
        if (actionSetChanged)
        {
            switch (currentActionSet.GetShortName())
            {
            case "MySet":
                currentActionSet.Activate(currentSource, 0, false);
                pose.poseAction   = SteamVR_Input.GetAction <SteamVR_Action_Pose>("MySet", "Pose", false, false);
                gripClickAction   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("MySet", "GripClick", false, false);
                triggerPullAction = SteamVR_Input.GetAction <SteamVR_Action_Single>("MySet", "Teleport", false, false);
                joyStickAction    = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("MySet", "Move", false, false);
                break;

            case "Sword":
                currentActionSet.Activate(currentSource, 0, false);
                pose.poseAction = SteamVR_Input.GetAction <SteamVR_Action_Pose>("Sword", "Pose", false, false);
                //gripClickAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false);
                triggerClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false);
                joyStickAction     = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("Sword", "Move", false, false);
                break;

            default:
                break;
            }

            actionSetChanged = false;
        }

        gripClick      = gripClickAction.GetStateDown(currentSource);
        triggerClickUp = triggerClickAction.GetStateUp(currentSource);
        triggerValue   = triggerPullAction.GetAxis(currentSource);
        triggerClick   = triggerClickAction.GetLastStateDown(currentSource);
        detach         = detachAction.GetStateDown(currentSource);
        moveValue      = joyStickAction.GetAxis(currentSource);

        //INITIATESLASH CODE ----------------------------------------------------------------------------------------------------------------------------------
        if (triggerClick && attached && currentActionSet.GetShortName().Equals("Sword"))
        {
            slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>();
            ParticleSystem.EmissionModule emiss = slashParticles.emission;
            emiss.rateOverDistance = 200f;
        }
        if (triggerClickUp && attached && currentActionSet.GetShortName().Equals("Sword"))
        {
            slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>();
            ParticleSystem.EmissionModule emiss = slashParticles.emission;
            emiss.rateOverDistance = 0f;
        }

        //OBJECT DETACH CODE ---------------------------------------------------------------------------------------------------------------------------------
        if (attached && detach && hover.closestHoverObj != null)
        {
            //Grab a reference to the current closestHoverObject that is obtained by running Hover() in Hover.cs
            try
            {
                ObjectInteraction detachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>();

                attached = detachCall.DetachObjectFromController();
                currentActionSet.Deactivate(currentSource);
                currentActionSet        = SteamVR_Input.GetActionSet("MySet");
                currentlyAttachedObject = null;
                actionSetChanged        = true;
            }
            catch (NullReferenceException)
            {
                Debug.LogWarning("detachCall Hand is null in OculusInput.cs");
                return;
            }
        }

        //OBJECT ATTACH CODE ---------------------------------------------------------------------------------------------------------------------------------
        if (gripClick && hover.closestHoverObj != null && !attached)
        {
            try
            {
                ObjectInteraction attachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>();

                attached = attachCall.AttachObjectToController(this.gameObject, hover.hoverPoint);
                currentlyAttachedObject = hover.closestHoverObj;
                currentActionSet.Deactivate(currentSource);
                currentActionSet = SteamVR_Input.GetActionSet("Sword"); //CHANGE THIS LATER WHEN WE HAVE MORE THAN ONE ITEM TO PICK UP
                actionSetChanged = true;
            }
            catch (NullReferenceException)
            {
                Debug.LogWarning("attachCall Right Hand is null in OculusInput.cs");
                return;
            }
        }

        //TRIGGER PRESS CODE ---------------------------------------------------------------------------------------------------------------------------------
        if (triggerValue > 0.1f)
        {
            int layerMask = (1 << 9);
            if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 50f, layerMask))
            {
                teleTarget.transform.position = hit.point;
                Debug.DrawRay(transform.position, (transform.forward - transform.up) * 100f, Color.blue, 5f);
            }
        }
        if (triggerValue > 0.75f && pressFlag)//Teleport using raycast
        {
            print("Teleport");
            Debug.DrawRay(transform.position, transform.forward * 100f, Color.red);
            if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 100f))
            {
                cameraRig.transform.position = hit.point;
            }
            pressFlag = false;
        }
        if (triggerValue < 0.1f)//Must release or almost release trigger before teleporting again
        {
            pressFlag = true;
        }

        //JOYSTICK MOVEMENT CODE ---------------------------------------------------------------------------------------------------------------------------------
        if (moveValue.y > 0.1f || moveValue.y < -0.1f)
        {//Forward and Backward
            Vector3 controllerMove = new Vector3(((transform.forward - transform.up).normalized).x,
                                                 0f,
                                                 (((transform.forward - transform.up).normalized).z));

            cameraRig.transform.Translate(controllerMove * moveValue.y);
        }
        if (moveValue.x > 0.1f || moveValue.x < -0.1f)
        {//Right and Left
            Vector3 controllerMove = new Vector3(transform.right.x, 0f, transform.right.z);
            cameraRig.transform.Translate(controllerMove * moveValue.x);
        }
    }
Ejemplo n.º 22
0
 // Removes the selection event.
 private void OnDestroy()
 {
     trigger.onStateDown -= Trigger_onStateDown;
     SelectRobot.Deactivate();
 }
Ejemplo n.º 23
0
        protected override void Update()
        {
            base.Update();
            Vector2 steer    = Vector2.zero;
            float   throttle = 0;
            float   brake    = 0;

            bool reset = false;

            bool b_brake = false;
            bool b_reset = false;


            if (attachedToHand)
            {
                SteamVR_Input_Sources hand = attachedToHand.handType;

                if (!was_attached)
                {
                    actionSet.ActivatePrimary();
                }


                steer    = a_steering.GetAxis(hand);
                throttle = a_trigger.GetAxis(hand);
                b_brake  = a_brake.GetState(hand);
                b_reset  = a_reset.GetState(hand);
                brake    = b_brake ? 1 : 0;
                reset    = a_reset.GetStateDown(hand);
            }
            else
            {
                if (was_attached)
                {
                    actionSet.Deactivate();
                }
            }
            was_attached = attachedToHand != null;


            if (reset && resettingRoutine == null)
            {
                resettingRoutine = StartCoroutine(DoReset());
            }

            if (ui_Canvas != null)
            {
                ui_Canvas.gameObject.SetActive(attachedToHand);

                usteer = Mathf.Lerp(usteer, steer.x, Time.deltaTime * 9);
                ui_steer.localEulerAngles = Vector3.forward * usteer * -ui_steerangle;
                ui_rpm.fillAmount         = Mathf.Lerp(ui_rpm.fillAmount, Mathf.Lerp(ui_fillAngles.x, ui_fillAngles.y, throttle), Time.deltaTime * 4);
                float speedLim = 40;
                ui_speed.fillAmount = Mathf.Lerp(ui_fillAngles.x, ui_fillAngles.y, 1 - (Mathf.Exp(-buggy.speed / speedLim)));
            }


            modelJoystick.localRotation = joySRot;

            /*if (input.AttachedHand != null && input.AttachedHand.IsLeft)
             * {
             *  Joystick.Rotate(steer.y * -joystickRot, steer.x * -joystickRot, 0, Space.Self);
             * }
             * else if (input.AttachedHand != null && input.AttachedHand.IsRight)
             * {
             *  Joystick.Rotate(steer.y * -joystickRot, steer.x * joystickRot, 0, Space.Self);
             * }
             * else*/
            //{
            modelJoystick.Rotate(steer.y * -joystickRot, steer.x * -joystickRot, 0, Space.Self);
            //}

            modelTrigger.localRotation = trigSRot;
            modelTrigger.Rotate(throttle * -triggerRot, 0, 0, Space.Self);
            buttonBrake.localScale = new Vector3(1, 1, b_brake ? 0.4f : 1.0f);
            buttonReset.localScale = new Vector3(1, 1, b_reset ? 0.4f : 1.0f);

            buggy.steer               = steer;
            buggy.throttle            = throttle;
            buggy.handBrake           = brake;
            buggy.controllerReference = transform;
        }