예제 #1
0
    private IEnumerator FindDevices()
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        RightHand = VRTK_DeviceFinder.GetControllerRightHand();
        LeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();

        RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed    += TouchpadPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed     += TouchpadPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadReleased   += TouchpadReleased;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadReleased    += TouchpadReleased;
        RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadTouchEnd   += TouchpadReleased;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadTouchEnd    += TouchpadReleased;
        RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadTouchStart += TouchpadReleased;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadTouchStart  += TouchpadReleased;

        gameObject.SetActive(false);
    }
예제 #2
0
        private Transform GetSnapHandle(GameObject grabbingObject)
        {
            if (rightSnapHandle == null && leftSnapHandle != null)
            {
                rightSnapHandle = leftSnapHandle;
            }

            if (leftSnapHandle == null && rightSnapHandle != null)
            {
                leftSnapHandle = rightSnapHandle;
            }

            if (VRTK_DeviceFinder.IsControllerRightHand(grabbingObject))
            {
                return(rightSnapHandle);
            }

            if (VRTK_DeviceFinder.IsControllerLeftHand(grabbingObject))
            {
                return(leftSnapHandle);
            }

            return(null);
        }
예제 #3
0
 //手势判定
 public void gestureJudge()
 {
     //获取手柄速度
     bingV = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents> ().GetVelocity();
     if (renPos.x > -12.5f)
     {
         //玩家向z轴正方向挥拍
         if (bingV.z > 0)
         {
             if (Constant.isOutside)
             {
                 speA.x = Random.Range(-10, -7);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(0, 2);
             }
             else
             {
                 speA.x = Random.Range(-6, -5);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(0, 2);
             }
         }
         else                                                                                                                                                                                    //玩家向z轴负方向挥拍
         {
             if (Constant.isOutside)
             {
                 speA.x = Random.Range(-10, -7);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(-2, 0);
             }
             else
             {
                 speA.x = Random.Range(-6, -5);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(-2, 0);
             }
         }
     }
     else                                                                                                                                                                //玩家在AI端
     {
         if (bingV.z > 0)                                                                                                                                                //玩家向z轴正方向挥拍
         {
             if (Constant.isOutside)
             {
                 speA.x = Random.Range(8, 11);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(0, 2);
             }
             else
             {
                 speA.x = Random.Range(5, 7);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(0, 2);
             }
         }
         else                                                                                                                                                                    //玩家向z轴负方向挥拍
         {
             if (Constant.isOutside)
             {
                 speA.x = Random.Range(8, 11);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(-2, 0);
             }
             else
             {
                 speA.x = Random.Range(5, 7);
                 speA.y = Random.Range(5, 9);
                 speA.z = Random.Range(-2, 0);
             }
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        //スワイプ値リセット
        IsOnSwipeHorizontal = false;
        IsOnSwipeVertical   = false;
        diffTouchPadX       = 0f;
        diffTouchPadY       = 0f;

        VRTK_ControllerReference reference = VRTK_ControllerReference.GetControllerReference(gameObject);

        if (headsetType == SDK_BaseHeadset.HeadsetType.Undefined)
        {
            headsetType = VRTK_DeviceFinder.GetHeadsetType();
        }

        if (headsetType == SDK_BaseHeadset.HeadsetType.OculusRift)
        {
            //Riftでのタッチパッドの移動量取得
            var axis = VRTK_SDK_Bridge.GetControllerAxis(SDK_BaseController.ButtonTypes.Touchpad, reference);

            var absX = Mathf.Abs(axis.x);
            var absY = Mathf.Abs(axis.y);
            if (absX > absY) //X軸スワイプ
            {
                if (absX > TOUCH_MARGIN)
                {
                    IsOnSwipeHorizontal = true;
                    diffTouchPadX       = (axis.x - TOUCH_MARGIN) * 0.05f * Time.deltaTime * 30f;
                }
            }
            else //Y軸スワイプ
            {
                if (absY > TOUCH_MARGIN)
                {
                    IsOnSwipeVertical = true;
                    diffTouchPadY     = (axis.y - TOUCH_MARGIN) * 0.05f * Time.deltaTime * 30f;
                }
            }
        }
        else //Rift以外の場合
        {
            //Viveでのタッチパッドの移動量取得
            if (VRTK_SDK_Bridge.GetControllerButtonState(SDK_BaseController.ButtonTypes.Touchpad, SDK_BaseController.ButtonPressTypes.TouchDown, reference))
            {
                touchMarginSumX = 0f;
                touchMarginSumY = 0f;
                prevTouchPadX   = VRTK_SDK_Bridge.GetControllerAxis(SDK_BaseController.ButtonTypes.Touchpad, reference).x;
                prevTouchPadY   = VRTK_SDK_Bridge.GetControllerAxis(SDK_BaseController.ButtonTypes.Touchpad, reference).y;
            }
            else if (VRTK_SDK_Bridge.GetControllerButtonState(SDK_BaseController.ButtonTypes.Touchpad, SDK_BaseController.ButtonPressTypes.Touch, reference))
            {
                float nowTouchPadX = VRTK_SDK_Bridge.GetControllerAxis(SDK_BaseController.ButtonTypes.Touchpad, reference).x;
                diffTouchPadX = nowTouchPadX - prevTouchPadX;
                if (touchMarginSumX > TOUCH_MARGIN) //タッチ移動量がマージンを超えたら
                {
                    IsOnSwipeHorizontal = true;
                }
                prevTouchPadX    = nowTouchPadX;
                touchMarginSumX += Mathf.Abs(diffTouchPadX);

                float nowTouchPadY = VRTK_SDK_Bridge.GetControllerAxis(SDK_BaseController.ButtonTypes.Touchpad, reference).y;
                diffTouchPadY = nowTouchPadY - prevTouchPadY;
                if (touchMarginSumY > TOUCH_MARGIN) //タッチ移動量がマージンを超えたら
                {
                    IsOnSwipeVertical = true;
                }
                prevTouchPadY    = nowTouchPadY;
                touchMarginSumY += Mathf.Abs(diffTouchPadY);
            }
        }
    }
예제 #5
0
    public void DoTeleport()
    {
        Quaternion?rotation = null;

        if (rotate)
        {
            var rotationY = rotationAbsolute ? transform.rotation.eulerAngles.y : VectorUtils.AngleOffAroundAxis(transform.forward, VRTK_DeviceFinder.HeadsetTransform().forward, Vector3.up);
            rotationY += VRTK_SDKManager.instance.transform.rotation.eulerAngles.y;
            rotation   = Quaternion.Euler(0, rotationY, 0);
        }

        var  playAreaTeleport           = teleport as PlayAreaLimitedTeleport;
        bool originalCheckForCollisions = false;

        if (playAreaTeleport)
        {
            originalCheckForCollisions          = playAreaTeleport.checkForCollisions;
            playAreaTeleport.checkForCollisions = false;
        }

        teleport.skipBlink = true;
        teleport.Teleport(transform, transform.position, rotation);
        teleport.skipBlink = false;

        headsetEat.enabled = true;

        Destroy(gameObject);

        if (playAreaTeleport)
        {
            playAreaTeleport.checkForCollisions = originalCheckForCollisions;
        }
    }
예제 #6
0
        protected virtual void ToggleSDKVisibility()
        {
            VRTK_SDKSetup sdkType = VRTK_SDKManager.GetLoadedSDKSetup();

            if (sdkType != null)
            {
                VRTK_ControllerReference leftController  = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerLeftHand(true));
                VRTK_ControllerReference rightController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand(true));
                switch (sdkType.name)
                {
                case "SteamVR":
                    ToggleControllerRenderer(leftController.actual, "Model");
                    ToggleControllerRenderer(rightController.actual, "Model");
                    break;

                case "Oculus":
                    ToggleControllerRenderer(leftController.model);
                    ToggleControllerRenderer(rightController.model);
                    break;

                case "WindowsMR":
                    ToggleControllerRenderer(leftController.model, "glTFController");
                    ToggleControllerRenderer(rightController.model, "glTFController");
                    break;
                }
            }
        }
