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; }
/// <summary> /// Creates a WFS XML filter string. /// </summary> /// <param name="filter">The filter string.</param> /// <param name="geometryName">Name of the geometry object.</param> /// <param name="boundingBox">The bounding box.</param> /// <returns>A string containing WFS XML-text.</returns> private static string CreateWfsXmlFilterString(string filter, string geometryName, WfsBoundingBox boundingBox) { FormulaOperation formulaOperation; SpatialOperation bboxOperation = null; if (string.IsNullOrEmpty(geometryName)) { geometryName = "the_geom"; } if (boundingBox != null) { SpatialBoundingBox spatialBoundingBox = new SpatialBoundingBox(boundingBox.MinX, boundingBox.MinY, boundingBox.MaxX, boundingBox.MaxY, boundingBox.SrsName); bboxOperation = new SpatialOperation(new SpatialFieldValue(geometryName), spatialBoundingBox, WFSSpatialOperator.InsideBbox); } if (string.IsNullOrEmpty(filter)) { formulaOperation = bboxOperation ?? null; } else { WfsFormulaParser parser = new WfsFormulaParser(); formulaOperation = parser.Parse(filter); if (bboxOperation != null) { formulaOperation = new BinaryLogicalOperation(formulaOperation, bboxOperation, WFSBinaryLogicalOperator.And); } } WFSFilter wfsFilter = new WFSFilter { Formula = formulaOperation }; string strWfsXmlRepresentation = wfsFilter.WfsXmlRepresentation(); return(strWfsXmlRepresentation); }
async void CreateSecondaryTile() { rootPage.NotifyUser("", NotifyType.StatusMessage); if (glbUri == null) { rootPage.NotifyUser("Please pick content to be shown.", NotifyType.ErrorMessage); return; } // Create a guid to use as a unique tile id string tileId = GenerateTileId(); var logoUri = new Uri("ms-appx:///Assets/squareTile-sdk.png"); var tile = new SecondaryTile( tileId, // TileId glbName, // Display Name tileId, // Arguments logoUri, // Square150x150Logo TileSize.Square150x150); // DesiredSize // Set the mixed reality model properties. TileMixedRealityModel model = tile.VisualElements.MixedRealityModel; model.Uri = glbUri; if (BoundingBoxCheckBox.IsChecked.Value) { var boundingBox = new SpatialBoundingBox(); boundingBox.Center = new Vector3( ParseFloatOrDefault(BoundingBoxCenterXTextBox.Text), ParseFloatOrDefault(BoundingBoxCenterYTextBox.Text), ParseFloatOrDefault(BoundingBoxCenterZTextBox.Text)); boundingBox.Extents = new Vector3( ParseFloatOrDefault(BoundingBoxExtentsXTextBox.Text), ParseFloatOrDefault(BoundingBoxExtentsYTextBox.Text), ParseFloatOrDefault(BoundingBoxExtentsZTextBox.Text)); model.BoundingBox = boundingBox; } // Create the tile bool created = await tile.RequestCreateAsync(); if (created) { // Warn the user that they need to be in the headset for anything interesting to happen. if (!HolographicApplicationPreview.IsCurrentViewPresentedOnHolographicDisplay()) { rootPage.NotifyUser("3D content can be created only while the view is being displayed in a Mixed Reality headset.", NotifyType.StatusMessage); } } else { rootPage.NotifyUser("Could not create secondary tile.", NotifyType.ErrorMessage); } }
/// <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); }
public void WfsFilterWfsXmlRepresentation_BoundingBox_CorrectXmlRepresentationIsCreated() { string strFilter = "<Filter><Or><PropertyIsEqualTo><PropertyName>LänSKOD</PropertyName><Literal>5</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>LänSKOD</PropertyName><Literal>6</Literal></PropertyIsEqualTo></Or></Filter>"; WfsFormulaParser parser = new WfsFormulaParser(); FormulaOperation formulaOperation = parser.Parse(strFilter); SpatialBoundingBox spatialBoundingBox = new SpatialBoundingBox(-180, -90, 180, 90, "EPSG:4326"); var bboxOperation = new SpatialOperation(new SpatialFieldValue("the_geom"), spatialBoundingBox, WFSSpatialOperator.InsideBbox); formulaOperation = new BinaryLogicalOperation(formulaOperation, bboxOperation, WFSBinaryLogicalOperator.And); WFSFilter wfsFilter = new WFSFilter { Formula = formulaOperation }; string strWfsXmlRepresentation = wfsFilter.WfsXmlRepresentation(); string expectedXmlString = "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\"><ogc:And><ogc:Or><ogc:PropertyIsEqualTo matchCase=\"true\"><ogc:PropertyName>LänSKOD</ogc:PropertyName><ogc:Literal>5</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo matchCase=\"true\"><ogc:PropertyName>LänSKOD</ogc:PropertyName><ogc:Literal>6</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or><ogc:BBOX><ogc:PropertyName>the_geom</ogc:PropertyName><gml:Envelope xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"EPSG:4326\"><gml:lowerCorner>-180 -90</gml:lowerCorner><gml:upperCorner>180 90</gml:upperCorner></gml:Envelope></ogc:BBOX></ogc:And></ogc:Filter>"; Assert.IsNotNull(formulaOperation); Assert.AreEqual(expectedXmlString, strWfsXmlRepresentation); }
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); } } }
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; } }
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(); }
async void CreateSecondaryTile() { // Warn the user that they need to be in the headset for anything interesting to happen. if (!HolographicApplicationPreview.IsCurrentViewPresentedOnHolographicDisplay()) { ContentDialog dialog = new ContentDialog() { Title = "Secondary Tile", Content = "3D content can be created only while the view is being displayed in a Mixed Reality headset.", CloseButtonText = "Ok", }; await dialog.ShowAsync(); return; } try { if (glbPath == null && !await SelectGlb()) { return; } // Create a guid to use as a unique tile id string tileId = GenerateTileId(); var logoUri = new Uri("ms-appx:///assets/Square150x150Logo.png"); var tile = new SecondaryTile( tileId, // TileId glbPath.Name, // DisplayName tileId, // Arguments logoUri, // Square150x150Logo TileSize.Square150x150); // DesiredSize TileMixedRealityModel model = tile.VisualElements.MixedRealityModel; var tcs = new TaskCompletionSource <string>(); var copiedPath = await CopyAssetToLocalAppData(); if (String.IsNullOrEmpty(copiedPath)) { return; } model.Uri = new Uri(copiedPath); if (CreateWithBoundingBox) { var boundingBoxCenterFloats = BoundingBoxCenter.Split(',').Select(s => ParseWithDefault(s, 0f)).ToArray(); var boundingBoxExtentsFloats = BoundingBoxExtents.Split(',').Select(s => ParseWithDefault(s, 1f)).ToArray(); var boundingBox = new SpatialBoundingBox(); if (boundingBoxCenterFloats.Length == 3) { boundingBox.Center = new Vector3(boundingBoxCenterFloats[0], boundingBoxCenterFloats[1], boundingBoxCenterFloats[2]); } if (boundingBoxExtentsFloats.Length == 3) { boundingBox.Extents = new Vector3(boundingBoxExtentsFloats[0], boundingBoxExtentsFloats[1], boundingBoxExtentsFloats[2]); } model.BoundingBox = boundingBox; } if (DoNotActivate) { model.ActivationBehavior = TileMixedRealityModelActivationBehavior.None; } // Commit the tile bool created = await tile.RequestCreateAsync(); if (!created) { ContentDialog dialog = new ContentDialog() { Title = "Secondary Tile", Content = "Creation denied", CloseButtonText = "Ok", }; await dialog.ShowAsync(); } } catch { ContentDialog dialog = new ContentDialog() { Title = "Secondary Tile", Content = "Failed to create", CloseButtonText = "Ok", }; await dialog.ShowAsync(); } }