コード例 #1
0
        /// <summary>
        /// Updates the list of key poses internal to the magic leap device,
        /// enabling or disabling key poses that should be tracked.
        /// </summary>
        private void UpdateKeyPoseStates()
        {
            MLHandTracking.HandKeyPose[] keyPoseTypes = GetKeyPoseTypes();

            // Early out in case there are no key poses to enable.
            if (keyPoseTypes.Length == 0)
            {
                MLHandTrackingStarterKit.DisableKeyPoses();
                return;
            }

            bool status = MLHandTrackingStarterKit.EnableKeyPoses(true, keyPoseTypes);

            if (!status)
            {
                Debug.LogError("Error: MLHandTrackingBehavior failed enabling tracked key poses, disabling script.");
                enabled = false;
                return;
            }
        }
コード例 #2
0
ファイル: HandMeshingExample.cs プロジェクト: untaris2020/HMD
        /// <summary>
        /// Validate and initialize properties
        /// </summary>
        void Start()
        {
            if (_behavior == null)
            {
                Debug.LogError("Error: HandMeshingExample._behavior is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_occlusionMaterial == null)
            {
                Debug.LogError("Error: HandMeshingExample._occlusionMaterial is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_flatMaterial == null)
            {
                Debug.LogError("Error: HandMeshingExample._flatMaterial is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_wireframeMaterial == null)
            {
                Debug.LogError("Error: HandMeshingExample._wireframeMaterial is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_statusText == null)
            {
                Debug.LogError("Error: HandMeshingExample._status is not set, disabling script.");
                enabled = false;
                return;
            }

            if (_switchTooltip == null)
            {
                Debug.LogError("Error: HandMeshingExample._switchTooltip is not set, disabling script.");
                enabled = false;
                return;
            }
            _switchTooltip.gameObject.SetActive(false);

            // Note: MLHandTracking API is not necessary to use Hand Meshing.
            // It is only used for switching the render modes in this example.
            MLResult result = MLHandTrackingStarterKit.Start();

            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogError("Error: HandMeshingExample failed on MLHandTrackingStarterKit.Start, disabling script.");
                enabled = false;
                return;
            }
            #endif

            MLHandTrackingStarterKit.EnableKeyPoses(true, _keyposeToSwitch);
            MLHandTrackingStarterKit.SetPoseFilterLevel(MLHandTracking.PoseFilterLevel.ExtraRobust);
            MLHandTrackingStarterKit.SetKeyPointsFilterLevel(MLHandTracking.KeyPointFilterLevel.ExtraSmoothed);

            _timer = _secondsBetweenModes;
        }