public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a new AR Scene View, set its scene, and provide the coordinates for laying it out
            ARView = new ARSceneView();
            // Add the ARSceneView to the Subview
            View.AddSubview(ARView);

            var p     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            var scene = new Scene(Basemap.CreateImagery());

            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")));
            scene.BaseSurface.ElevationExaggeration = 10;
            scene.BaseSurface.NavigationConstraint  = NavigationConstraint.None;
            ARView.TranslationFactor = 100000000;
            // Set pitch to 0 so looking forward looks "down" on earth from space
            ARView.OriginCamera = new Esri.ArcGISRuntime.Mapping.Camera(new MapPoint(0, 0, 20000000, SpatialReferences.Wgs84), 0, 0, 0);
            ARView.NorthAlign   = false;
            await scene.LoadAsync();

            ARView.Scene = scene;

            _ = ARView.StartTrackingAsync();
        }
Exemplo n.º 2
0
        private void CreateLayout()
        {
            // Load the view.
            SetContentView(ArcGISRuntime.Resource.Layout.CollectDataAR);

            // Set up control references.
            _arView          = FindViewById <ARSceneView>(ArcGISRuntime.Resource.Id.arView);
            _helpLabel       = FindViewById <TextView>(ArcGISRuntime.Resource.Id.helpLabel);
            _calibrateButton = FindViewById <Button>(ArcGISRuntime.Resource.Id.calibrateButton);
            _addButton       = FindViewById <Button>(ArcGISRuntime.Resource.Id.addTreeButton);
            _roamingButton   = FindViewById <Button>(ArcGISRuntime.Resource.Id.roamingButton);
            _localButton     = FindViewById <Button>(ArcGISRuntime.Resource.Id.localButton);
            _calibrationView = FindViewById(ArcGISRuntime.Resource.Id.calibrationView);
            _headingSlider   = FindViewById <JoystickSeekBar>(ArcGISRuntime.Resource.Id.headingJoystick);
            _altitudeSlider  = FindViewById <JoystickSeekBar>(ArcGISRuntime.Resource.Id.altitudeJoystick);

            // Disable plane rendering and visualization.
            _arView.ArSceneView.PlaneRenderer.Enabled = false;
            _arView.ArSceneView.PlaneRenderer.Visible = false;

            // Configure button click events.
            _addButton.Click       += AddButtonPressed;
            _calibrateButton.Click += (o, e) => IsCalibrating = !IsCalibrating;
            _roamingButton.Click   += (o, e) => RealScaleValueChanged(true);
            _localButton.Click     += (o, e) => RealScaleValueChanged(false);

            // Configure calibration sliders.
            _headingSlider.DeltaProgressChanged  += HeadingSlider_DeltaProgressChanged;
            _altitudeSlider.DeltaProgressChanged += AltitudeSlider_DeltaProgressChanged;
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView();

            _arSceneView = new ARSceneView();
            _arSceneView.TranslatesAutoresizingMaskIntoConstraints = false;

            _arKitStatusLabel = new UILabel();
            _arKitStatusLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            _arKitStatusLabel.TextAlignment   = UITextAlignment.Center;
            _arKitStatusLabel.TextColor       = UIColor.Black;
            _arKitStatusLabel.BackgroundColor = UIColor.FromWhiteAlpha(1.0f, 0.6f);
            _arKitStatusLabel.Text            = "Setting up ARKit";

            // Add the views.
            View.AddSubviews(_arSceneView, _arKitStatusLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _arSceneView.TopAnchor.ConstraintEqualTo(View.TopAnchor),
                _arSceneView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
                _arSceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _arSceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _arKitStatusLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _arKitStatusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _arKitStatusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _arKitStatusLabel.HeightAnchor.ConstraintEqualTo(40)
            });

            // Listen for tracking status changes and provide feedback to the user.
            _arSceneView.ARSCNViewCameraDidChangeTrackingState += CameraTrackingStateChanged;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Create a new AR Scene View, set its scene, and provide the coordinates for laying it out
            arSceneView = new ARSceneView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            // Add the ARSceneView to the Subview
            View.AddSubview(arSceneView);
            arSceneView.TopAnchor.ConstraintEqualTo(this.View.TopAnchor, 0).Active       = true;
            arSceneView.LeftAnchor.ConstraintEqualTo(this.View.LeftAnchor, 0).Active     = true;
            arSceneView.BottomAnchor.ConstraintEqualTo(this.View.BottomAnchor, 0).Active = true;
            arSceneView.RightAnchor.ConstraintEqualTo(this.View.RightAnchor, 0).Active   = true;
            trackingStatus = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            trackingStatus.Text = "Move the device in a circular motion to detect surfaces...";
            View.AddSubview(trackingStatus);
            trackingStatus.TopAnchor.ConstraintEqualTo(this.View.SafeAreaLayoutGuide.TopAnchor, 0).Active = true;
            trackingStatus.LeftAnchor.ConstraintEqualTo(this.View.LeftAnchor, 0).Active = true;

            arSceneView.OriginCamera           = new Camera(27.988056, 86.925278, 0, 0, 90, 0);
            arSceneView.TranslationFactor      = 10000; //1m device movement == 10km
            arSceneView.PlanesDetectedChanged += ArSceneView_PlanesDetectedChanged;
            arSceneView.GeoViewDoubleTapped   += ArSceneView_GeoViewDoubleTapped;
            arSceneView.RenderPlanes           = true;
            _ = arSceneView.StartTrackingAsync();
        }
