Пример #1
0
        public async Task <bool> Register(StereoApplication app, SpatialCoordinateSystem coordinateSystem, System.Numerics.Vector3 extents, int trianglesPerCubicMeter = 1000, bool onlyAdd = false, bool convertToLeftHanded = true)
        {
            this.currentHoloApp          = app;
            this.trianglesPerCubicMeter  = trianglesPerCubicMeter;
            this.currentCoordinateSystem = coordinateSystem;
            ConvertToLeftHanded          = convertToLeftHanded;
            OnlyAdd = onlyAdd;

            var result = await SpatialSurfaceObserver.RequestAccessAsync();

            if (result != SpatialPerceptionAccessStatus.Allowed)
            {
                return(false);
            }

            observer = new SpatialSurfaceObserver();
            observer.SetBoundingVolume(SpatialBoundingVolume.FromBox(coordinateSystem, new SpatialBoundingBox {
                Extents = extents
            }));

            foreach (var item in observer.GetObservedSurfaces())
            {
                lock (UpdateCache)
                {
                    UpdateCache[item.Key] = item.Value.UpdateTime.ToUniversalTime();
                }
                ProcessSurface(item.Value);
            }
            observer.ObservedSurfacesChanged += Observer_ObservedSurfacesChanged;

            return(true);
        }
Пример #2
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;
        }
Пример #3
0
        public async Task <bool> Register(HoloApplication app, SpatialCoordinateSystem coordinateSystem, System.Numerics.Vector3 extents, int trianglesPerCubicMeter = 1000)
        {
            this.currentHoloApp          = app;
            this.trianglesPerCubicMeter  = trianglesPerCubicMeter;
            this.currentCoordinateSystem = coordinateSystem;

            var result = await SpatialSurfaceObserver.RequestAccessAsync();

            if (result != SpatialPerceptionAccessStatus.Allowed)
            {
                return(false);
            }

            observer = new SpatialSurfaceObserver();
            observer.SetBoundingVolume(SpatialBoundingVolume.FromBox(coordinateSystem, new SpatialBoundingBox {
                Extents = extents
            }));
            foreach (var surface in observer.GetObservedSurfaces())
            {
                updateCache[surface.Key] = surface.Value.UpdateTime.UtcDateTime;
                ProcessSurface(surface.Value);
            }
            observer.ObservedSurfacesChanged += Observer_ObservedSurfacesChanged;

            return(true);
        }
        async void CheckAccess()
        {
            var res = await SpatialSurfaceObserver.RequestAccessAsync();

            if (res != SpatialPerceptionAccessStatus.Allowed)
            {
                throw new Exception("No access to spatial data.");
            }
        }
Пример #5
0
        /// <summary>
        /// Initialize all resources used by this instance.
        /// </summary>
        public async void Initialize()
        {
            // The surface mapping API reads information about the user's environment. The user must
            // grant permission to the app to use this capability of the Windows Holographic device.
            var status = await SpatialSurfaceObserver.RequestAccessAsync();

            if (status != SpatialPerceptionAccessStatus.Allowed)
            {
                return;
            }

            // If status is allowed, we can create the surface observer.
            this.surfaceObserver = new SpatialSurfaceObserver();
            this.surfaceObserver.ObservedSurfacesChanged += this.ObservedSurfacesChanged;
            this.RefreshBoundingVolume();
        }
Пример #6
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);
                }
            }
        }
Пример #7
0
        public async void Initialize(SpatialCoordinateSystem coordinateSystem)
        {
            CoordinateSystem = coordinateSystem;
            var requestStatus = await SpatialSurfaceObserver.RequestAccessAsync();

            if (requestStatus == SpatialPerceptionAccessStatus.Allowed)
            {
                SurfaceObserver = new SpatialSurfaceObserver();
                var boundingBox = new SpatialBoundingBox()
                {
                    Center  = Vector3.Zero,
                    Extents = new Vector3(10.0f, 10.0f, 2.5f)
                };
                SurfaceObserver.SetBoundingVolume(SpatialBoundingVolume.FromBox(coordinateSystem, boundingBox));
                await CreateDeviceDenpendantResources();

                SurfaceObserver.ObservedSurfacesChanged += OnObservedSurfacesChanged;
                Active = true;
            }
        }
Пример #8
0
        private bool InitializeUWP()
        {
            // Ask or check for Spatial permissions
            SpatialSurfaceObserver.RequestAccessAsync().Completed = (i, s) => {
                if (s == AsyncStatus.Completed && i.GetResults() == SpatialPerceptionAccessStatus.Allowed)
                {
                    observer = new SpatialSurfaceObserver();
                    observer.ObservedSurfacesChanged += OnSurfaceUpdate;
                    UpdateBounds(center, radius);
                }
            };

            // Establish the coordinate frame of reference
            var locator = SpatialLocator.GetDefault();

            if (locator != null)
            {
                locator.LocatabilityChanged += OnLocated;
                OnLocated(locator, null);
            }
            return(true);
        }
Пример #9
0
        private async Task InitializeSurfaceObservation()
        {
            var requestStatus = await SpatialSurfaceObserver.RequestAccessAsync();

            if (requestStatus == SpatialPerceptionAccessStatus.Allowed)
            {
                SurfaceObserver = new SpatialSurfaceObserver();
                var boundingBox = new SpatialBoundingBox
                {
                    Center  = Vector3.Zero,
                    Extents = new Vector3(10.0f, 10.0f, 10.0f)
                };
                SurfaceObserver.SetBoundingVolume(SpatialBoundingVolume.FromBox(CoordinateSystem, boundingBox));
                SurfaceObserver.ObservedSurfacesChanged += (sender, _) =>
                {
                    if (!GeometryPaused)
                    {
                        Meshes.ProcessSurfaces(sender.GetObservedSurfaces());
                    }
                };
            }
            MeshTexturer.InitializeTextures();
        }