コード例 #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);
        }
        void BuildSpatialSurfaceObserver()
        {
            _spatialSurfaceObserver = new SpatialSurfaceObserver();

            var positionFormat = DirectXPixelFormat.R32G32B32A32Float;
            var normalFormat   = DirectXPixelFormat.R32G32B32A32Float;

            _spatialSurfaceMeshOptions = new SpatialSurfaceMeshOptions
            {
                IncludeVertexNormals = true,
                VertexPositionFormat = positionFormat,
                VertexNormalFormat   = normalFormat,
                TriangleIndexFormat  = DirectXPixelFormat.R16UInt
            };

            var boundingBox = new SpatialBoundingBox
            {
                Center  = new Vector3(0f, 0f, 0f),
                Extents = new Vector3(10f, 10f, 10f)
            };
            var bounds = SpatialBoundingVolume.FromBox(_spatialCoordinateSystem, boundingBox);

            _spatialSurfaceObserver.SetBoundingVolume(bounds);

            _spatialSurfaceObserver.ObservedSurfacesChanged += SpatialSurfaceObserverOnObservedSurfacesChanged;
        }
コード例 #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);
        }
コード例 #4
0
        /// <summary>
        /// Refresh the volume
        /// </summary>
        private void RefreshBoundingVolume()
        {
            // The surface observer can now be configured as needed.
            // In this example, we specify one area to be observed using an axis-aligned
            // bounding box 20 meters in width and 5 meters in height and centered at the
            // origin.
            SpatialBoundingBox aabb = new SpatialBoundingBox()
            {
                Center  = System.Numerics.Vector3.Zero,
                Extents = this.extents.ToSystemNumerics()
            };

            SpatialBoundingVolume bounds = SpatialBoundingVolume.FromBox(WaveServices.GetService <MixedRealityService>().ReferenceFrame.CoordinateSystem, aabb);

            this.surfaceObserver.SetBoundingVolume(bounds);
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
        /// <summary>
        /// Applies the configured observation extents.
        /// </summary>
        private void ConfigureObserverVolume(Vector3 newOrigin, Vector3 newExtents)
        {
            if (currentObserverExtents.Equals(newExtents) &&
                currentObserverOrigin.Equals(newOrigin))
            {
                return;
            }

            spatialSurfaceObserver.SetBoundingVolume(
                SpatialBoundingVolume.FromBox(
                    WindowsMixedRealityUtilities.SpatialCoordinateSystem, new SpatialBoundingBox
            {
                Center  = newOrigin.ToNumericsVector3(),
                Extents = newExtents.ToNumericsVector3()
            }
                    )
                );

            currentObserverExtents = newExtents;
            currentObserverOrigin  = newOrigin;
        }
コード例 #8
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();
        }