Exemplo n.º 5
0
        public static async Task <Scene> CreateBerlin(ARSceneView sv)
        {
            // URL for a scene service of buildings in Brest, France
            Uri buildingsService = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Berlin/SceneServer");
            var iml = new ArcGISSceneLayer(buildingsService)
            {
                Opacity = 1
            };
            await iml.LoadAsync();

            var      observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(new MapPoint(-4.49492, 48.3808, 48.2511, SpatialReferences.Wgs84), 344.488, 74.1212, 0.0);
            MapPoint center         = (MapPoint)GeometryEngine.Project(iml.FullExtent.GetCenter(), SpatialReferences.Wgs84);

            observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(center.Y, center.X, 600, 120, 60, 0);
            var scene = new Scene(Basemap.CreateImagery());

            scene.InitialViewpoint = new Esri.ArcGISRuntime.Mapping.Viewpoint(observerCamera.Location, observerCamera);
            scene.OperationalLayers.Add(iml);
            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")));
            scene.BaseSurface.NavigationConstraint = NavigationConstraint.None;
            sv.TranslationFactor = 1000;
            return(scene);
        }
Exemplo n.º 6
0
        public static async Task <Scene> CreateBrestFrance(ARSceneView sv)
        {
            // URL for a scene service of buildings in Brest, France
            string brestFrance         = @"https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0";
            string _elevationSourceUrl = @"https://scene.arcgis.com/arcgis/rest/services/BREST_DTM_1M/ImageServer";
            var    scene = new Scene(Basemap.CreateImagery());

            var observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(new MapPoint(-4.49492, 48.3808, 48.2511, SpatialReferences.Wgs84), 344.488, 74.1212, 0.0);

            scene.InitialViewpoint = new Esri.ArcGISRuntime.Mapping.Viewpoint(observerCamera.Location, observerCamera);

            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri(_elevationSourceUrl)));
            scene.BaseSurface.NavigationConstraint = NavigationConstraint.None;
            var iml = new ArcGISSceneLayer(new Uri(brestFrance))
            {
                Opacity = 1
            };

            scene.OperationalLayers.Add(iml);
            await iml.LoadAsync();

            sv.TranslationFactor = 250;
            return(scene);
        }
