Exemplo n.º 1
0
 /// <summary>
 /// The IsControllerRightHand method is used to check if a given controller game object is the right handed controller.
 /// </summary>
 /// <param name="checkController">The controller object that is being checked.</param>
 /// <returns>Is true if the given controller is the right controller.</returns>
 public static bool IsControllerRightHand(GameObject checkController)
 {
     return(VRTK_SDK_Bridge.IsControllerRightHand(checkController));
 }
Exemplo n.º 2
0
 private void ReleaseBlink()
 {
     VRTK_SDK_Bridge.HeadsetFade(Color.clear, fadeInTime);
     fadeInTime = 0f;
 }
        private void UpdateRenderScale()
        {
            if (!active)
            {
                SetRenderScale(1.0f, 1.0f);
                return;
            }

            // Add latest timing to ring buffer
            frameTimeRingBufferIndex = (frameTimeRingBufferIndex + 1) % frameTimeRingBuffer.Length;
            frameTimeRingBuffer[frameTimeRingBufferIndex] = VRStats.gpuTimeLastFrame;

            // Rendering in low resolution means adaptive quality needs to scale back the render scale target to free up gpu cycles
            bool renderInLowResolution = VRTK_SDK_Bridge.ShouldAppRenderWithLowResources();

            // Thresholds
            float thresholdModifier = renderInLowResolution
                                      ? singleFrameDurationInMilliseconds * 0.75f
                                      : singleFrameDurationInMilliseconds;
            float lowThresholdInMilliseconds           = 0.7f * thresholdModifier;
            float extrapolationThresholdInMilliseconds = 0.85f * thresholdModifier;
            float highThresholdInMilliseconds          = 0.9f * thresholdModifier;

            // Get latest 3 frames
            float frameMinus0 = frameTimeRingBuffer[(frameTimeRingBufferIndex - 0 + frameTimeRingBuffer.Length) % frameTimeRingBuffer.Length];
            float frameMinus1 = frameTimeRingBuffer[(frameTimeRingBufferIndex - 1 + frameTimeRingBuffer.Length) % frameTimeRingBuffer.Length];
            float frameMinus2 = frameTimeRingBuffer[(frameTimeRingBufferIndex - 2 + frameTimeRingBuffer.Length) % frameTimeRingBuffer.Length];

            int previousLevel = currentRenderScaleLevel;

            // Always drop 2 levels except when dropping from level 2
            int dropTargetLevel = previousLevel == 2 ? 1 : previousLevel - 2;
            int newLevel        = Mathf.Clamp(dropTargetLevel, 0, allRenderScales.Count - 1);

            // Ignore frame timings if overriding
            if (overrideRenderScale)
            {
                currentRenderScaleLevel = overrideRenderScaleLevel;
            }
            // Rapidly reduce quality 2 levels if last frame was critical
            else if (Time.frameCount >= lastRenderScaleChangeFrameCount + 2 + 1 &&
                     frameMinus0 > highThresholdInMilliseconds &&
                     newLevel != previousLevel)
            {
                currentRenderScaleLevel         = newLevel;
                lastRenderScaleChangeFrameCount = Time.frameCount;
            }
            // Rapidly reduce quality 2 levels if last 3 frames are expensive
            else if (Time.frameCount >= lastRenderScaleChangeFrameCount + 2 + 3 &&
                     frameMinus0 > highThresholdInMilliseconds &&
                     frameMinus1 > highThresholdInMilliseconds &&
                     frameMinus2 > highThresholdInMilliseconds &&
                     newLevel != previousLevel)
            {
                currentRenderScaleLevel         = newLevel;
                lastRenderScaleChangeFrameCount = Time.frameCount;
            }
            // Predict next frame's cost using linear extrapolation: max(frame-1 to frame+1, frame-2 to frame+1)
            else if (Time.frameCount >= lastRenderScaleChangeFrameCount + 2 + 2 &&
                     frameMinus0 > extrapolationThresholdInMilliseconds)
            {
                float frameDelta = frameMinus0 - frameMinus1;

                // Use frame-2 if it's available
                if (Time.frameCount >= lastRenderScaleChangeFrameCount + 2 + 3)
                {
                    float frameDelta2 = (frameMinus0 - frameMinus2) * 0.5f;
                    frameDelta = Mathf.Max(frameDelta, frameDelta2);
                }

                if (frameMinus0 + frameDelta > highThresholdInMilliseconds &&
                    newLevel != previousLevel)
                {
                    currentRenderScaleLevel         = newLevel;
                    lastRenderScaleChangeFrameCount = Time.frameCount;
                }
            }
            else
            {
                // Increase quality 1 level if last 3 frames are cheap
                newLevel = Mathf.Clamp(previousLevel + 1, 0, allRenderScales.Count - 1);
                if (Time.frameCount >= lastRenderScaleChangeFrameCount + 2 + 3 &&
                    frameMinus0 < lowThresholdInMilliseconds &&
                    frameMinus1 < lowThresholdInMilliseconds &&
                    frameMinus2 < lowThresholdInMilliseconds &&
                    newLevel != previousLevel)
                {
                    currentRenderScaleLevel         = newLevel;
                    lastRenderScaleChangeFrameCount = Time.frameCount;
                }
            }

            // Force on interleaved reprojection for level 0 which is just a replica of level 1 with reprojection enabled
            float additionalViewportScale = 1.0f;

            if (!hmdDisplayIsOnDesktop)
            {
                if (currentRenderScaleLevel == 0)
                {
                    if (interleavedReprojectionEnabled && frameMinus0 < singleFrameDurationInMilliseconds * 0.85f)
                    {
                        interleavedReprojectionEnabled = false;
                    }
                    else if (frameMinus0 > singleFrameDurationInMilliseconds * 0.925f)
                    {
                        interleavedReprojectionEnabled = true;
                    }
                }
                else
                {
                    interleavedReprojectionEnabled = false;
                }

                VRTK_SDK_Bridge.ForceInterleavedReprojectionOn(interleavedReprojectionEnabled);
            }
            // Not running in direct mode! Interleaved reprojection not supported, so scale down the viewport
            else if (currentRenderScaleLevel == 0)
            {
                additionalViewportScale = 0.8f;
            }

            float newRenderScale         = allRenderScales[allRenderScales.Count - 1];
            float newRenderViewportScale = allRenderScales[currentRenderScaleLevel] / newRenderScale * additionalViewportScale;

            SetRenderScale(newRenderScale, newRenderViewportScale);
        }
Exemplo n.º 4
0
 public VRTK_ControllerReference(SDK_BaseController.ControllerHand controllerHand)
 {
     storedControllerIndex = VRTK_SDK_Bridge.GetControllerIndex(GetValidObjectFromHand(controllerHand));
     AddToCache();
 }
Exemplo n.º 5
0
 protected virtual void ReleaseBlink()
 {
     VRTK_SDK_Bridge.HeadsetFade(Color.clear, fadeInTime);
     fadeInTime = 0f;
 }
Exemplo n.º 6
0
        protected virtual GameObject GetValidObjectFromIndex()
        {
            GameObject checkObject = VRTK_SDK_Bridge.GetControllerByIndex(storedControllerIndex, false);

            return(checkObject == null ? VRTK_SDK_Bridge.GetControllerByIndex(storedControllerIndex, true) : checkObject);
        }
Exemplo n.º 7
0
 private static SDK_BaseController.ControllerHand GetControllerHand(GameObject controllerObject)
 {
     if (VRTK_SDK_Bridge.IsControllerLeftHand(controllerObject, false) || VRTK_SDK_Bridge.IsControllerLeftHand(controllerObject, true))
     {
         return(SDK_BaseController.ControllerHand.Left);
     }
     else if (VRTK_SDK_Bridge.IsControllerRightHand(controllerObject, false) || VRTK_SDK_Bridge.IsControllerRightHand(controllerObject, true))
     {
         return(SDK_BaseController.ControllerHand.Right);
     }
     return(VRTK_SDK_Bridge.GetControllerModelHand(controllerObject));
 }
