GetControllerOrientationTracked() публичный статический Метод

Returns true if the given Controller's orientation is currently tracked. Only supported for Oculus LTouch and RTouch controllers. Non-tracked controllers will return false.
public static GetControllerOrientationTracked ( OVRInput, controllerType ) : bool
controllerType OVRInput,
Результат bool
Пример #1
0
        /// Updates IsTrackedObjectValid and Behavior.transform
        public void UpdatePosesAndValidity()
        {
            // OVRInput.Controller.Touch checks both (LTouch | RTouch)
            bool bothTouchControllersConnected =
                (OVRInput.GetConnectedControllers() & OVRInput.Controller.Touch)
                == OVRInput.Controller.Touch;

            OVRInput.Controller input = m_ControllerType;
            IsTrackedObjectValid = OVRInput.GetControllerOrientationTracked(input) ||
                                   OVRInput.GetControllerPositionTracked(input) &&
                                   bothTouchControllersConnected;
            Transform t = Behavior.transform;

            t.localRotation = OVRInput.GetLocalControllerRotation(input);
            t.localPosition = OVRInput.GetLocalControllerPosition(input);
        }
Пример #2
0
        bool IsTracked_Oculus()
        {
            if (string.IsNullOrEmpty(context.Data.trackedByDevice))
            {
                return(false);
            }

            try {
                OVRInput.Controller controller = OVRInput.Controller.None;
                if (context.Data.trackedByDevice == "Device1")
                {
                    controller = OVRInput.Controller.LTouch;
                }
                else if (context.Data.trackedByDevice == "Device2")
                {
                    controller = OVRInput.Controller.RTouch;
                }

                return(OVRInput.IsControllerConnected(controller) && OVRInput.GetControllerPositionTracked(controller) && OVRInput.GetControllerOrientationTracked(controller));
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
Пример #3
0
        private bool IsOculusTouchTrackingBone(HumanBodyBones bone)
        {
            // We assume that the left controller is used to track bones on the left side
            // and the right controller is used to track the bones on the right side
            switch (bone)
            {
            // Left bones
            case HumanBodyBones.LeftEye:
            case HumanBodyBones.LeftShoulder:
            case HumanBodyBones.LeftUpperLeg:
            case HumanBodyBones.LeftLowerLeg:
            case HumanBodyBones.LeftFoot:
            case HumanBodyBones.LeftToes:
            case HumanBodyBones.LeftUpperArm:
            case HumanBodyBones.LeftLowerArm:
            case HumanBodyBones.LeftHand:
            case HumanBodyBones.LeftIndexDistal:
            case HumanBodyBones.LeftIndexIntermediate:
            case HumanBodyBones.LeftIndexProximal:
            case HumanBodyBones.LeftLittleDistal:
            case HumanBodyBones.LeftLittleIntermediate:
            case HumanBodyBones.LeftLittleProximal:
            case HumanBodyBones.LeftMiddleDistal:
            case HumanBodyBones.LeftMiddleIntermediate:
            case HumanBodyBones.LeftMiddleProximal:
            case HumanBodyBones.LeftRingDistal:
            case HumanBodyBones.LeftRingIntermediate:
            case HumanBodyBones.LeftRingProximal:
            case HumanBodyBones.LeftThumbDistal:
            case HumanBodyBones.LeftThumbIntermediate:
            case HumanBodyBones.LeftThumbProximal:
                return(OVRInput.GetControllerPositionTracked(OVRInput.Controller.LTouch) && OVRInput.GetControllerOrientationTracked(OVRInput.Controller.LTouch));

            // Right bones
            case HumanBodyBones.RightEye:
            case HumanBodyBones.RightShoulder:

            case HumanBodyBones.RightUpperLeg:
            case HumanBodyBones.RightLowerLeg:
            case HumanBodyBones.RightFoot:
            case HumanBodyBones.RightToes:

            case HumanBodyBones.RightUpperArm:
            case HumanBodyBones.RightLowerArm:
            case HumanBodyBones.RightHand:
            case HumanBodyBones.RightIndexDistal:
            case HumanBodyBones.RightIndexIntermediate:
            case HumanBodyBones.RightIndexProximal:
            case HumanBodyBones.RightLittleDistal:
            case HumanBodyBones.RightLittleIntermediate:
            case HumanBodyBones.RightLittleProximal:
            case HumanBodyBones.RightMiddleDistal:
            case HumanBodyBones.RightMiddleIntermediate:
            case HumanBodyBones.RightMiddleProximal:
            case HumanBodyBones.RightRingDistal:
            case HumanBodyBones.RightRingIntermediate:
            case HumanBodyBones.RightRingProximal:
            case HumanBodyBones.RightThumbDistal:
            case HumanBodyBones.RightThumbIntermediate:
            case HumanBodyBones.RightThumbProximal:
                return(OVRInput.GetControllerPositionTracked(OVRInput.Controller.RTouch) && OVRInput.GetControllerOrientationTracked(OVRInput.Controller.RTouch));

            default:
                Debug.LogWarningFormat("IKTarget IsOculusTouchTrackingBone: Invalid bone for Oculus Touch: {0} - returning false", bone);
                return(false);
            }
        }
        bool GetTrackedTransform_Oculus(out Vector3 pos, out Quaternion rot)
        {
            pos = Vector3.zero;
            rot = Quaternion.identity;

            if (string.IsNullOrEmpty(context.Data.trackedByDevice))
            {
                return(false);
            }

            try
            {
                OVRInput.Controller controller = OVRInput.Controller.None;
                if (context.Data.trackedByDevice == "Device1")
                {
                    controller = OVRInput.Controller.LTouch;
                }
                else if (context.Data.trackedByDevice == "Device2")
                {
                    controller = OVRInput.Controller.RTouch;
                }

                if (!OVRInput.IsControllerConnected(controller) || !OVRInput.GetControllerPositionTracked(controller) || !OVRInput.GetControllerOrientationTracked(controller))
                {
                    return(false);
                }

                pos = OVRInput.GetLocalControllerPosition(controller);
                rot = OVRInput.GetLocalControllerRotation(controller);

                if (trackedByOculusDevice != context.Data.trackedByDevice)
                {
                    trackedByOculusDevice = context.Data.trackedByDevice;

                    OnTrackedDeviceSwitchAndReady();
                }

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }