public KinectAbsoluteScreenspaceCursor(KinectService Kinect, Handedness hand, Game1 MyGame)
 {
     myGame = MyGame;
     kinect = Kinect;
     handSelect = hand;
     kinect.RegisterKinectListener(this);
     _rect = new Rectangle();
     _rect.Width = 48;
     _rect.Height = 48;
     _position = new Vector2();
     bodySpace = new Rectangle();
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public HandData PostProcess(Handedness handedness, HandData handData)
        {
            if (handData.TrackingState == TrackingState.Tracked)
            {
                // Gather needed data for calculations.
                var palmPose               = handData.Joints[(int)TrackedHandJoint.Palm];
                var palmLookRotation       = Quaternion.LookRotation(palmPose.Forward, palmPose.Up);
                var thumbMetacarpalPose    = handData.Joints[(int)TrackedHandJoint.ThumbMetacarpal];
                var thumbProximalPose      = handData.Joints[(int)TrackedHandJoint.ThumbProximal];
                var indexProximalPose      = handData.Joints[(int)TrackedHandJoint.IndexProximal];
                var indexIntermediatePose  = handData.Joints[(int)TrackedHandJoint.IndexIntermediate];
                var middleProximalPose     = handData.Joints[(int)TrackedHandJoint.MiddleProximal];
                var middleIntermediatePose = handData.Joints[(int)TrackedHandJoint.MiddleIntermediate];
                var ringProximalPose       = handData.Joints[(int)TrackedHandJoint.RingProximal];
                var ringIntermediatePose   = handData.Joints[(int)TrackedHandJoint.RingIntermediate];
                var littleProximalPose     = handData.Joints[(int)TrackedHandJoint.LittleProximal];
                var littleIntermediatePose = handData.Joints[(int)TrackedHandJoint.LittleIntermediate];

                // Calculate per finger curl angles.
                var thumbMetacarpalCurl    = Quaternion.Angle(palmLookRotation, thumbMetacarpalPose.Rotation);
                var thumbProximalCurl      = Quaternion.Angle(palmLookRotation, thumbProximalPose.Rotation);
                var indexProximalCurl      = Quaternion.Angle(palmLookRotation, indexProximalPose.Rotation);
                var indexIntermediateCurl  = Quaternion.Angle(palmLookRotation, indexIntermediatePose.Rotation);
                var middleProximalCurl     = Quaternion.Angle(palmLookRotation, middleProximalPose.Rotation);
                var middleIntermediateCurl = Quaternion.Angle(palmLookRotation, middleIntermediatePose.Rotation);
                var ringProximalCurl       = Quaternion.Angle(palmLookRotation, ringProximalPose.Rotation);
                var ringIntermediateCurl   = Quaternion.Angle(palmLookRotation, ringIntermediatePose.Rotation);
                var littleProximalCurl     = Quaternion.Angle(palmLookRotation, littleProximalPose.Rotation);
                var littleIntermediateCurl = Quaternion.Angle(palmLookRotation, littleIntermediatePose.Rotation);

                // Grip strength is defined as the total traveled curl distance for the intermediate joints
                // compared to the total travel curl distance for the whole hand.
                var totalIntermediateCurlDistance =
                    littleIntermediateCurl - CURL_LITTLE_INTERMEDIATE_LOW_END_ANGLE +
                    (ringIntermediateCurl - CURL_RING_INTERMEDIATE_LOW_END_ANGLE) +
                    (middleIntermediateCurl - CURL_MIDDLE_INTERMEDIATE_LOW_END_ANGLE) +
                    (indexIntermediateCurl - CURL_INDEX_INTERMEDIATE_LOW_END_ANGLE);

                // For grip strength we just use the intermediate curls.
                handData.GripStrength = Mathf.Clamp(totalIntermediateCurlDistance / CURL_TOTAL_INTERMEDIATE_DISTANCE, 0f, 1f);

                // For finger curl strengths we add the proximal curl to the equation.
                var thumbCurlStrength = Mathf.Clamp(
                    (((thumbMetacarpalCurl - CURL_THUMB_METACARPAL_LOW_END_ANGLE) / CURL_THUMB_METACARPAL_DISTANCE) +
                     (thumbProximalCurl - CURL_THUMB_PROXIMAL_LOW_END_ANGLE) / CURL_THUMB_PROXIMAL_DISTANCE) / 2, 0f, 1f);

                var indexCurlStrength = Mathf.Clamp(
                    (((indexProximalCurl - CURL_INDEX_PROXIMAL_LOW_END_ANGLE) / CURL_INDEX_PROXIMAL_DISTANCE) +
                     (indexIntermediateCurl - CURL_INDEX_INTERMEDIATE_LOW_END_ANGLE) / CURL_INDEX_INTERMEDIATE_DISTANCE) / 2, 0f, 1f);

                var middleCurlStrength = Mathf.Clamp(
                    (((middleProximalCurl - CURL_MIDDLE_PROXIMAL_LOW_END_ANGLE) / CURL_MIDDLE_PROXIMAL_DISTANCE) +
                     (middleIntermediateCurl - CURL_MIDDLE_INTERMEDIATE_LOW_END_ANGLE) / CURL_MIDDLE_INTERMEDIATE_DISTANCE) / 2, 0f, 1f);

                var ringCurlStrength = Mathf.Clamp(
                    (((ringProximalCurl - CURL_RING_PROXIMAL_LOW_END_ANGLE) / CURL_RING_PROXIMAL_DISTANCE) +
                     (ringIntermediateCurl - CURL_RING_INTERMEDIATE_LOW_END_ANGLE) / CURL_RING_INTERMEDIATE_DISTANCE) / 2, 0f, 1f);

                var littleCurlStrength = Mathf.Clamp(
                    (((littleProximalCurl - CURL_LITTLE_PROXIMAL_LOW_END_ANGLE) / CURL_LITTLE_PROXIMAL_DISTANCE) +
                     (littleIntermediateCurl - CURL_LITTLE_INTERMEDIATE_LOW_END_ANGLE) / CURL_LITTLE_INTERMEDIATE_DISTANCE) / 2, 0f, 1f);

                handData.FingerCurlStrengths = new float[]
                {
                    thumbCurlStrength,
                    indexCurlStrength,
                    middleCurlStrength,
                    ringCurlStrength,
                    littleCurlStrength,
                };

                // Hand is gripping if the grip strength passed the threshold. But we are also taking
                // the index curl into account explicitly, this helps avoiding the pinch gesture being
                // considered gripping as well.
                handData.IsGripping = handData.GripStrength >= IS_GRIPPING_CURL_THRESHOLD && indexCurlStrength >= IS_GRIPPING_INDEX_CURL_THRESHOLD;

                if (Debug.isDebugBuild && DEBUG_LOG_VALUES_TO_CONSOLE)
                {
                    Debug.Log($"Grip Strength: {handData.GripStrength} " +
                              $"| Thumb: {handData.FingerCurlStrengths[(int)HandFinger.Thumb]} " +
                              $"| Index: {handData.FingerCurlStrengths[(int)HandFinger.Index]} " +
                              $"| Middle: {handData.FingerCurlStrengths[(int)HandFinger.Middle]} " +
                              $"| Ring: {handData.FingerCurlStrengths[(int)HandFinger.Ring]} " +
                              $"| Little: {handData.FingerCurlStrengths[(int)HandFinger.Little]}");
                }
            }
            else
            {
                // When hand is not tracked, reset all values.
                handData.IsGripping          = false;
                handData.GripStrength        = 0f;
                handData.FingerCurlStrengths = new float[]
                {
                    0f,
                    0f,
                    0f,
                    0f,
                    0f
                };
            }

            return(handData);
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public override void SetupDefaultInteractions(Handedness controllerHandedness)
 {
     AssignControllerMappings(controllerHandedness == Handedness.Left ? DefaultLeftHandedInteractions : DefaultRightHandedInteractions);
 }
Ejemplo n.º 4
0
        private static Texture2D GetControllerTextureInternal(string fullTexturePath, Handedness handedness, bool scaled)
        {
            var handednessSuffix = string.Empty;

            switch (handedness)
            {
            case Handedness.Left:
                handednessSuffix = "_left";
                break;

            case Handedness.Right:
                handednessSuffix = "_right";
                break;
            }

            var themeSuffix = EditorGUIUtility.isProSkin ? "_white" : "_black";

            return((Texture2D)AssetDatabase.LoadAssetAtPath($"{fullTexturePath}{handednessSuffix}{themeSuffix}{(scaled ? "_scaled" : string.Empty)}.png", typeof(Texture2D)));
        }
Ejemplo n.º 5
0
        private static Texture2D GetControllerTextureCached(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness, bool scaled = false)
        {
            var key = new Tuple <SupportedControllerType, Handedness, bool>(controllerType, handedness, scaled);

            if (CachedTextures.TryGetValue(key, out var texture))
            {
                return(texture);
            }

            texture = GetControllerTextureInternal(mappingProfile, controllerType, handedness, scaled);
            CachedTextures.Add(key, texture);
            return(texture);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 protected SimulatedHand(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 protected BaseWindowsMixedRealitySource(TrackingState trackingState, Handedness sourceHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, sourceHandedness, inputSource, interactions)
 {
 }
 public WindowsMixedRealityArticulatedHandDefinition(IMixedRealityInputSource source, Handedness handedness) : base(source, handedness)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Default constructor used by reflection for profiles
 /// </summary>
 /// <param name="trackingState"></param>
 /// <param name="controllerHandedness"></param>
 /// <param name="inputSource"></param>
 /// <param name="interactions"></param>
 public OculusQuestHand(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
     palmFilter.Reset();
     indexTipFilter.Reset();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Default constructor used by reflection for profiles
 /// </summary>
 public OculusHand(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
     handDefinition = new ArticulatedHandDefinition(inputSource, controllerHandedness);
 }
Ejemplo n.º 11
0
 public TestHand(Handedness handedness)
 {
     this.handedness   = handedness;
     simulationService = PlayModeTestUtilities.GetInputSimulationService();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="controllerType"></param>
 /// <param name="handedness"></param>
 /// <param name="pointerPrefab"></param>
 public PointerOption(IMixedRealityController controllerType, Handedness handedness, GameObject pointerPrefab)
 {
     this.controllerType = new SystemType(controllerType.GetType());
     this.handedness     = handedness;
     this.pointerPrefab  = pointerPrefab;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Release this pointer. This sends pointer clicked and pointer up events across the input system.
 /// </summary>
 /// <param name="mixedRealityInputAction">The input action that corresponds to the released button or axis.</param>
 /// <param name="handedness">Optional handedness of the source that released the pointer.</param>
 public void RaisePointerUp(MixedRealityInputAction mixedRealityInputAction, Handedness handedness = Handedness.None)
 {
     InputSystem.RaisePointerClicked(this, handedness, mixedRealityInputAction, 0);
     InputSystem.RaisePointerUp(this, handedness, mixedRealityInputAction);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Press this pointer. This sends a pointer down event across the input system.
 /// </summary>
 /// <param name="mixedRealityInputAction">The input action that corresponds to the pressed button or axis.</param>
 /// <param name="handedness">Optional handedness of the source that pressed the pointer.</param>
 public void RaisePointerDown(MixedRealityInputAction mixedRealityInputAction, Handedness handedness = Handedness.None)
 {
     InputSystem.RaisePointerDown(this, handedness, mixedRealityInputAction);
 }
Ejemplo n.º 15
0
 /// <inheritdoc />
 protected BaseOculusController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile, OculusApi.Controller controllerType = OculusApi.Controller.None, OculusApi.Node nodeType = OculusApi.Node.None)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
     ControllerType = controllerType;
     NodeType       = nodeType;
 }
 /// <summary>
 /// Assign the default interactions based on controller handedness if necessary.
 /// </summary>
 public abstract void SetupDefaultInteractions(Handedness controllerHandedness);
Ejemplo n.º 17
0
 void initialize()
 {
     up_axis = UpAxis.YUp;
     handedness = Handedness.RightHanded;
     unit = 0.0f;
 }
 public BaseOculusController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
     NodeType = controllerHandedness == Handedness.Left ? OculusApi.Node.HandLeft : OculusApi.Node.HandRight;
 }
 public bool IsHandTracked(Handedness handedness)
 {
     return(handedness == Handedness.Left ? leftHand != null : handedness == Handedness.Right ? rightHand != null : false);
 }
Ejemplo n.º 20
0
        public static void Show(MixedRealityControllerMapping controllerMapping, SerializedProperty interactionsList, Handedness handedness = Handedness.None)
        {
            if (window != null)
            {
                window.Close();
            }

            window = null;

            window                          = CreateInstance <ControllerPopupWindow>();
            window.thisWindow               = window;
            window.titleContent             = new GUIContent($"{controllerMapping.Description} - Input Action Assignment");
            window.currentControllerMapping = controllerMapping;
            window.currentInteractionList   = interactionsList;
            isMouseInRects                  = new bool[interactionsList.arraySize];

            if (!File.Exists($"{Application.dataPath}{EditorWindowOptionsPath}"))
            {
                var empty = new ControllerInputActionOptions
                {
                    Controllers = new List <ControllerInputActionOption>
                    {
                        new ControllerInputActionOption
                        {
                            Controller          = SupportedControllerType.None,
                            Handedness          = Handedness.None,
                            InputLabelPositions = new[] { new Vector2(0, 0) },
                            IsLabelFlipped      = new [] { false }
                        }
                    }
                };

                File.WriteAllText($"{Application.dataPath}{EditorWindowOptionsPath}", JsonUtility.ToJson(empty));
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
            else
            {
                controllerInputActionOptions = JsonUtility.FromJson <ControllerInputActionOptions>(File.ReadAllText($"{Application.dataPath}{EditorWindowOptionsPath}"));

                if (controllerInputActionOptions.Controllers.Any(option => option.Controller == controllerMapping.SupportedControllerType && option.Handedness == handedness))
                {
                    window.currentControllerOption = controllerInputActionOptions.Controllers.FirstOrDefault(option => option.Controller == controllerMapping.SupportedControllerType && option.Handedness == handedness);

                    if (window.currentControllerOption != null && window.currentControllerOption.IsLabelFlipped == null)
                    {
                        window.currentControllerOption.IsLabelFlipped = new bool[interactionsList.arraySize];
                    }
                }
            }

            var windowSize = new Vector2(controllerMapping.HasCustomInteractionMappings ? 896f : 768f, 512f);

            window.maxSize = windowSize;
            window.minSize = windowSize;
            window.CenterOnMainWin();
            window.ShowUtility();

            defaultLabelWidth = EditorGUIUtility.labelWidth;
            defaultFieldWidth = EditorGUIUtility.fieldWidth;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Event handler for when the Ungulate menu entry is selected.
        /// </summary>
        void HandednessMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentUngulate++;
            if (hand == true)
                hand = false;
            else
                hand = true;

            if (currentUngulate > Handedness.Right)
                currentUngulate = 0;

            SetMenuEntryText();
        }
Ejemplo n.º 22
0
        protected virtual void AttachToNewTrackedObject()
        {
            this.currentTrackedHandedness = Handedness.None;

            Transform target = null;

            if (TrackedTargetType == TrackedObjectType.Head)
            {
                target = CameraCache.Main.transform;
            }
            else if (TrackedTargetType == TrackedObjectType.MotionController)
            {
                if (this.TrackedHandness == Handedness.Both)
                {
                    this.currentTrackedHandedness = Handedness.Left;
                    target = GetMotionController(Handedness.Left);
                    if (target == null)
                    {
                        this.currentTrackedHandedness = Handedness.Right;
                        target = GetMotionController(Handedness.Right);
                        if (target == null)
                        {
                            this.currentTrackedHandedness = Handedness.None;
                        }
                    }
                }
                else
                {
                    this.currentTrackedHandedness = this.TrackedHandness;
                    target = GetMotionController(this.TrackedHandness);
                }
            }
            else if (TrackedTargetType == TrackedObjectType.HandJoint)
            {
                if (HandJointService != null)
                {
                    this.currentTrackedHandedness = this.TrackedHandness;
                    if (currentTrackedHandedness == Handedness.Both)
                    {
                        if (HandJointService.IsHandTracked(Handedness.Left))
                        {
                            currentTrackedHandedness = Handedness.Left;
                        }
                        else if (HandJointService.IsHandTracked(Handedness.Right))
                        {
                            currentTrackedHandedness = Handedness.Right;
                        }
                        else
                        {
                            currentTrackedHandedness = Handedness.None;
                        }
                    }

                    target = HandJointService.RequestJointTransform(this.TrackedHandJoint, currentTrackedHandedness);
                }
            }
            else if (TrackedTargetType == TrackedObjectType.CustomOverride)
            {
                target = this.transformOverride;
            }

            TrackTransform(target);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Gets a scaled texture for the <see cref="SupportedControllerType"/> based on a list of the active <see cref="MixedRealityControllerMappingProfiles"/>.
 /// </summary>
 /// <param name="controllerType"></param>
 /// <param name="handedness"></param>
 /// <returns>The scaled texture for the controller type, if none found then a generic texture is returned.</returns>
 public static Texture2D GetControllerTextureScaled(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness)
 {
     return(GetControllerTextureCached(mappingProfile, controllerType, handedness, true));
 }
Ejemplo n.º 24
0
 public static bool IsValidHandedness(Handedness hand)
 {
     return(hand <= Handedness.Both);
 }
Ejemplo n.º 25
0
        private static Texture2D GetControllerTextureInternal(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness, bool scaled)
        {
            if (mappingProfile != null &&
                mappingProfile.ControllerType == controllerType)
            {
                var texture = GetControllerTextureInternal(mappingProfile.TexturePath, handedness, scaled);

                if (texture != null)
                {
                    return(texture);
                }
            }

            return(GetControllerTextureInternal($"{MixedRealityEditorSettings.MixedRealityToolkit_RelativeFolderPath}/StandardAssets/Textures/Generic_controller", Handedness.None, scaled));
        }
        /// <summary>
        /// Instantiates <see cref="FingerTipKinematicBodyPrefab"/>s for all <see cref="fingerTipTypes"/>.
        /// </summary>
        /// <remarks>
        /// Optionally instantiates <see cref="PalmKinematicBodyPrefab"/>.
        /// </remarks>
        /// <param name="rigidBodyPrefab">The prefab to instantiate.</param>
        /// <param name="layer">the layer to put the prefab on.</param>
        /// <param name="handednessType">the specified <see cref="Handedness"/> for the joint.</param>
        /// <param name="jointType">the specified <see cref="TrackedHandJoint"/> to instantiate against.</param>
        /// <param name="parent">The root <see href="https://docs.unity3d.com/ScriptReference/GameObject.html"> for the joints.</param>
        /// <param name="jointKinematicBody">When successful, the generated <see cref="JointKinematicBody"/>.</param>
        /// <returns>True when able to successfully intantiate and create a <see cref="JointKinematicBody"/>.</returns>
        private static bool TryCreateJointKinematicBody(GameObject rigidBodyPrefab, int layer, Handedness handednessType, TrackedHandJoint jointType, Transform parent, out JointKinematicBody jointKinematicBody)
        {
            jointKinematicBody = null;

            GameObject currentGameObject = GameObject.Instantiate(rigidBodyPrefab, parent);

            currentGameObject.layer = layer;
            JointKinematicBody currentJoint = currentGameObject.GetComponent <JointKinematicBody>();

            if (currentJoint == null)
            {
                Debug.LogError("The HandPhysicsService assumes the FingerTipKinematicBodyPrefab has a JointKinematicBody component.");
                UnityEngine.Object.Destroy(currentGameObject);
                return(false);
            }

            currentJoint.JointType      = jointType;
            currentJoint.HandednessType = handednessType;
            currentGameObject.name      = handednessType + " " + jointType;

            if (currentGameObject.GetComponent <Collider>() == null)
            {
                Debug.LogError("The HandPhysicsService assumes the FingerTipKinematicBodyPrefab has a Collder component.");
                UnityEngine.Object.Destroy(currentGameObject);
                return(false);
            }

            Rigidbody rigidbody = currentGameObject.GetComponent <Rigidbody>();

            if (rigidbody == null)
            {
                Debug.LogError("The HandPhysicsService assumes the FingerTipKinematicBodyPrefab has a Rigidbody component.");
                UnityEngine.Object.Destroy(currentGameObject);
                return(false);
            }

            if (!rigidbody.isKinematic)
            {
                Debug.LogWarning("The HandPhysicsService FingerTipKinematicBodyPrefab rigidbody should be marked as kinematic, making kinematic.");
                rigidbody.isKinematic = true;
            }

            jointKinematicBody = currentJoint;
            return(true);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="controllerType">Controller Type to instantiate at runtime.</param>
 /// <param name="handedness">The designated hand that the device is managing.</param>
 public MixedRealityControllerMapping(Type controllerType, Handedness handedness = Handedness.None) : this()
 {
     this.controllerType = new SystemType(controllerType);
     this.handedness     = handedness;
     interactions        = null;
 }
 /// <inheritdoc />
 public override void SetupDefaultInteractions(Handedness controllerHandedness)
 {
     AssignControllerMappings(DefaultInteractions);
 }
Ejemplo n.º 29
0
 public GenericOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
     nodeType = controllerHandedness == Handedness.Left ? XRNode.LeftHand : XRNode.RightHand;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        protected BaseController(
            TrackingState trackingState,
            Handedness controllerHandedness,
            IMixedRealityInputSource inputSource          = null,
            MixedRealityInteractionMapping[] interactions = null,
            IMixedRealityInputSourceDefinition definition = null)
        {
            TrackingState        = trackingState;
            ControllerHandedness = controllerHandedness;
            InputSource          = inputSource;
            Interactions         = interactions;
            Definition           = definition;

            IsPositionAvailable   = false;
            IsPositionApproximate = false;
            IsRotationAvailable   = false;

            Type controllerType = GetType();

            if (IsControllerMappingEnabled() && Interactions == null)
            {
                // We can only enable controller profiles if mappings exist.
                MixedRealityControllerMapping[] controllerMappings = GetControllerMappings();

                // Have to test that a controller type has been registered in the profiles,
                // else its Unity input manager mappings will not have been set up by the inspector.
                bool profileFound = false;
                if (controllerMappings != null)
                {
                    for (int i = 0; i < controllerMappings.Length; i++)
                    {
                        if (controllerMappings[i].ControllerType.Type == controllerType)
                        {
                            profileFound = true;

                            // If it is an exact match, assign interaction mappings.
                            if (controllerMappings[i].Handedness == ControllerHandedness &&
                                controllerMappings[i].Interactions.Length > 0)
                            {
                                MixedRealityInteractionMapping[] profileInteractions = controllerMappings[i].Interactions;
                                MixedRealityInteractionMapping[] newInteractions     = new MixedRealityInteractionMapping[profileInteractions.Length];

                                for (int j = 0; j < profileInteractions.Length; j++)
                                {
                                    newInteractions[j] = new MixedRealityInteractionMapping(profileInteractions[j]);
                                }

                                AssignControllerMappings(newInteractions);
                                break;
                            }
                        }
                    }
                }

                // If no controller mappings found, try to use default interactions.
                if (Interactions == null || Interactions.Length < 1)
                {
                    SetupDefaultInteractions();

                    // We still don't have controller mappings, so this may be a custom controller.
                    if (Interactions == null || Interactions.Length < 1)
                    {
                        Debug.LogWarning($"No controller interaction mappings found for {controllerType}.");
                        return;
                    }
                }

                // If no profile was found, warn the user. Does not stop the project from running.
                if (!profileFound)
                {
                    Debug.LogWarning($"No controller profile found for type {controllerType}; please ensure all controllers are defined in the configured MixedRealityControllerConfigurationProfile.");
                }
            }

            if (GetControllerVisualizationProfile() != null &&
                GetControllerVisualizationProfile().RenderMotionControllers&&
                InputSource != null)
            {
                TryRenderControllerModel(controllerType, InputSource.SourceType);
            }

            Enabled = true;
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public ViveWandController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
     : base(trackingState, controllerHandedness, inputSource, interactions)
 {
 }
 public virtual void SetupDefaultInteractions(Handedness controllerHandedness) => SetupDefaultInteractions();
Ejemplo n.º 33
0
		// Change from left- to right-handedness and back
		private void SetHandedness(Handedness h) {
			handedness = h;
			
			poserLeftHand.poseRoot = targets.leftHand;
			poserRightHand.poseRoot = targets.rightHand;
			
			poserLeftHand.AutoMapping();
			poserRightHand.AutoMapping();
		}
Ejemplo n.º 34
0
 public ControllerItem(SupportedControllerType controllerType, Handedness handedness, MixedRealityInteractionMapping[] interactions)
 {
     ControllerType = controllerType;
     Handedness     = handedness;
     Interactions   = interactions;
 }