Exemplo n.º 8
0
 /// <summary>
 /// The GetCurrentControllerType method returns the current used ControllerType based on the SDK and headset being used.
 /// </summary>
 /// <returns>The ControllerType based on the SDK and headset being used.</returns>
 public static SDK_BaseController.ControllerType GetCurrentControllerType()
 {
     return(VRTK_SDK_Bridge.GetCurrentControllerType());
 }
Exemplo n.º 9
0
 /// <summary>
 /// The GetControllerIndex method is used to find the index of a given controller object.
 /// </summary>
 /// <param name="controller">The controller object to get the index of a controller.</param>
 /// <returns>The index of the given controller.</returns>
 public static uint GetControllerIndex(GameObject controller)
 {
     return(VRTK_SDK_Bridge.GetControllerIndex(controller));
 }
Exemplo n.º 10
0
 /// <summary>
 /// The HeadsetCamera method is used to retrieve the transform for the VR Camera in the scene.
 /// </summary>
 /// <returns>The transform of the VR Camera component.</returns>
 public static Transform HeadsetCamera()
 {
     return(VRTK_SDK_Bridge.GetHeadsetCamera());
 }
Exemplo n.º 11
0
 /// <summary>
 /// The PlayAreaTransform method is used to retrieve the transform for the play area in the scene.
 /// </summary>
 /// <returns>The transform of the VR Play Area component.</returns>
 public static Transform PlayAreaTransform()
 {
     return(VRTK_SDK_Bridge.GetPlayArea());
 }
Exemplo n.º 12
0
 /// <summary>
 /// The GetHeadsetAngularVelocity method is used to determine the current angular velocity of the headset.
 /// </summary>
 /// <returns>A Vector3 containing the current angular velocity of the headset.</returns>
 public static Vector3 GetHeadsetAngularVelocity()
 {
     return(VRTK_SDK_Bridge.GetHeadsetAngularVelocity());
 }
Exemplo n.º 13
0
 /// <summary>
 /// The GetControllerAngularVelocity method is used for getting the current rotational velocity of the physical game controller. This can be useful for determining which way the controller is being rotated and at what speed the rotation is occurring.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller.</param>
 /// <returns>A 3 dimensional vector containing the current real world physical controller angular (rotational) velocity.</returns>
 public static Vector3 GetControllerAngularVelocity(VRTK_ControllerReference controllerReference)
 {
     return(VRTK_SDK_Bridge.GetControllerAngularVelocity(controllerReference));
 }
Exemplo n.º 14
0
 /// <summary>
 /// The GetModelAliasController method will attempt to get the object that contains the model for the controller.
 /// </summary>
 /// <param name="givenController">The GameObject of the controller.</param>
 /// <returns>The GameObject that is the alias controller containing the controller model.</returns>
 public static GameObject GetModelAliasController(GameObject givenController)
 {
     return(VRTK_SDK_Bridge.GetControllerModel(givenController));
 }
