Forming the AR scene

Now that we have ARCore and Sceneform enabled and our 3D model included in the project, let's add the code that will make the model appear on the screen when a flat surface is detected and the user taps on the screen. Let's get started:

  1. Open your MainActivity.java file from app/java/com.banana.arprototype and add the following imports:
import android.net.Uri;import android.view.Gravity;import android.view.MotionEvent;import android.widget.Toast;import com.google.ar.core.Anchor;import com.google.ar.core.HitResult;import com.google.ar.core.Plane;import com.google.ar.sceneform.AnchorNode;import com.google.ar.sceneform.rendering.ModelRenderable;import com.google.ar.sceneform.ux.ArFragment;import com.google.ar.sceneform.ux.TransformableNode; ...

Get Enterprise Augmented Reality Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.