1/5

ARCore Assignment

Extending the Sceneform basic app with some models

Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Android developer website. Please do not hesitate to ask me or the tutor if you have any questions. Under „Tip“ you can find some hints for the task. The „Checklist“ specifies what should happen when your implementation is correct.

2/5

Tasks

  1. Create a 3D model object
  2. Add the model to the scene
3/5

Install the Sceneform Plugin

To install the Sceneform Plugin in Android Studio go to: Menu -> Preferences -> Plugins and there select the “Google Scenform Tools (Beta)”.

center 60%

As you see, this is still a Beta software, so there might be some issues when working with it. Sceneform is also needed to simply import your own assets (e.g. 3D Models) into a ARCore compatible format.

4/5

Import the models

Android Studio 3.1 supports a new folder type named “sampledata”. This folder is used for design time sample data. For our purposes, we’ll keep the source 3D assets in this directory. Files in sampledata are not added to the APK, but available in the editor. To make sceneform compatible models, we’ll add the conversion tasks to gradle and add them to the assets directory so they are available at runtime.

Create the sample data directory by clicking on app in the project view and then right mouse click to find the menu item New > Sample Data Directory.

There is one example model of andy the robot that you can download here.

Extract the .zip and copy both files into the sampledata/models folder. If there is no models folder, create it by right-click on the sampledata-> New -> Directory. Type models as the name of the new directory and click on finish.

We’ll use the Sceneform plugin to add the conversion tasks to the build.gradle file and preview the models.

Select app/sampledata/models/andy.obj and then right mouse click to get the menu and pick New > Sceneform asset. This opens the import wizard page as shown here:

center 60%

Make sure you set as output path the /res/raw folder so the import is easy using the R class (e.g. R.raw.andy). If there is no /res/raw folder in your project, then create this first.

Important!!!

There is a bug with the current version of the Sceneform Plugin 1.4.0: it will generate models that can’t be loaded in the app. To overcome this use the old version of the plugin for generating the .sfa and .sfb files. To install the old version got to your Projects build.gradle file and in dependecies {} replace the

classpath 'com.google.ar.sceneform:plugin:1.4.x'

with

classpath 'com.google.ar.sceneform:plugin:1.0.1'

Then clean and rebuild your projekt and regenerate the .sfa and .sfb files.

5/5

Placing the model in the scene

Now that you have imported the model, add an OnTapARPlaneListener on the ARFragement and implement the following functionality:

Tip

Refer to the slides 02-ARCore-SceneForm-Basics for code snippets.

Checklist
The app runs on the phone showing the dottet pattern when moving around. This is where we will place our objects.
When taping on the dotted pattern, the 3D model will appear. It is movable and responds to gestures