Exemplo n.º 15
0
        private void UpdateRenderScale()
        {
            if (allRenderScales.Count == 0)
            {
                return;
            }

            if (!scaleRenderViewport)
            {
                renderViewportScaleSetting.currentValue = defaultRenderViewportScaleLevel;
                renderScaleSetting.currentValue         = defaultRenderViewportScaleLevel;
                SetRenderScale(1.0f, 1.0f);

                return;
            }

            // Rendering in low resolution means adaptive quality needs to scale back the render scale target to free up gpu cycles
            bool renderInLowResolution = VRTK_SDK_Bridge.ShouldAppRenderWithLowResources();

            // Thresholds
            float allowedSingleFrameDurationInMilliseconds = renderInLowResolution
                                                             ? singleFrameDurationInMilliseconds * 0.75f
                                                             : singleFrameDurationInMilliseconds;
            float lowThresholdInMilliseconds           = 0.7f * allowedSingleFrameDurationInMilliseconds;
            float extrapolationThresholdInMilliseconds = 0.85f * allowedSingleFrameDurationInMilliseconds;
            float highThresholdInMilliseconds          = 0.9f * allowedSingleFrameDurationInMilliseconds;

            int newRenderViewportScaleLevel = renderViewportScaleSetting.currentValue;

            // Rapidly reduce render viewport scale level if cost of last 1 or 3 frames, or the predicted next frame's cost are expensive
            if (timing.WasFrameTimingBad(
                    1,
                    highThresholdInMilliseconds,
                    renderViewportScaleSetting.lastChangeFrameCount,
                    renderViewportScaleSetting.decreaseFrameCost) ||
                timing.WasFrameTimingBad(
                    3,
                    highThresholdInMilliseconds,
                    renderViewportScaleSetting.lastChangeFrameCount,
                    renderViewportScaleSetting.decreaseFrameCost) ||
                timing.WillFrameTimingBeBad(
                    extrapolationThresholdInMilliseconds,
                    highThresholdInMilliseconds,
                    renderViewportScaleSetting.lastChangeFrameCount,
                    renderViewportScaleSetting.decreaseFrameCost))
            {
                // Always drop 2 levels except when dropping from level 2 (level 0 is for reprojection)
                newRenderViewportScaleLevel = ClampRenderScaleLevel(renderViewportScaleSetting.currentValue == 2
                                                                    ? 1
                                                                    : renderViewportScaleSetting.currentValue - 2);
            }
            // Rapidly increase render viewport scale level if last 12 frames are cheap
            else if (timing.WasFrameTimingGood(
                         12,
                         lowThresholdInMilliseconds,
                         renderViewportScaleSetting.lastChangeFrameCount - renderViewportScaleSetting.increaseFrameCost,
                         renderViewportScaleSetting.increaseFrameCost))
            {
                newRenderViewportScaleLevel = ClampRenderScaleLevel(renderViewportScaleSetting.currentValue + 2);
            }
            // Slowly increase render viewport scale level if last 6 frames are cheap
            else if (timing.WasFrameTimingGood(
                         6,
                         lowThresholdInMilliseconds,
                         renderViewportScaleSetting.lastChangeFrameCount,
                         renderViewportScaleSetting.increaseFrameCost))
            {
                // Only increase by 1 level to prevent frame drops caused by adjusting
                newRenderViewportScaleLevel = ClampRenderScaleLevel(renderViewportScaleSetting.currentValue + 1);
            }

            // Apply and remember when render viewport scale level changed
            if (newRenderViewportScaleLevel != renderViewportScaleSetting.currentValue)
            {
                if (renderViewportScaleSetting.currentValue >= renderScaleSetting.currentValue &&
                    newRenderViewportScaleLevel < renderScaleSetting.currentValue)
                {
                    lastRenderViewportScaleLevelBelowRenderScaleLevelFrameCount = Time.frameCount;
                }

                renderViewportScaleSetting.currentValue = newRenderViewportScaleLevel;
            }

            // Ignore frame timings if overriding
            if (overrideRenderViewportScale)
            {
                renderViewportScaleSetting.currentValue = overrideRenderViewportScaleLevel;
            }

            // Force on interleaved reprojection for level 0 which is just a replica of level 1 with reprojection enabled
            float additionalViewportScale = 1.0f;

            if (!hmdDisplayIsOnDesktop)
            {
                if (renderViewportScaleSetting.currentValue == 0)
                {
                    if (interleavedReprojectionEnabled && timing.GetFrameTiming(0) < singleFrameDurationInMilliseconds * 0.85f)
                    {
                        interleavedReprojectionEnabled = false;
                    }
                    else if (timing.GetFrameTiming(0) > singleFrameDurationInMilliseconds * 0.925f)
                    {
                        interleavedReprojectionEnabled = true;
                    }
                }
                else
                {
                    interleavedReprojectionEnabled = false;
                }

                VRTK_SDK_Bridge.ForceInterleavedReprojectionOn(interleavedReprojectionEnabled);
            }
            // Not running in direct mode! Interleaved reprojection not supported, so scale down the viewport some more
            else if (renderViewportScaleSetting.currentValue == 0)
            {
                additionalViewportScale = 0.8f;
            }

            int newRenderScaleLevel = renderScaleSetting.currentValue;
            int levelInBetween      = (renderViewportScaleSetting.currentValue - renderScaleSetting.currentValue) / 2;

            // Increase render scale level to the level in between
            if (renderScaleSetting.currentValue < renderViewportScaleSetting.currentValue &&
                Time.frameCount >= renderScaleSetting.lastChangeFrameCount + renderScaleSetting.increaseFrameCost)
            {
                newRenderScaleLevel = ClampRenderScaleLevel(renderScaleSetting.currentValue + Mathf.Max(1, levelInBetween));
            }
            // Decrease render scale level
            else if (renderScaleSetting.currentValue > renderViewportScaleSetting.currentValue &&
                     Time.frameCount >= renderScaleSetting.lastChangeFrameCount + renderScaleSetting.decreaseFrameCost &&
                     Time.frameCount >= lastRenderViewportScaleLevelBelowRenderScaleLevelFrameCount + renderViewportScaleSetting.increaseFrameCost)
            {
                // Slowly decrease render scale level to level in between if last 6 frames are cheap, otherwise rapidly
                newRenderScaleLevel = timing.WasFrameTimingGood(6, lowThresholdInMilliseconds, 0, 0)
                                      ? ClampRenderScaleLevel(renderScaleSetting.currentValue + Mathf.Min(-1, levelInBetween))
                                      : renderViewportScaleSetting.currentValue;
            }

            // Apply and remember when render scale level changed
            renderScaleSetting.currentValue = newRenderScaleLevel;

            if (!scaleRenderTargetResolution)
            {
                renderScaleSetting.currentValue = allRenderScales.Count - 1;
            }

            float newRenderScale         = allRenderScales[renderScaleSetting.currentValue];
            float newRenderViewportScale = allRenderScales[Mathf.Min(renderViewportScaleSetting.currentValue, renderScaleSetting.currentValue)]
                                           / newRenderScale * additionalViewportScale;

            SetRenderScale(newRenderScale, newRenderViewportScale);
        }
