Concise notes for the impatient learner

Uncategorized

Vuforia Smart Terrain in Unity

Objective

Set up Vuforia Smart Terrain feature in Unity.

Introduction

The Smart Terrain feature in Vuforia builds a 3D model of the environment, so objects in the environment can interact with the virtual objects in your scene in a more realistic manner. For example, if a physical object is in front of a virtual object, you want the physical object to block the view of the virtual object.

Prerequisites

Set up the Unity project described in Augmented Reality with Unity, Vuforia, and Google VR. This post adds more features on top of that project.

Steps

Start with the project created in the previous post, as described in the prerequisites section.

Under the Project tab, find Smart Terrain

Vuforia_SmartTerrain_ProjectTab

Drag and drop Smart Terrain on the scene

Vuforia_SmartTerrain_DragOnScene

The Primary Surface and Prop Template will be displayed. These represent the 3D features Smart Terrain will detect in the physical environment.

Vuforia_SmartTerrain_PrimarySurface

Select ARCamera. Change the World Center Mode to “Specific Target” and World Center to “Primary Surface”.

Vuforia_SmartTerrain_WorldCenter

Select Image Target and find Image Target Behavior. Enable Smart Terrain. Select the Smart Terrain instance in your scene.

Vuforia_SmartTerrain_Enable

Open Vuforia Configuration and find Smart Terrain Tracker. Select Start Automatically. With this option, scanning of the environment will start automatically when the application is launched.
Set the scale (100 in the example). The scale determines the relative size of the virtual world and the physical world.

Vuforia_SmartTerrain_Tracker.png

Build and run the application on your favorite device.
When Vuforia detects the Image Target it will start scanning the environment to build a 3D model of it. Scan your camera around the environment slowly to capture the different angles of the objects.
Once objects are detected and modeled, try to move a physical object in front of your virtual object to test the effect. Make sure not to cover the Image Target, otherwise the virtual object will disappear.

Useful Links

Smart Terrain on Vuforia site

Vuforia Smart Terrain Tutorial – Augmented Reality in Unity
Very useful YouTube video introducing Smart Terrain in Unity.

Leave a Reply