示例#1
0
        private void Update()
        {
            _surfaceObserver = TryToGetObserver();
            if (_surfaceObserver == null)
            {
                return;
            }

            switch (CurrentObserverMode)
            {
            case ObserverMode.Auto:
                if (_objectTracker.QueryActive || _objectAnchorsService.TrackingResults.Count == 0)
                {
                    _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.Visible;
                }
                else
                {
                    _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
                }
                break;

            case ObserverMode.ForceOn:
                _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.Visible;
                break;

            case ObserverMode.ForceOff:
                _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
                break;
            }
        }
示例#2
0
 private void _searchAreaController_SearchAreaMoved(object sender, System.EventArgs e)
 {
     _surfaceObserver = TryToGetObserver();
     _surfaceObserver.ObserverVolumeType = MixedReality.Toolkit.Utilities.VolumeType.AxisAlignedCube;
     _surfaceObserver.ObserverOrigin     = _searchAreaController.SearchArea.Center;
     _surfaceObserver.ObserverRotation   = _searchAreaController.SearchArea.Orientation;
     _surfaceObserver.ObservationExtents = _searchAreaController.SearchArea.Extents;
 }
示例#3
0
 // Start is called before the first frame update
 void Start()
 {
     gameModeSelection.OnSelectionEvents.AddListener(OnGameModeChanged);
     editingActionSelection.OnSelectionEvents.AddListener(OnEditingActionChanged);
     LoadGraphInfo();
     WorldAnchorStore.GetAsync(OnAnchorStoreLoaded);
     gazeProvider        = CameraCache.Main.GetComponent <GazeProvider>();
     spatialMeshObserver = MixedRealityToolkit.Instance.GetService <IMixedRealitySpatialAwarenessMeshObserver>();
 }
示例#4
0
 public void Start()
 {
     observer = CoreServices.GetSpatialAwarenessSystemDataProvider <IMixedRealitySpatialAwarenessMeshObserver>();
     foreach (GameObject gO in destinations)
     {
         searchDestinations.Add(gO.name, gO);
     }
     lr.enabled = false;
     textToSpeech.StartSpeaking("Welcome to HoloAssist! Wait a few seconds to scan your surroundings. Say the destination out loud to see the path.");
 }
示例#5
0
        public void StopObserver()
        {
            _surfaceObserver = TryToGetObserver();
            if (_surfaceObserver != null)
            {
                _surfaceObserver.Disable();
                _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
                Debug.Log("Observer Stopped");
            }

            ObserverRunning = false;
        }
示例#6
0
        private void Start()
        {
            // Get Core Spatial Awareness Services
            m_spatialAwarenessService = CoreServices.SpatialAwarenessSystem;
            if (m_spatialAwarenessService != null)
            {
                IMixedRealityDataProviderAccess dataProviderAccess = m_spatialAwarenessService as IMixedRealityDataProviderAccess;
                m_spatialAwarenessMeshObserver = dataProviderAccess.GetDataProvider <IMixedRealitySpatialAwarenessMeshObserver>();

                // Try to get "Spatial Awareness System" object (stores meshes)
                AcquireSpatailAwarenessObject();
            }
        }
示例#7
0
        private void Awake()
        {
            _objectAnchorsService = ObjectAnchorsService.GetService();

            _surfaceObserver = TryToGetObserver();
            if (_surfaceObserver != null)
            {
                _surfaceObserver.Disable();
                _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.None;
            }

            _objectTracker = FindObjectOfType <ObjectTracker>();
        }
示例#8
0
        private IMixedRealitySpatialAwarenessMeshObserver TryToGetObserver()
        {
            IMixedRealitySpatialAwarenessMeshObserver retval = null;

            if (MixedRealityServiceRegistry.TryGetService <IMixedRealitySpatialAwarenessSystem>(out var service))
            {
                IMixedRealityDataProviderAccess dataProviderAccess = service as IMixedRealityDataProviderAccess;

                retval =
                    dataProviderAccess.GetDataProvider <IMixedRealitySpatialAwarenessMeshObserver>();
            }

            return(retval);
        }
示例#9
0
 public void StartObserver()
 {
     _surfaceObserver = TryToGetObserver();
     if (_surfaceObserver != null)
     {
         _surfaceObserver.Enable();
         _surfaceObserver.DisplayOption = SpatialAwarenessMeshDisplayOptions.Visible;
         ObserverRunning = true;
         Debug.Log("Observer started");
     }
     else
     {
         Debug.Log("No observer?");
     }
 }
        private static IEnumerator SaveInternal(IMixedRealitySpatialAwarenessMeshObserver meshObserver, string folderPath, bool consolidate = true)
        {
            var targets = new HashSet <Transform>();

            // Build up unique set of GameObjects to target to pull Mesh data
            foreach (SpatialAwarenessMeshObject meshObject in meshObserver.Meshes.Values)
            {
                targets.Add(consolidate ? meshObject.GameObject.transform.parent : meshObject.GameObject.transform);
            }

            foreach (var target in targets)
            {
                string filePath = Path.Combine(folderPath, target.name + ".obj");
                yield return(target.gameObject.ExportOBJAsync(filePath, true));
            }
        }
        private void Awake()
        {
            // We do not wish to play the ambient room sound from the audio source.
            gameObject.GetComponent <AudioSource>().volume = 0.0f;

            spatialMeshObserver = (CoreServices.SpatialAwarenessSystem as IMixedRealityDataProviderAccess)?.GetDataProvider <IMixedRealitySpatialAwarenessMeshObserver>();
            visibleMaterial     = spatialMeshObserver?.VisibleMaterial;

            if (visibleMaterial != null)
            {
                // Cache the initial material settings.
                defaultMaterialColor = visibleMaterial.GetColor("_WireColor");
                defaultWireThickness = visibleMaterial.GetInt("_WireThickness");

                visibleMaterial.SetColor("_WireColor", meshColor);
            }

            micStream = new WindowsMicrophoneStream();
            if (micStream == null)
            {
                Debug.Log("Failed to create the Windows Microphone Stream object");
            }

            micStream.Gain = inputGain;

            // Initialize the microphone stream.
            WindowsMicrophoneStreamErrorCode result = micStream.Initialize(WindowsMicrophoneStreamType.HighQualityVoice);

            if (result != WindowsMicrophoneStreamErrorCode.Success)
            {
                Debug.Log($"Failed to initialize the microphone stream. {result}");
                return;
            }

            // Start the microphone stream.
            // Do not keep the data and do not preview.
            result = micStream.StartStream(false, false);
            if (result != WindowsMicrophoneStreamErrorCode.Success)
            {
                Debug.Log($"Failed to start the microphone stream. {result}");
            }
        }
        /// <summary>
        /// Save spatial mesh data for given observer to folder path provided
        /// </summary>
        /// <param name="meshObserver">Observer to target for requests of spatial mesh data</param>
        /// <param name="folderPath">Folder path to pull all OBJ files</param>
        /// <param name="consolidate">if true, merge all mesh data from observer into one OBJ file. If false, create OBJ file per mesh object</param>
        /// <remarks>
        /// <para>Accessing GameObject/Mesh data will occur as Coroutine on Unity Main thread. May impact performance.
        /// If folder path does not exist, throws exception</para>
        /// </remarks>
        public static async Task Save(IMixedRealitySpatialAwarenessMeshObserver meshObserver, string folderPath, bool consolidate = true)
        {
            CreateFoldersIfDoesNotExist(folderPath);

            await SaveInternal(meshObserver, folderPath, consolidate);
        }