Exemplo n.º 16
0
 /// <summary>
 /// The GetControllerByIndex method is used to find a controller based on it's unique index.
 /// </summary>
 /// <param name="index">The index of the actual controller to find.</param>
 /// <param name="getActual">An optional parameter that if true will return the game object that the SDK controller is attached to.</param>
 /// <returns>The actual controller GameObject that matches the given index.</returns>
 public static GameObject GetControllerByIndex(uint index, bool getActual)
 {
     return(VRTK_SDK_Bridge.GetControllerByIndex(index, getActual));
 }
Exemplo n.º 17
0
        private void InitPlayAreaCursor()
        {
            var btmRightInner = 0;
            var btmLeftInner  = 1;
            var topLeftInner  = 2;
            var topRightInner = 3;

            var btmRightOuter = 4;
            var btmLeftOuter  = 5;
            var topLeftOuter  = 6;
            var topRightOuter = 7;

            Vector3[] cursorDrawVertices = VRTK_SDK_Bridge.GetPlayAreaVertices(playArea.gameObject);

            if (playAreaCursorDimensions != Vector2.zero)
            {
                var customAreaPadding = VRTK_SDK_Bridge.GetPlayAreaBorderThickness(playArea.gameObject);

                cursorDrawVertices[btmRightOuter] = new Vector3(playAreaCursorDimensions.x / 2, 0f, (playAreaCursorDimensions.y / 2) * -1);
                cursorDrawVertices[btmLeftOuter]  = new Vector3((playAreaCursorDimensions.x / 2) * -1, 0f, (playAreaCursorDimensions.y / 2) * -1);
                cursorDrawVertices[topLeftOuter]  = new Vector3((playAreaCursorDimensions.x / 2) * -1, 0f, playAreaCursorDimensions.y / 2);
                cursorDrawVertices[topRightOuter] = new Vector3(playAreaCursorDimensions.x / 2, 0f, playAreaCursorDimensions.y / 2);

                cursorDrawVertices[btmRightInner] = cursorDrawVertices[btmRightOuter] + new Vector3(-customAreaPadding, 0f, customAreaPadding);
                cursorDrawVertices[btmLeftInner]  = cursorDrawVertices[btmLeftOuter] + new Vector3(customAreaPadding, 0f, customAreaPadding);
                cursorDrawVertices[topLeftInner]  = cursorDrawVertices[topLeftOuter] + new Vector3(customAreaPadding, 0f, -customAreaPadding);
                cursorDrawVertices[topRightInner] = cursorDrawVertices[topRightOuter] + new Vector3(-customAreaPadding, 0f, -customAreaPadding);
            }

            var width  = cursorDrawVertices[btmRightOuter].x - cursorDrawVertices[topLeftOuter].x;
            var length = cursorDrawVertices[topLeftOuter].z - cursorDrawVertices[btmRightOuter].z;
            var height = 0.01f;

            playAreaCursor      = GameObject.CreatePrimitive(PrimitiveType.Cube);
            playAreaCursor.name = string.Format("[{0}]WorldPointer_PlayAreaCursor", gameObject.name);
            Utilities.SetPlayerObject(playAreaCursor, VRTK_PlayerObject.ObjectTypes.Pointer);
            playAreaCursor.transform.parent     = null;
            playAreaCursor.transform.localScale = new Vector3(width, height, length);
            playAreaCursor.SetActive(false);

            playAreaCursor.GetComponent <Renderer>().enabled = false;

            CreateCursorCollider(playAreaCursor);

            playAreaCursor.AddComponent <Rigidbody>().isKinematic = true;

            var playAreaCursorScript = playAreaCursor.AddComponent <VRTK_PlayAreaCollider>();

            playAreaCursorScript.SetParent(gameObject);
            playAreaCursorScript.SetIgnoreTarget(ignoreTargetWithTagOrClass, targetTagOrScriptListPolicy);
            playAreaCursor.layer = LayerMask.NameToLayer("Ignore Raycast");

            var playAreaBoundaryX = playArea.transform.localScale.x / 2;
            var playAreaBoundaryZ = playArea.transform.localScale.z / 2;
            var heightOffset      = 0f;

            DrawPlayAreaCursorBoundary(0, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmRightOuter].x, cursorDrawVertices[btmRightInner].z, cursorDrawVertices[btmRightOuter].z, height, new Vector3(0f, heightOffset, playAreaBoundaryZ));
            DrawPlayAreaCursorBoundary(1, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmLeftInner].x, cursorDrawVertices[topLeftOuter].z, cursorDrawVertices[btmLeftOuter].z, height, new Vector3(playAreaBoundaryX, heightOffset, 0f));
            DrawPlayAreaCursorBoundary(2, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmRightOuter].x, cursorDrawVertices[btmRightInner].z, cursorDrawVertices[btmRightOuter].z, height, new Vector3(0f, heightOffset, -playAreaBoundaryZ));
            DrawPlayAreaCursorBoundary(3, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmLeftInner].x, cursorDrawVertices[topLeftOuter].z, cursorDrawVertices[btmLeftOuter].z, height, new Vector3(-playAreaBoundaryX, heightOffset, 0f));
        }
