Esempio n. 1
0
        /// <inheritdoc />
        public WindowsMixedRealitySpatialMeshObserver(string name, uint priority, WindowsMixedRealitySpatialMeshObserverProfile profile, IMixedRealitySpatialAwarenessSystem parentService)
            : base(name, priority, profile, parentService)
        {
#if WINDOWS_UWP
            if (profile.MeshLevelOfDetail == SpatialAwarenessMeshLevelOfDetail.Custom)
            {
                trianglesPerCubicMeter = profile.TrianglesPerCubicMeter;
            }

            if (SpatialSurfaceObserver.IsSupported())
            {
                spatialSurfaceObserver    = new SpatialSurfaceObserver();
                spatialSurfaceMeshOptions = new SpatialSurfaceMeshOptions {
                    IncludeVertexNormals = true
                };

                // TODO Determine which formats are the correct ones to use.
                var supportedVertexPositionFormats = SpatialSurfaceMeshOptions.SupportedVertexPositionFormats;
                var supportedVertexNormalFormats   = SpatialSurfaceMeshOptions.SupportedVertexNormalFormats;

                for (int i = 0; i < supportedVertexPositionFormats.Count; i++)
                {
                    if (supportedVertexPositionFormats[i] == Windows.Graphics.DirectX.DirectXPixelFormat.R16G16B16A16IntNormalized)
                    {
                        spatialSurfaceMeshOptions.VertexPositionFormat = Windows.Graphics.DirectX.DirectXPixelFormat.R16G16B16A16IntNormalized;
                        break;
                    }
                }

                for (int i = 0; i < supportedVertexNormalFormats.Count; i++)
                {
                    if (supportedVertexNormalFormats[i] == Windows.Graphics.DirectX.DirectXPixelFormat.R8G8B8A8IntNormalized)
                    {
                        spatialSurfaceMeshOptions.VertexNormalFormat = Windows.Graphics.DirectX.DirectXPixelFormat.R8G8B8A8IntNormalized;
                        break;
                    }
                }

                // If a very high detail setting with spatial mapping is used, it can be beneficial
                // to use a 32-bit unsigned integer format for indices instead of the default 16-bit.
                if (MeshLevelOfDetail == SpatialAwarenessMeshLevelOfDetail.High)
                {
                    var supportedTriangleIndexFormats = SpatialSurfaceMeshOptions.SupportedTriangleIndexFormats;

                    for (int i = 0; i < supportedTriangleIndexFormats.Count; i++)
                    {
                        if (supportedTriangleIndexFormats[i] == Windows.Graphics.DirectX.DirectXPixelFormat.R8G8B8A8IntNormalized)
                        {
                            spatialSurfaceMeshOptions.TriangleIndexFormat = Windows.Graphics.DirectX.DirectXPixelFormat.R32UInt;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        async private void GalleryGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            VideoItem selectedVideo = (VideoItem)e.ClickedItem;

            if (selectedVideo != null)
            {
                if ((HolographicSpace.IsSupported && HolographicSpace.IsAvailable) ||
                    SpatialSurfaceObserver.IsSupported())
                {
                    var appViewSource = new AppViewSource(selectedVideo.SourceUri);
                    var appView       = CoreApplication.CreateNewView(appViewSource);
                    await appView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        int appviewId  = ApplicationView.GetForCurrentView().Id;
                        bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(appviewId, ViewSizePreference.Default, mainviewId, ViewSizePreference.Default);
                        System.Diagnostics.Debug.Assert(viewShown);
                    });
                }
                else
                {
                    Frame.Navigate(typeof(PlaybackPage), selectedVideo.SourceUri);
                }
            }
        }
Esempio n. 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);
                }
            }
        }