Esempio n. 1
0
        private async void Init()
        {
            try
            {
                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;
                scene.OperationalLayers[0].Opacity = .5;
            }
            catch (System.Exception ex)
            {
                await DisplayAlert("Failed to load scene", ex.Message, "OK");

                await Navigation.PopAsync();
            }
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                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
                ARView.NorthAlign        = false;
                //Set the clipping distance to only render a circular area around the origin
                ARView.ClippingDistance = 350;
                //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));
                //Listen for double-tap to place
                ARView.GeoViewDoubleTapped += ArView_GeoViewDoubleTapped;
            }
            catch (System.Exception ex)
            {
                Toast.MakeText(this, "Failed to load scene: \n" + ex.Message, ToastLength.Long).Show();
            }
            ToggleRenderPlanes(true);
        }
 private void ArView_GeoViewDoubleTapped(object sender, GeoViewInputEventArgs e)
 {
     if (ARView.SetInitialTransformation(e.Position))
     {
         Toast.MakeText(this, "Placed scene", ToastLength.Short).Show();
     }
     else
     {
         Toast.MakeText(this, "Couldn't place scene", ToastLength.Short).Show();
     }
 }
Esempio n. 4
0
 private void ArView_GeoViewDoubleTapped(object sender, GeoViewInputEventArgs e)
 {
     if (ARView.Scene?.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded)
     {
         return;
     }
     if (ARView.SetInitialTransformation(e.Position))
     {
         //Scene placed successfully
         ARView.Scene.OperationalLayers[0].Opacity = 1;
     }
 }