Exemplo n.º 1
0
        private void Initialize()
        {
            // Create and add the scene.
            MyARSceneView.Scene = new Scene(Basemap.CreateImagery());

            // Create the custom location data source and configure the AR scene view to use it.
#if XAMARIN_ANDROID
            _locationSource = new ARLocationDataSource(Android.App.Application.Context);
            _locationSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl;
#elif __IOS__
            _locationSource = new ARLocationDataSource();
#endif
            MyARSceneView.LocationDataSource = _locationSource;

            // Create and add the elevation source.
            _elevationSource  = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
            _elevationSurface = new Surface();
            _elevationSurface.ElevationSources.Add(_elevationSource);
            MyARSceneView.Scene.BaseSurface = _elevationSurface;

            // Configure the surface for AR: no navigation constraint and hidden by default.
            _elevationSurface.NavigationConstraint = NavigationConstraint.None;
            _elevationSurface.Opacity = 0;

            // Create a graphics overlay for the pipes.
            GraphicsOverlay pipesOverlay = new GraphicsOverlay();

            // Use absolute surface placement to see the graphics at the correct altitude.
            pipesOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute;

            // Add graphics for the pipes.
            pipesOverlay.Graphics.AddRange(PipeGraphics);

            // Display routes as red 3D tubes.
            SolidStrokeSymbolLayer strokeSymbolLayer = new SolidStrokeSymbolLayer(0.3, System.Drawing.Color.Red, null, StrokeSymbolLayerLineStyle3D.Tube)
            {
                CapStyle = StrokeSymbolLayerCapStyle.Round
            };
            MultilayerPolylineSymbol tubeSymbol = new MultilayerPolylineSymbol(new[] { strokeSymbolLayer });
            pipesOverlay.Renderer = new SimpleRenderer(tubeSymbol);

            // Configure scene view display for real-scale AR: no space effect or atmosphere effect.
            MyARSceneView.SpaceEffect      = SpaceEffect.None;
            MyARSceneView.AtmosphereEffect = AtmosphereEffect.None;

            // Add the graphics overlay to the scene.
            MyARSceneView.GraphicsOverlays.Add(pipesOverlay);

            // Disable scene interaction.
            MyARSceneView.InteractionOptions = new SceneViewInteractionOptions()
            {
                IsEnabled = false
            };

            // Enable the calibration button.
            CalibrateButton.IsEnabled = true;
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            // Create the custom location data source and configure the AR scene view to use it.
#if XAMARIN_ANDROID
            _locationDataSource = new ARLocationDataSource(Android.App.Application.Context);
            _locationDataSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl;
#elif __IOS__
            _locationDataSource = new ARLocationDataSource();
#endif
            MyARSceneView.LocationDataSource     = _locationDataSource;
            _locationDataSource.LocationChanged += LocationDataSource_LocationChanged;

            // Create the scene and show it.
            _scene = new Scene(BasemapStyle.ArcGISImageryStandard);
            MyARSceneView.Scene = _scene;

            // Create and add the elevation surface.
            _elevationSource = new ArcGISTiledElevationSource(new Uri(
                                                                  "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
            _elevationSurface = new Surface();
            _elevationSurface.ElevationSources.Add(_elevationSource);
            MyARSceneView.Scene.BaseSurface = _elevationSurface;

            // Hide the surface in AR.
            _elevationSurface.NavigationConstraint = NavigationConstraint.None;
            _elevationSurface.Opacity = 0;

            // Create and add a graphics overlay for showing routes.
            _routeOverlay = new GraphicsOverlay();
            MyARSceneView.GraphicsOverlays.Add(_routeOverlay);

            // Configure the graphics overlay to render graphics as yellow 3D tubes.
            SolidStrokeSymbolLayer strokeSymbolLayer = new SolidStrokeSymbolLayer(1, System.Drawing.Color.Yellow, null,
                                                                                  StrokeSymbolLayerLineStyle3D.Tube);
            strokeSymbolLayer.CapStyle = StrokeSymbolLayerCapStyle.Round;
            MultilayerPolylineSymbol tubeSymbol = new MultilayerPolylineSymbol(new[] { strokeSymbolLayer });
            _routeOverlay.Renderer = new SimpleRenderer(tubeSymbol);

            // Configure the space and atmosphere effects for AR.
            MyARSceneView.SpaceEffect      = SpaceEffect.None;
            MyARSceneView.AtmosphereEffect = AtmosphereEffect.None;

            // Set up the route graphic.
            SetRoute(PassedRouteResult.Routes[0]);
        }