Example #1
0
        /// <summary>
        /// Should the Menu on the given side open. Pose must been between cetain values for a certain amount of time for the menu to open.
        /// Should the minimum value be bigger than the maximum, the spectrum throu the zero degree point is used.
        /// </summary>
        /// <param name="hand">The hand to check</param>
        /// <param name="minX">The minimum X rotation the controller must be in for the menu to open</param>
        /// <param name="maxX">The maximum X rotation the controller must be in for the menu to open</param>
        /// <param name="minZ">The minimum Z rotation the controller must be in for the menu to open</param>
        /// <param name="maxZ">The maximum Z rotation the controller must be in for the menu to open</param>
        /// <returns>True is the menu should open</returns>
        private bool ShouldShowMenu(SteamVR_Input_Sources hand, float minX, float maxX, float minZ, float maxZ)
        {
            for (int i = 0; i < 5; i++)
            {
                Pose.GetPoseAtTimeOffset(hand, (float)i / 5, out Vector3 position, out Quaternion rotation, out Vector3 velocity, out Vector3 angularVelocity);

                if (!IsBetween(minX, maxX, rotation.eulerAngles.x) || !IsBetween(minZ, maxZ, rotation.eulerAngles.z))
                {
                    return(false);
                }
            }

            if (rightHand.currentAttachedObject != null || rightHand.hoveringInteractable != null || leftHand.currentAttachedObject != null || leftHand.hoveringInteractable != null)
            {
                return(false);
            }
            return(true);
        }