Пример #1
0
        /// <summary>
        /// The difference in velocity of the two controllers.
        /// </summary>
        /// <returns>A 3-dimensional vector, equal to the difference between the controller's [0] velocities in the x direction, [1] velocities in the y direction (float), and [2] velocities in the z direction (float).</returns>
        public Vector3 VelocityDelta()
        {
            Vector3 LeftVelocity  = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceLeftHand());
            Vector3 RightVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceRightHand());

            return(LeftVelocity - RightVelocity);
        }
Пример #2
0
        /// <summary>
        /// The dot product of the difference in velocity between the two controllers and their local distance. Can be used as a local scaling factor.
        /// </summary>
        /// <returns>A float that approximates a reasonable (neither too fast, nor too slow) local scaling factor.</returns>
        public float LocalScalingFactor()
        {
            Vector3 LeftVelocity  = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceLeftHand());
            Vector3 RightVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceRightHand());
            Vector3 VelocityDelta = LeftVelocity - RightVelocity;

            Vector3 LeftLocalPosition  = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController).localPosition;
            Vector3 RightLocalPosition = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController).localPosition;
            Vector3 localDistance      = LeftLocalPosition - RightLocalPosition;

            return(Vector3.Dot(VelocityDelta, localDistance));
        }
Пример #3
0
    private void Start()
    {
        Spawner  = FindObjectOfType <Spawner>();
        scoring  = FindObjectOfType <Scoring>();
        PPInGame = PostProcessingInGame.Instance;

        if (Color == COLOR.RED)
        {
            controllerReference = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
        }
        else
        {
            controllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand();
        }
    }
Пример #4
0
        IEnumerator Start()
        {
            yield return(null);

            // VRTKのSDKオートロードはせずに手動セットアップ
            string vrSystem = ApplicationSetting.Instance.GetString("VRSystem");
            int    sdkIndex = (int)DEVICE_TYPE.OCULUS;

            if (vrSystem.ToLower() == "oculus")
            {
                Debug.Log("select VR System [ Oculus ]");
                sdkIndex = (int)DEVICE_TYPE.OCULUS;

                deviceType = DEVICE_TYPE.OCULUS;
            }
            else if (vrSystem.ToLower() == "vive")
            {
                Debug.Log("select VR System [ VIVE ]");
                sdkIndex = (int)DEVICE_TYPE.VIVE;

                deviceType = DEVICE_TYPE.VIVE;
            }

            try
            {
                VRTK_SDKManager.instance.TryLoadSDKSetup(sdkIndex, true, VRTK_SDKManager.instance.setups);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                yield break;
            }

            // デバイス初期化に時間がかかるため、各デバイスのエイリアスが取得できるまで確認ループ
            while (!AllDeviceIsReady())
            {
                yield return(null); // 初期化完了待機 1フレ後に以下取得を確認

                // リグRoot
                vrRig = VRTK_DeviceFinder.PlayAreaTransform();

                // ヘッドセット
                headset = VRTK_DeviceFinder.HeadsetCamera();

                // 初期化時 左コントローラー → 右コントローラー の認識順
                leftControllerReference = VRTK_DeviceFinder.GetControllerReferenceLeftHand();
                GameObject leftHand = VRTK_DeviceFinder.GetControllerLeftHand(false);
                if (leftHand != null)
                {
                    leftControllerEvents = leftHand.GetComponent <VRTK_ControllerEvents>();
                }
                if (leftControllerEvents != null)
                {
                    leftControllerRoot = leftControllerEvents.transform.parent.gameObject;

                    if (deviceType == DEVICE_TYPE.OCULUS)
                    {
                        leftControllerModel = leftControllerRoot.transform.Find("LeftControllerAnchor").gameObject;
                    }
                    else if (deviceType == DEVICE_TYPE.VIVE)
                    {
                        leftControllerModel = leftControllerRoot.transform.Find("Model").gameObject;
                    }
                }

                rightControllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand();
                GameObject rightHand = VRTK_DeviceFinder.GetControllerRightHand(false);
                if (rightHand != null)
                {
                    rightControllerEvents = rightHand.GetComponent <VRTK_ControllerEvents>();
                }
                if (rightControllerEvents != null)
                {
                    rightControllerRoot = rightControllerEvents.transform.parent.gameObject;

                    if (deviceType == DEVICE_TYPE.OCULUS)
                    {
                        rightControllerModel = rightControllerRoot.transform.Find("RightControllerAnchor").gameObject;
                    }
                    else if (deviceType == DEVICE_TYPE.VIVE)
                    {
                        rightControllerModel = rightControllerRoot.transform.Find("Model").gameObject;
                    }
                }
            }

            isReady = true;

            yield break;
        }
Пример #5
0
 /// <summary>
 /// How fast the right controller is rotating in space.
 /// </summary>
 /// <returns>A 3-dimensional vector, equal to the right controller's counterclockwise angular velocity in the [0] x direction (float), [1] y direction (float), and [2] z direction (float).</returns>
 public Vector3 RightAngularVelocity()
 {
     return(VRTK_DeviceFinder.GetControllerAngularVelocity(VRTK_DeviceFinder.GetControllerReferenceRightHand()));
 }