Exemplo n.º 18
0
 /// <summary>
 /// The GetControllerOrigin method is used to find the controller's origin.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to get the origin for.</param>
 /// <returns>The transform of the controller origin or if an origin is not set then the transform parent.</returns>
 public static Transform GetControllerOrigin(VRTK_ControllerReference controllerReference)
 {
     return(VRTK_SDK_Bridge.GetControllerOrigin(controllerReference));
 }
Exemplo n.º 19
0
        private static GameObject GetValidObjectFromHand(SDK_BaseController.ControllerHand controllerHand)
        {
            switch (controllerHand)
            {
            case SDK_BaseController.ControllerHand.Left:
                return(VRTK_SDK_Bridge.GetControllerLeftHand(false) ? VRTK_SDK_Bridge.GetControllerLeftHand(false) : VRTK_SDK_Bridge.GetControllerLeftHand(true));

            case SDK_BaseController.ControllerHand.Right:
                return(VRTK_SDK_Bridge.GetControllerRightHand(false) ? VRTK_SDK_Bridge.GetControllerRightHand(false) : VRTK_SDK_Bridge.GetControllerRightHand(true));
            }
            return(null);
        }
Exemplo n.º 20
0
 protected virtual void FixedUpdate()
 {
     VRTK_SDK_Bridge.HeadsetProcessFixedUpdate();
 }
