AR with 3D objects in Android

Mar 25 2020Written by Manektech Team

ARCore, augmented reality (AR) will deploy the digital objects into the real world system via camera interface. ARCore, enabling experiences that are more natural, interactive UI/UX support and helpful. You can add 3D objects in the real world system and interact with those, how it looks if they were present in real life.

We will learn how to build 3D objects and deploy using the ARCore feature provided by Google.

Set up your development environment
1. Android Studio version 3.1 or higher with Android SDK Platform version 7.0 (API level 24) or higher
2. You can run AR apps on a supported device or in the Android Emulator
3. OpenGL ES 3.0 or higher required
4. Android Emulator 27.2.9 or later
5. Clone the google sample application from

git clone: https://github.com/google-ar/sceneform-android-sdk.git

Add AR dependency com.google.ar.sceneform:core:1.15.0 to use the predefined functions to manipulate the objects easily.

Declare the <meta-data> information for the AR as below. You can make AR features optional or required by declaring a value flag inside the meta-data. This will affect the application visibility inside the Google Play Store. If value="optional"then application will be displayed to all the devices even if they are not supporting the AR feature. value="required"then Google Play will display applications only to the devices which have the AR feature.

Android Manifest to declare AR Optional for the application:

   <meta-data android:name="com.google.ar.core" android:value="optional" />

App with AR Support compulsorily:

Check whether ARCore is supported

Check Google Play Services for AR is installed or not

App must call ArCoreApk.requestInstall() to check if Google Play Services is installed or not.

Open the demo system ‘solarsystem’ available inside the samples folder. Import the project inside Android Studio. Please take note that .sfb file is a 3d model representation file.

Add ArSceneView for showing Augmented view in layout file

Build all the planet models.

  

Build a renderable from a 2D View.

ARCore's motion tracking technology uses the phone's camera to identify interesting points, called features, and tracks how those points move over time. With a combination of the movement of these points and readings from the phone's inertial sensors, ARCore determines both the position and orientation of the phone as it moves through space.

Set an update listener on the Scene that will hide the loading message once a Plane is detected.   

ARCore looks for clusters of feature points that appear to lie on common horizontal or vertical surfaces, like tables or walls, and makes these surfaces available to your app as planes. ARCore can also determine each plane's boundary and make that information available to your app. You can use this information to place virtual objects resting on flat surfaces.

Place the solar system once detect the plane surface

        // Create solar system using the nodes

Create planet individual

Using ARCore Sceneform , a 3D framework that makes it easy for Java developers to build ARCore apps without OpenGL.

ARCore's understanding of the real world lets you place objects, annotations, or other information in a way that integrates seamlessly with the real world. You can place a napping kitten on the corner of your coffee table, or annotate a painting with biographical information about the artist.

Create planet function

After this, the camera will detect the surface and place the solar system objects will be visible on the surface. You can Touch objects for information and zoom in or out according to your preference. You can also move the phone close to the object or move to any direction to see the planets in 3D in front of you.

Contact us

Here to Help ambitious people TRANSFORM the Digital Solutions!