Native Vuforia Engine Sample

The native sample for Android, iOS and UWP provides a good starting point for familiarizing yourself with native Vuforia Engine development. This guide will explain the main elements of the sample and their roles.

Datasets

The sample contains the following two datasets:

  • StonesAndChips (Assets/ImageTargets)
  • Mars Lander (Assets/ModelTargets)

Each dataset has a .dat and an .xml file that goes with it. Before running the sample, you should print the Image Target, which is found in the Media directory. To detect and track the Model Target you will need to 3D print the model, instructions can be found in the Media directory or follow the guide on Printing and Assembling the Viking Lander.

Using the app

In order to deploy the sample to your device, please follow the guides’ sections on deploying the sample. The guides for this can be found here: AndroidiOS, and UWP.

Upon launching the app, a main menu will be shown from which you can select between the Image Targets or Model Targets feature:

Select one of the two features, point the device to the corresponding targets and the device should display an augmentation over the target.

You can trigger the camera to re-focus by single-tapping on the screen.

You can navigate back to the target menu by double-tapping on the screen.

High Level Code Structure

The code for the sample is in 2 main parts, the platform specific code for the application and cross-platform code wrapping interaction with Vuforia APIs.

Within the platform specific code there are 3 UI elements:

  • A splash screen shown during app startup.
  • A main menu to choose between using an Image Target or a Model Target.
  • A Vuforia AR experience which renders an augmentation on the chosen target.

The table below lists the primary source files for each of these 3 UI elements:

 

Android

iOS

UWP

Splash Screen SplashScreenActivity.kt LaunchScreen.storyboard Package.appxmanifest
Main Menu MainActivity.kt
activity_main.xml
ViewController.swift
Main.storyboard
MainPage
.xaml/.idl/.h/.cpp
Vuforia AR Experience VuforiaActivity.kt VuforiaViewController.swift
VuforiaView.swift
VuforiaPage
.xaml/.idl/.h/.cpp

Cross-platform AppController

The native sample includes a cross-platform AppController class that wraps most Vuforia API calls to provide single abstraction that can be used on Android, iOS and UWP. The AppController is found in the CrossPlatform directory along with a set of utility classes. For details of the AppController’s methods please see AppController.h.

Rendering

For each platform the sample app demonstrates using the platform preferred rendering API:

Android

OpenGLES 3

GLESRenderer.h/.cpp

iOS Metal MetalRenderer.swift
UWP DirectX 11 DXRenderer.h/.cpp

The rendering classes have a similar API, in particular each has the following methods for Vuforia AR rendering:

  • renderVideoBackground
  • renderWorldOrigin
  • renderImageTarget
  • renderModelTarget
  • renderModelTargetGuideView

The sample includes a number of other classes to support rendering on each supported platform.