Explore scenes in flyover AR

View on GitHubSample viewer app

Use augmented reality (AR) to quickly explore a scene more naturally than you could with a touch or mouse interface.

screenshot

Use case

You can use AR to drop into an area and visualize information, like a proposed development or a historical model of a city. You could use flyover AR to explore a city by walking through it virtually.

How to use the sample

When you open the sample, you'll be viewing the scene from above. You can walk around, using your device as a window into the scene. Try moving vertically to get closer to the ground.

How it works

  1. Create the ArcGISARView and add it to the view.
  2. Create the scene, add content, then display it.
  3. When the content you want to view loads, get its center point and use that to create the origin camera for the AR view. Note that the altitude should be set so that all scene content is visible. For a city, a good value might be a bit higher than the tallest building. The sample uses 250 meters in the absence of tall buildings in the sample data.
  4. Set the translation factor so that you can move through the scene easily. With a translation factor of 1000, you will move 1000 feet in the scene for every foot you move the physical device.
  5. Set the space effect to SpaceEffect::Stars and atmosphere effect to AtmosphereEffect::Realistic to create an immersive experience.

Relevant API

  • ArcGISARView
  • SceneView

About the data

This sample uses a sample integrated mesh layer provided by Vricon. The integrated mesh layer shows an area around the US-Mexico border.

The world elevation service is used to show terrain while the integrated mesh layer loads.

Additional information

Flyover AR is one of three main patterns for working with geographic information in augmented reality. Augmented reality is made possible with the ArcGIS Maps SDK for Qt Toolkit. See Augmented reality in the guide for more information about augmented reality and adding it to your app.

Clone the toolkit repo - Required for AR samples

Change directory into your locally cloned samples repo and then use git clone to get a copy of the ArcGIS Maps SDK for Qt Toolkit.

# Change directory to the clone of the samples repository
# Clone the toolkit repository into the current directory in terminal
$ cd /arcgis-maps-sdk-samples-qt
$ git clone https://github.com/Esri/arcgis-maps-sdk-toolkit-qt.git

Cloning the toolkit in this location will allow for the samples to automatically pick it up. If you wish to place the toolkit in another location, you will need to update the samples project file accordingly to locate the necessary .pri file.

For more information on the Augmented Reality (AR) toolkit, including the steps required to deploy to Android and iOS, see the AR README on GitHub.

Tags

augmented reality, bird's eye, birds-eye-view, fly over, flyover, mixed reality, translation factor

Sample Code

ExploreScenesInFlyoverAR.cppExploreScenesInFlyoverAR.cppExploreScenesInFlyoverAR.hExploreScenesInFlyoverAR.qml
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// [WriteFile Name=ExploreScenesInFlyoverAR, Category=AR]
// [Legal]
// Copyright 2020 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

#ifdef PCH_BUILD
#include "pch.hpp"
#endif // PCH_BUILD

// sample headers
#include "ExploreScenesInFlyoverAR.h"

// ArcGIS Maps SDK headers
#include "ArcGISTiledElevationSource.h"
#include "ElevationSourceListModel.h"
#include "Envelope.h"
#include "Error.h"
#include "IntegratedMeshLayer.h"
#include "LayerListModel.h"
#include "MapTypes.h"
#include "Point.h"
#include "Scene.h"
#include "SceneQuickView.h"
#include "SceneViewTypes.h"
#include "Surface.h"

using namespace Esri::ArcGISRuntime;
namespace toolkit = Esri::ArcGISRuntime::Toolkit;

ExploreScenesInFlyoverAR::ExploreScenesInFlyoverAR(QObject* parent /* = nullptr */):
  QObject(parent),
  m_scene(new Scene(BasemapStyle::ArcGISImageryStandard, this))
{
  // create a new elevation source from Terrain3D REST service
  ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(
        QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);

  // add the elevation source to the scene to display elevation
  m_scene->baseSurface()->elevationSources()->append(elevationSource);
  m_scene->baseSurface()->setOpacity(0.0f);

  // create the integrated mesh layer
  const QUrl meshLyrUrl("https://www.arcgis.com/home/item.html?id=5c55d0d1f21e489193cdeff11460a28c");
  m_integratedMeshLayer = new IntegratedMeshLayer(meshLyrUrl, this);

  // add the layer to the scene
  m_scene->operationalLayers()->append(m_integratedMeshLayer);

  connect(m_integratedMeshLayer, &IntegratedMeshLayer::doneLoading, this, [this](const Error& e)
  {
    if (!e.isEmpty())
    {
      qDebug() << e.errorType() << ":" << e.message() << "-" << e.additionalMessage();
      return;
    }

    // Enable subsurface navigation. This allows you to look at the scene from below.
    m_scene->baseSurface()->setNavigationConstraint(NavigationConstraint::StayAbove);
    m_scene->baseSurface()->setOpacity(1.0f);

    const Point centerPoint = m_integratedMeshLayer->fullExtent().center();

    // Start with the camera at the center of the mesh layer.
    m_originCamera = Camera(centerPoint.y(), centerPoint.x(), 250, 0, 90, 0);
    arcGISArView()->setOriginCamera(m_originCamera);

    // Set the translation factor to enable rapid movement through the scene.
    arcGISArView()->setTranslationFactor(1000);

    // Enable atmosphere and space effects for a more immersive experience.
    m_sceneView->setSpaceEffect(SpaceEffect::Stars);
    m_sceneView->setAtmosphereEffect(AtmosphereEffect::Realistic);
    emit arcGISArViewChanged();
    emit sceneViewChanged();
  });
}

ExploreScenesInFlyoverAR::~ExploreScenesInFlyoverAR() = default;

void ExploreScenesInFlyoverAR::init()
{
  // Register classes for QML
  qmlRegisterType<SceneQuickView>("Esri.Samples", 1, 0, "SceneView");
  qmlRegisterType<ExploreScenesInFlyoverAR>("Esri.Samples", 1, 0, "ExploreScenesInFlyoverARSample");
}

SceneQuickView* ExploreScenesInFlyoverAR::sceneView() const
{
  return m_sceneView;
}

toolkit::ArcGISArView* ExploreScenesInFlyoverAR::arcGISArView() const
{
  return m_arcGISArView;
}

// Set the view (created in QML)
void ExploreScenesInFlyoverAR::setSceneView(SceneQuickView* sceneView)
{
  if (!sceneView || sceneView == m_sceneView)
    return;

  m_sceneView = sceneView;
  m_sceneView->setArcGISScene(m_scene);

  emit sceneViewChanged();
}

// Set the AR view
void ExploreScenesInFlyoverAR::setArcGISArView(toolkit::ArcGISArView* arcGISArView)
{
  if (!arcGISArView || arcGISArView == m_arcGISArView)
    return;

  m_arcGISArView = arcGISArView;
  m_arcGISArView->setTracking(true);

  emit arcGISArViewChanged();
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.