/// <summary>
        /// Calls Start on MLHandTrackingStarterKit.
        /// </summary>
        void Start()
        {
            MLResult result = MLHandTrackingStarterKit.Start();

            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: KeyPoseVisualizer failed on MLHandTrackingStarterKit.Start, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif
            cur_pose = new string[2];
            //cur_pose[0] = "def";
            LogToFileHelper logger = new LogToFileHelper();

            scn       = SceneManager.GetActiveScene();
            sceneName = scn.name;

            //establishing logger for storing interactions locally as a backup
            StartCoroutine(logger.LogToFileStringArray("log_poses.json", cur_pose));
            //creating new session
            StartCoroutine(consoler.NewSession("http://" + LoggingConfig.ip_address + ":" + LoggingConfig.port + "/ext/" + LoggingConfig.api_key + "/new_session"));
            StartCoroutine(checkHands());
        }
Beispiel #2
0
 /// <summary>
 /// Disables all key poses and calls Stop on MLHandTrackingStarterKit.
 /// </summary>
 void OnDestroy()
 {
     // Disable all key poses if MLHandTrackingStarterKit was started
     _trackedKeyPoses &= 0;
     UpdateKeyPoseStates();
     MLHandTrackingStarterKit.Stop();
 }
Beispiel #3
0
 /// <summary>
 /// Calls Start on MLHandTrackingStarterKit.
 /// </summary>
 void Start()
 {
     #if PLATFORM_LUMIN
     MLResult result = MLHandTrackingStarterKit.Start();
     if (!result.IsOk)
     {
         Debug.LogErrorFormat("Error: HandTrackingExample failed on MLHandTrackingStarterKit.Start, disabling script. Reason: {0}", result);
         enabled = false;
         return;
     }
     #endif
 }
Beispiel #4
0
        /// <summary>
        /// Calls Start on MLHandTrackingStarterKit.
        /// </summary>
        void Start()
        {
            MLResult result = MLHandTrackingStarterKit.Start();

            #if PLATFORM_LUMIN
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: KeyPoseVisualizer failed on MLHandTrackingStarterKit.Start, disabling script. Reason: {0}", result);
                _spriteRenderer.material.color = Color.red;
                enabled = false;
                return;
            }
            #endif
        }
Beispiel #5
0
        void Start()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLHandTrackingStarterKit.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLHandTrackingBehavior failed on MLHandTrackingStarterKit.Start, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif

            UpdateKeyPoseStates();

            MLHandTrackingStarterKit.SetKeyPointsFilterLevel(_keyPointFilterLevel);
            MLHandTrackingStarterKit.SetPoseFilterLevel(_poseFilterLevel);
        }
Beispiel #6
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;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Calls Start on MLHandTrackingStarterKit and initializes the lists of hand transforms.
        /// </summary>
        void Start()
        {
            if (_center == null)
            {
                Debug.LogError("Error: HandVisualizer._center is not set, disabling script.");
                enabled = false;
                return;
            }

            MLResult result = MLHandTrackingStarterKit.Start();

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

            Initialize();
        }
Beispiel #8
0
 /// <summary>
 /// Clean up.
 /// </summary>
 void OnDestroy()
 {
     MLHandTrackingStarterKit.Stop();
 }
Beispiel #9
0
        /// <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;
        }