예제 #7
0
        static void OnUpdate(UnityModManager.ModEntry mod, float delta)
        {
            timer += delta;
            if (!floatLoaded)
            {
                floatLoaded = Floaties.Initialize();
            }
            else if (!listenersSetup)
            {
                // eyesTransform = PlayerManager.PlayerCamera.transform;
                if (VRManager.IsVREnabled())
                {
                    VRTK_InteractGrab lGrab = VRTK_DeviceFinder.GetControllerLeftHand(true)?.transform.GetComponentInChildren <VRTK_InteractGrab>();
                    VRTK_InteractGrab rGrab = VRTK_DeviceFinder.GetControllerRightHand(true)?.transform.GetComponentInChildren <VRTK_InteractGrab>();
                    if (lGrab == null || rGrab == null)
                    {
                        return;
                    }
                    lGrab.ControllerGrabInteractableObject        += OnItemGrabbedLeftVR;
                    lGrab.ControllerStartUngrabInteractableObject += OnItemUngrabbedLeftVR;
                    rGrab.ControllerGrabInteractableObject        += OnItemGrabbedRightVR;
                    rGrab.ControllerStartUngrabInteractableObject += OnItemUngrabbedRightVR;
                }
                else
                {
                    Grabber grab = PlayerManager.PlayerTransform.GetComponentInChildren <Grabber>();
                    grab.Grabbed  += OnItemGrabbedRightNonVR;
                    grab.Released += OnItemUngrabbedRightNonVR;
                    SingletonBehaviour <Inventory> .Instance.ItemAddedToInventory += OnItemAddedToInventory;
                }

                mod.Logger.Log(string.Format("Listeners have been set up, total time elapsed: {0:0.00} seconds.", timer));
                listenersSetup = true;
            }
            else
            {
                if (showing)
                {
                    if (holdingRight == null || !showFloat)
                    {
                        Floaties.HideFloatie();
                        showing = false;
                    }
                    else
                    {
                        if (timer > POINTER_INTERVAL)
                        {
                            counter++;
                            timer %= POINTER_INTERVAL;
                            // Calculate tracks that cars are on.
                            holdingRight.UpdateJobCars();
                            holdingRight.UpdateJobPrivilege();
                            Floaties.ChangeFloatieText(holdingRight.GetFloatieText(counter));
                            Floaties.UpdateAttentionTransform(holdingRight.GetPointerAt(counter));
                        }
                    }
                }
                else if (!showing && holdingRight != null && showFloat)
                {
                    // TODO: Read job information and process text accordingly.
                    Floaties.ShowFloatie(holdingRight.GetFloatieText(counter));
                    Floaties.UpdateAttentionTransform(holdingRight.GetPointerAt(counter));
                    showing = true;
                    timer   = 0;
                }
            }
        }