Exemplo n.º 21
0
        public static VRTK_ControllerReference GetControllerReference(GameObject controllerObject)
        {
            //Try and get the index from either the actual or alias
            uint controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(controllerObject);

            //If not found then try and get index from the model object
            if (controllerIndex >= uint.MaxValue)
            {
                controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(GetValidObjectFromHand(VRTK_SDK_Bridge.GetControllerModelHand(controllerObject)));
            }

            VRTK_ControllerReference foundReference = VRTK_SharedMethods.GetDictionaryValue(controllerReferences, controllerIndex);

            if (foundReference != null)
            {
                return(foundReference);
            }
            return(new VRTK_ControllerReference(controllerIndex));
        }
Exemplo n.º 22
0

        
Exemplo n.º 23
0
 protected virtual void Awake()
 {
     destroyColliderOnDisable = false;
     SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject);
     defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand));
 }
Exemplo n.º 24
0

        
Exemplo n.º 25
0
 protected virtual void Blink(float transitionSpeed)
 {
     fadeInTime = transitionSpeed;
     VRTK_SDK_Bridge.HeadsetFade(Color.black, 0);
     Invoke("ReleaseBlink", blinkPause);
 }
 /// <summary>
 /// The GetControllerOrigin method returns the origin of the given controller.
 /// </summary>
 /// <param name="controllerReference">The reference to the controller to retrieve the origin from.</param>
 /// <returns>A Transform containing the origin of the controller.</returns>
 public override Transform GetControllerOrigin(VRTK_ControllerReference controllerReference)
 {
     return(VRTK_SDK_Bridge.GetPlayArea());
 }
Exemplo n.º 27
0
 protected virtual void LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e)
 {
     CheckControllersReady();
     previousControllerSDK = VRTK_SDK_Bridge.GetControllerSDK();
 }
Exemplo n.º 28
0
        // Token: 0x060016E7 RID: 5863 RVA: 0x0007B184 File Offset: 0x00079384
        public static VRTK_ControllerReference GetControllerReference(GameObject controllerObject)
        {
            uint controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(controllerObject);

            if (controllerIndex >= 4294967295U)
            {
                controllerIndex = VRTK_SDK_Bridge.GetControllerIndex(VRTK_ControllerReference.GetValidObjectFromHand(VRTK_SDK_Bridge.GetControllerModelHand(controllerObject)));
            }
            if (VRTK_ControllerReference.controllerReferences.ContainsKey(controllerIndex))
            {
                return(VRTK_ControllerReference.controllerReferences[controllerIndex]);
            }
            return(new VRTK_ControllerReference(controllerIndex));
        }
Exemplo n.º 29
0
 /// <summary>
 /// The GetControllerLeftHand method retrieves the game object for the left hand controller.
 /// </summary>
 /// <param name="getActual">An optional parameter that if true will return the game object that the SDK controller is attached to.</param>
 /// <returns>The left hand controller.</returns>
 public static GameObject GetControllerLeftHand(bool getActual = false)
 {
     return(VRTK_SDK_Bridge.GetControllerLeftHand(getActual));
 }
Exemplo n.º 30
0
 /// <summary>
 /// The GetControllerOrigin method returns the origin of the given controller.
 /// </summary>
 /// <param name="controller">The controller to retrieve the origin from.</param>
 /// <returns>A Transform containing the origin of the controller.</returns>
 public override Transform GetControllerOrigin(GameObject controller)
 {
     return(VRTK_SDK_Bridge.GetPlayArea());
 }