Пример #1
0
        /// <summary>
        /// Every _secondsToRequeue, this coroutine will attempt to find all pcfs and queue them all for updates.
        /// </summary>
        private IEnumerator ContinuouslyFindAllPCFs()
        {
            // Uses a while loop so that we can catch PCFs being created during runtime.
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                if (IsVisualizing)
                {
                    #if PLATFORM_LUMIN
                    // MLPersistentCoordinateFrames.FindAllPCFs() returns the PCFs found in the current map.
                    // Calling this function is expensive and is only called repeatedly for demonstration purposes.
                    // This function will create new pcfs during a new headpose session.
                    MLResult result = MLPersistentCoordinateFrames.FindAllPCFs(out List <MLPersistentCoordinateFrames.PCF> allPCFs);
                    if (!result.IsOk)
                    {
                        if (result.Result == MLResult.Code.PassableWorldLowMapQuality || result.Result == MLResult.Code.PassableWorldUnableToLocalize)
                        {
                            Debug.LogWarningFormat("Map quality not sufficient enough for PCFVisualizer to find all pcfs. Reason: {0}", result);
                        }
                        else
                        {
                            Debug.LogErrorFormat("Error: PCFVisualizer failed to find all PCFs because MLPersistentCoordinateFrames failed to get all PCFs. Reason: {0}", result);
                        }
                    }
                    else
                    {
                        OnFindAllPCFs?.Invoke(allPCFs);
                    }
                    #endif

                    yield return(new WaitForSeconds(_secondsToRequeue));
                }
            }
        }
Пример #2
0
        //Private Methods:
        private void DiscoverPCFs()
        {
            //interval:
            _interval++;
            _interval = _interval % 100;

            //if previous send queue isn't finished then interrupt it:
            StopCoroutine("SendPCFs");

            //clear lists:
            _localPCFs.Clear();
            _localPCFData.Clear();
            _localPCFReferences.Clear();
            _outboundPCFs.Clear();

            //get pcfs:
            MLPersistentCoordinateFrames.FindAllPCFs(out _localPCFs, QueryCount);

            //request poses:
            foreach (var item in _localPCFs)
            {
                item.Update();
                HandlePCFPoseRetrieval(item);
            }
        }
Пример #3
0
        //Coroutines:
        private IEnumerator PCFDiscovery()
        {
            //query until we get PCFs:
            while (_localPCFs.Count == 0)
            {
                MLPersistentCoordinateFrames.FindAllPCFs(out _localPCFs, QueryCount);
                yield return(null);
            }

            while (true)
            {
                DiscoverPCFs();
                yield return(new WaitForSeconds(QueryInterval));

                yield return(null);
            }
        }
Пример #4
0
    void PerformStartup()
    {
        pcfStatus = PCFStatus.Active;
        if (_pcfStatusText != null)
        {
            _pcfStatusText.text = "Status: Restoring Content";
        }

        if (OnPcfsReady != null)
        {
            OnPcfsReady(this);
        }

        //trigger updates
        if (displayDebugVisuals)
        {
            MLPersistentCoordinateFrames.FindAllPCFs(out List <MLPersistentCoordinateFrames.PCF> list, int.MaxValue, MLPersistentCoordinateFrames.PCF.Types.MultiUserMultiSession);
        }

        if (_pcfStatusText != null)
        {
            _pcfStatusText.text = "Done Restoring Content";
        }
    }