예제 #8
0
 // Use this for initialization
 void Awake()
 {
     playArea = VRTK_DeviceFinder.PlayAreaTransform();
     headset  = VRTK_DeviceFinder.HeadsetTransform();
 }
예제 #9
0
 public static void SetRotatableMole(GameObject mole)
 {
     mole.GetComponent <Rotator>().ResetRotation();
     VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <RotateController>().SetMolecule(mole);
 }
예제 #10
0
 //Fonction de vibration de la manette (à appeler en Event)
 public void StartHapticTouch()
 {
     controllerReference = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetModelAliasController(events.gameObject));
     VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, strengthOnTouch, durationOnTouch, intervalOnTouch);
 }
예제 #11
0
 public GameObject GetLeftController()
 {
     return(VRTK_DeviceFinder.GetControllerLeftHand(false));
 }
예제 #12
0
 protected override void Awake()
 {
     leftActions  = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>();
     rightActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>();
     base.Awake();
 }
 private void PlayHapticEvents()
 {
     NullSpace.SDK.SideOfHaptic whichSide = VRTK_DeviceFinder.GetControllerHand(GetGrabbingObject()) == SDK_BaseController.ControllerHand.Left ? NullSpace.SDK.SideOfHaptic.Left : NullSpace.SDK.SideOfHaptic.Right;
     //Debug.Log("Invoking Haptic Event\n" + whichSide.ToString());
     HapticsOnUse.Invoke(whichSide);
 }
 /// <summary>
 /// the function to play a haptic pulse if the player isnt using a vive. (haptics were broken on the vive) TODO: find out which the vive haptics sound wrong.
 /// </summary>
 void TriggerHapticPulse()
 {
     Debug.Log("hapticpulse");
     if (ViveObject == null || ViveObject.GetActive() == false)
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerIndex(this.gameObject)), audioahptic);
     }
 }
예제 #15
0
 public void Released(object o, InteractableObjectEventArgs e)
 {
     sources ["hold"].Stop();
     sources ["throw"].volume = Mathf.Clamp(VRTK_DeviceFinder.GetControllerVelocity(VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerIndex(e.interactingObject))).magnitude / 2, 0, 1);
     sources ["throw"].Play();
 }