Exemplo n.º 7
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a new AR Scene View, set its scene, and provide the coordinates for laying it out
            ARView = new ARSceneView();
            // Add the ARSceneView to the Subview
            View.AddSubview(ARView);

            lbl = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            lbl.Text = "Move the device in a circular motion to detect surfaces...";
            View.AddSubview(lbl);
            lbl.TopAnchor.ConstraintEqualTo(this.View.TopAnchor, 0).Active   = true;
            lbl.LeftAnchor.ConstraintEqualTo(this.View.LeftAnchor, 0).Active = true;

            var p    = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            var path = System.IO.Path.Combine(p, "philadelphia.mspk");
            MobileScenePackage package = await MobileScenePackage.OpenAsync(path);

            // Load the package.
            await package.LoadAsync();

            // Show the first scene.
            var scene = package.Scenes[0];

            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.NavigationConstraint     = NavigationConstraint.None;
            ARView.Scene = scene;
            //We'll set the origin of the scene in the middle so we can use that as the tie-point
            ARView.OriginCamera      = new Esri.ArcGISRuntime.Mapping.Camera(39.9579126, -75.1705827, 9.64, 0, 90, 0);
            ARView.TranslationFactor = 1000; // By increasing the translation factor, the scene appears as if it's at scale 1:1000
                                             //Set the initial location 1.5 meter in front of and .5m above the scene
            ARView.SetInitialTransformation(TransformationMatrix.Create(0, 0, 0, 1, 0, .5, 1.5));
            //Set the clipping distance to only render a circular area around the origin
            ARView.ClippingDistance = 350;
            //Listend for double-tap to place
            ARView.GeoViewDoubleTapped += ArView_GeoViewDoubleTapped;
            ARView.NorthAlign           = false;
            ARView.RenderPlanes         = true;

            UISwitch sw = new UISwitch()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            sw.ValueChanged += Sw_ValueChanged;
            View.AddSubview(sw);
            sw.TopAnchor.ConstraintEqualTo(this.View.TopAnchor, 0).Active     = true;
            sw.RightAnchor.ConstraintEqualTo(this.View.RightAnchor, 0).Active = true;
            sw.WidthAnchor.ConstraintEqualTo(100);
            sw.HeightAnchor.ConstraintEqualTo(30);

            ARView.PlanesDetectedChanged += ARView_PlanesDetectedChanged;
            _ = ARView.StartTrackingAsync();
        }
Exemplo n.º 8
0
        private void CreateLayout()
        {
            // Load the layout.
            SetContentView(ArcGISRuntime.Resource.Layout.DisplayScenesInTabletopAR);

            // Get references to the UI controls.
            _arSceneView = FindViewById <ARSceneView>(ArcGISRuntime.Resource.Id.arSceneView);
            _helpLabel   = FindViewById <TextView>(ArcGISRuntime.Resource.Id.helpLabel);

            // Request camera permission. Initialize will be called when permissions are granted.
            Initialize();
        }
        private void CreateLayout()
        {
            // Create the layout.
            LinearLayout layout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            // Add the AR scene view.
            _arSceneView = new ARSceneView(this);
            layout.AddView(_arSceneView);

            SetContentView(layout);

            // Request camera permission. Initialize will be called when permissions are granted.
            Initialize();
        }
Exemplo n.º 10
0
        public static async Task <Scene> CreateBartonSchoolHouse(ARSceneView sv)
        {
            var scene = new Scene();

            //scene.InitialViewpoint = new Viewpoint(new MapPoint(34.0508296, -117.215160, SpatialReferences.Wgs84), new Esri.ArcGISRuntime.Mapping.Camera(34.0508296, -117.215160, 385, 0, 0, 0));
            sv.OriginCamera   = new Esri.ArcGISRuntime.Mapping.Camera(34.0508296, -117.215160, 369, 0, 90, 0);
            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")));
            scene.BaseSurface.NavigationConstraint = NavigationConstraint.None;
            sv.TranslationFactor = 150;
            var p    = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            var path = "BartonSchoolHouse_3d_mesh.slpk";

            path = System.IO.Path.Combine(p, path);
            var iml = new IntegratedMeshLayer(new Uri(path, UriKind.Relative))
            {
                Opacity = 1
            };
            await iml.LoadAsync();

            scene.OperationalLayers.Add(iml);
            return(scene);
        }
Exemplo n.º 11
0
 public CalibrationViewController(ARSceneView arView, AdjustableLocationDataSource locationSource)
 {
     this.arView         = arView;
     this.locationSource = locationSource;
 }