Beispiel #1
0
        /// <inheritdoc/>
        public override async void StartObserving()
        {
            if (IsRunning)
            {
                return;
            }

            if (spatialSurfaceObserver == null)
            {
                Debug.LogError($"Failed to start {Name}! {nameof(spatialSurfaceObserver)} is null!");
                return;
            }

            if (currentAccessStatus != SpatialPerceptionAccessStatus.Allowed)
            {
                currentAccessStatus = await SpatialSurfaceObserver.RequestAccessAsync();
            }

            if (currentAccessStatus != SpatialPerceptionAccessStatus.Allowed)
            {
                Debug.LogWarning($"Failed to start {Name}! Access is {currentAccessStatus}.");
                return;
            }

            base.StartObserving();

            // We want the first update immediately.
            lastUpdated = 0;
        }
Beispiel #2
0
        public override void StopObserving()
        {
            if (!IsRunning)
            {
                return;
            }

            currentAccessStatus = SpatialPerceptionAccessStatus.Unspecified;

            base.StopObserving();
        }
Beispiel #3
0
        internal async void setUpSpatialMapping(SpatialCoordinateSystem coordinateSystem)
        {
            if (!Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4) || SpatialSurfaceObserver.IsSupported())
            {
                SpatialPerceptionAccessStatus status = await SpatialSurfaceObserver.RequestAccessAsync();

                if (status == SpatialPerceptionAccessStatus.Allowed)
                {
                    SpatialSurfaceObserver observer    = new SpatialSurfaceObserver();
                    SpatialBoundingBox     boundingBox = new SpatialBoundingBox()
                    {
                        Center  = new System.Numerics.Vector3(0, 0, 0),
                        Extents = new System.Numerics.Vector3(40, 40, 5)
                    };
                    SpatialBoundingVolume bounds = SpatialBoundingVolume.FromBox(coordinateSystem, boundingBox);
                    observer.SetBoundingVolume(bounds);
                    observer.ObservedSurfacesChanged += new TypedEventHandler <SpatialSurfaceObserver, object>(ClockworkSocket.SurfacesChanged);
                }
            }
        }