예제 #16
0
    private void OnTriggerEnter(Collider other)
    {
        if (!(other.gameObject.layer == 12 || other.gameObject.layer == 13))
        {
            return;
        }

        //check to measure either rigidbody or controller velocity
        controllerReference = weaponParent.GetComponent <WeaponHaptics>().controllerReference;
        if (isFlail)
        {
            velocity = rb.velocity;
        }
        else
        {
            velocity = VRTK_DeviceFinder.GetControllerVelocity(controllerReference);
        }


        if (velocity.magnitude >= minimumSpeedToProduceSound)
        {
            // play randomized sound effect
            AkSoundEngine.PostEvent(akEventCollision, this.gameObject);
            lastTimeSoundWasPlayed = Time.time;
        }

        Debug.Log("hit something!");


        int damage = baseDamage;

        if ((other.gameObject.layer == 12 || other.gameObject.layer == 13))
        {
            StateController state_controller = other.gameObject.GetComponentInParent <StateController>();
            GameObject      enemy            = state_controller.gameObject;

            //divide damage by factor if the enemy is blocking

            if (state_controller.isBlocking == true)
            {
                damage = (int)(damage / blockMultiplier);
            }



            if (velocity.magnitude > minimumSpeedToDamage)
            {
                if (other.gameObject.layer == 13 && collided == false)    //enemy layer is set to integer 13 in layer manager
                {
                    collided = true;
                    VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, 0.01f);
                    enemy.GetComponent <SkeletonDamagable>().DealDamage(damage);
                    Debug.Log("Damage dealt: " + damage);
                }
                else if (other.gameObject.layer == 12 && collided == false)      //critical layer is set to integer 12 in layer manager
                {
                    collided = true;
                    VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, 0.01f);
                    enemy.GetComponent <SkeletonDamagable>().DealDamage((int)(damage * critMultiplier));
                    Debug.Log("Crit damage dealt: " + damage);
                }
            }
        }
    }
예제 #17
0
 private Transform GetValue(Recursion arg1)
 {
     return(VRTK_DeviceFinder.HeadsetTransform());
 }
예제 #18
0
 public static void CancelRotatable()
 {
     VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <RotateController>().RemoveMolecule();
 }
예제 #19
0
 /// <summary>
 /// 显示控制器
 /// </summary>
 public void ControllerVisible()
 {
     VRTK_ObjectAppearance.SetRendererVisible(VRTK_DeviceFinder.GetModelAliasController(gameObject));
 }
예제 #20
0
 public static void SetLinearMovableMole(GameObject mole)
 {
     VRTK_DeviceFinder.GetControllerRightHand().GetComponent <LinearmoveController>().SetMolecule(mole);
 }
 public void Show()
 {
     camera = VRTK_DeviceFinder.HeadsetTransform();
 }
예제 #22
0
 public static void CancelLinearMovable()
 {
     VRTK_DeviceFinder.GetControllerRightHand().GetComponent <LinearmoveController>().RemoveMolecule();
 }
 //VRTK에 로드된 디바이스들을 찾아 위치들을 vector 형식으로 변환해서 위치값을 저장한다.
 private void OnEnable()
 {
     headset          = VRTK_DeviceFinder.HeadsetTransform();
     left_Controller  = VRTK_DeviceFinder.GetControllerLeftHand().transform;
     right_Controller = VRTK_DeviceFinder.GetControllerRightHand().transform;
 }
예제 #24
0
 public bool IsPressed()
 {
     return(VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>().triggerPressed); //fixme
 }
