Rendering scene without AR camera using ARCore

Sumeet Rukeja
Sumeet Rukeja, Android Developer at Yudiz Solutions
Published on Nov 30, 2018 in Augmented Reality Developers Resources
Rendering scene without AR camera using ARCore

This article is a practical case revolving around existing code, which you can download here.

Introduction

If you are really into mobile AR or you are among one of its million admirers (like me), I’m pretty sure that you have dreamt of owning an ARCore-supported device (if you don’t already have one of those).

The list of ARCore-supported devices is like a drop in the vast ocean of Android devices. :D.

Many well-known AR platforms like Vuforia and familiar frameworks like Rajawali are already compatible with older Android devices. Now, Google too has included a feature (a view) for viewing 3D models which can be used with devices not possessing AR camera.

This blog demonstrates the use of SceneView by ARCore.

Enough talk! Let’s code…

Rendering scene without AR camera using ARCore

Prerequisites

  • Basic knowledge of scene from (If you’re not familiar with it, please refer my blog on the same: Sceneform blog)
  • A 3D model (can be downloaded from Google Poly)
  • An Android device having Nougat OS or newer (to run the app)

Code

I’ll use a 3D model of a coffee cup in this demo.

Rendering scene without AR camera using ARCore

Skipping the initialization part and assuming that we are ready with the .sfb file of the 3D model, let’s focus on the core part. (Please refer the blog that I mentioned earlier, in order to generate the .sfb file of a model)

Add SceneView in the XML as shown below.

Rendering scene without AR camera using ARCore

In your activity, add the following methods.

Rendering scene without AR camera using ARCoreRendering scene without AR camera using ARCore

render() method accepts URI of the model (.sfa file) and produces a ModelRenderable object which is passes to addNode() method.

In this method, the node is prepared which has renderable as the ModelRenderable object that the previous method created. The node is added as a child in the scene view.

Don’t forget to resume and pause the sceneView in onResume() and onPause() methods.

Rendering scene without AR camera using ARCore

That’s it. You’re done! The following screenshot shows the output.

Rendering scene without AR camera using ARCore

I have included a link to the git repository for this project. Check it out!

Use cases

Such apps can be used to showcase the catalog of any business in 3D to the users that do not own an AR-supported device.

Conclusion

In general cases, any businessman, developer or investor who has invested a lot of his time and money in building the app, will always want his app to be available to most number of users as possible. This feature can be helpful at such times. And as it is possible to load 3D models in real time, a lot can be thought on the basis of this ARCore functionality.

Find more top mobile app developers worldwide on AppFutura.

Looking for an app or software development company?

You can post a project on AppFutura for free and explain your needs for app or software development. You will receive quotes from qualified companies and will be able to hire the best candidate through a safe payment system.

Post a project

About the author
Sumeet RukejaAndroid Developer at Yudiz Solutions

An Android App Developer with good command over core Java and an increasing interest in Kotlin. Enthusiastic about new technologies in the Android world, including Google ARCore and neural networks. A Machine Learning admirer & in love with flutter. ...

Read more...
You might also like