Rendering scene without AR camera using ARCore

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.

About the author
Yudiz Solutions Pvt. Ltd.Mobile app development company in India
ContactVisit website

Yudiz Solutions Pvt. Ltd. is an ISO 9001:2015 certified software development company having 9+ years of quality global exposure in IT services. We have successfully worked on 1500+ projects and served renown clients like Groupon, Nestle, NEC, Ubisoft, Havas Group, Tv18, McLaren, and Ketchapp.

You might also like