예제 #25
0
    private void StartLogging(int groupID, int taskID, string taskName, string taskDescription, PhotonMessageInfo info)
    {
        isLogging = true;

        this.groupID = groupID;
        this.taskID  = taskID;

        if (!filePath.EndsWith("\\"))
        {
            filePath += "\\";
        }

        if (isMasterLogger)
        {
            // Objects
            string path = string.Format("{0}Group{1}_Task{2}_ObjectData.txt", filePath, groupID, tasks[taskID].taskName);
            objectStreamWriter = new StreamWriter(path, true);

            // Write header for object data
            objectStreamWriter.WriteLine("Timestamp\tObjectType\tOriginalOwner\tOwner\tPosition.x\tPosition.y\tPosition.z\tRotation.x\tRotation.y\tRotation.z\tRotation.w\tWidth\tHeight\tDepth" +
                                         "\tID\txDimension\tyDimension\tzDimension\tSize\tSizeDimension\tColor\tColorDimension\tFacetDimension\tFacetSize\txNormaliser\tyNormaliser\tzNormaliser");

            // Save references of logged entities
            dashboards = FindObjectsOfType <Panel>().ToList();
            if (FindObjectOfType <KeyboardAndMouseAvatar>() != null)
            {
                observer = FindObjectOfType <KeyboardAndMouseAvatar>().transform;
            }
            markers = FindObjectsOfType <MarkerScript>().ToList();
            erasers = FindObjectsOfType <EraserScript>().ToList();

            // Annotations
            path = string.Format("{0}Group{1}_Task{2}_AnnotationData.txt", filePath, groupID, tasks[taskID].taskName);
            annotationsStreamWriter = new StreamWriter(path, true);

            // Write header for annotation data
            annotationsStreamWriter.WriteLine("Timestamp\tOriginalOwner\tOwner\tPositions\tParentChart");
        }
        if (!isMasterLogger || (isMasterLogger && isLoggingPlayerData))
        {
            string path = string.Format("{0}Group{1}_Task{2}_Participant{3}_PlayerData.txt", filePath, groupID, tasks[taskID].taskName, participantID);
            playerStreamWriter = new StreamWriter(path, true);

            // Write header for player data
            playerStreamWriter.WriteLine("Timestamp\t" +
                                         "HeadPosition.x\tHeadPosition.y\tHeadPosition.z\t" +
                                         "HeadRotation.x\tHeadRotation.y\tHeadRotation.z\tHeadRotation.w\t" +
                                         "LeftPosition.x\tLeftPosition.y\tLeftPosition.z\t" +
                                         "LeftRotation.x\tLeftRotation.y\tLeftRotation.z\tLeftRotation.w\t" +
                                         "LeftTrigger\tLeftGrip\tLeftTouchpad\tLeftTouchpadAngle\t" +
                                         "RightPosition.x\tRightPosition.y\tRightPosition.z\t" +
                                         "RightRotation.x\tRightRotation.y\tRightRotation.z\tRightRotation.w\t" +
                                         "RightTrigger\tRightGrip\tRightTouchpad\tRightTouchpadAngle\t" +
                                         "GazeObject\tGazeObjectOriginalOwner\tGazeObjectOwner\tGazeObjectID\t" +
                                         "LeftPointObject\tLeftPointObjectOriginalOwner\tLeftPointObjectOwner\tLeftPointObjectID\t" +
                                         "RightPointObject\tRightPointObjectOriginalOwner\tRightPointObjectOwner\tRightPointObjectID");

            path = string.Format("{0}Group{1}_Task{2}_Participant{3}_ActionData.txt", filePath, groupID, tasks[taskID].taskName, participantID);
            actionsStreamWriter = new StreamWriter(path, true);

            // Write header for action data
            actionsStreamWriter.WriteLine("Timestamp\tObjectType\tOriginalOwner\tOwner\tName\tTargetID\tDescription");

            // Save references of logged entities
            headset               = VRTK_DeviceFinder.HeadsetTransform();
            leftController        = VRTK_DeviceFinder.GetControllerLeftHand().transform;
            rightController       = VRTK_DeviceFinder.GetControllerRightHand().transform;
            leftControllerEvents  = leftController.GetComponent <VRTK_ControllerEvents>();
            rightControllerEvents = rightController.GetComponent <VRTK_ControllerEvents>();
        }

        startTime     = info.SentServerTime;
        textMesh.text = string.Format("<b>{0}</b>\n{1}", taskName, taskDescription.Replace("\\n", "\n"));

        Debug.Log("Logging started");
    }
 private Vector3 GetValue(Recursion arg1)
 {
     return(VRTK_DeviceFinder.GetControllerAngularVelocity(Controller.GetValue <VRTK_ControllerReference>()));
 }
예제 #27
0
 // Use this for initialization
 void Start()
 {
     myAnimator = VRTK_DeviceFinder.GetControllerLeftHand().GetComponentInChildren <Animator>();
     GetComponent <VRTK_ControllerEvents>().TriggerAxisChanged += new ControllerInteractionEventHandler(DoTriggerAxisChanged);
 }
 private void OnEnable()
 {
     m_camera = VRTK_DeviceFinder.HeadsetCamera() != null?VRTK_DeviceFinder.HeadsetCamera().GetComponentInChildren <Camera>() : null;
 }
예제 #29
0
 private void OnEnable()
 {
     playArea = VRTK_DeviceFinder.PlayAreaTransform();
 }
예제 #30
0
 private void TriggerHapticPulses(float left, float right)
 {
     VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>().TriggerHapticPulse((ushort)(left * 3999));
     VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>().TriggerHapticPulse((ushort)(right * 3999));
 }