[Huawei Developers] John Wo:
What makes a beautiful game loaded with top notch graphics, what makes virtual reality meeting rooms, what makes moving objects and space representation?

I am sure, this would have made you wonder!!

This is possible with 3D image rendering.

3D image rendering is a process to convert any 3D model (which is also done using computer software) into a 2D view on a compute/mobile screen, however ensuring the actual feel of the 3D model.

There are many tools and software to do the conversions on a system but very few supports the same process on an Android Mobile device.

Huawei Scene Kit is a wonderful set of API’s which allows 3D models to display on a mobile screen while converting the 3D models adopting physical based rendering (PBR) pipelines to achieve realistic rendering effects.

Features

Uses physical based rendering for 3D scenes with quality immersion to provide realistic effects.

Offers API's for different scenarios for easier 3D scene construction which makes the development super easy.

Uses less power for equally powerful scene construction using a 3D graphics rendering framework and algorithms to provide high performance experience.

How does Huawei Scene Kit Works

The SDK of Scene Kit, after being integrated into your app, will send a 3D materials loading request to the Scene Kit APK in HMS Core (APK). Then the Scene Kit APK will verify, parse, and render the materials.

Scene Kit also provides a Full-SDK, which you can integrate into your app to access 3D graphics rendering capabilities, even though your app runs on phones without HMS Core.

Scene Kit uses the Entity Component System (ECS) to reduce coupling and implement multi-threaded parallel rendering.

Real-time PBR pipelines are adopted to make rendered images look like in a real world.

The general-purpose GPU Turbo is supported to significantly reduce power consumption.

Huawei Scene Kit supports 3 types of different rendering mechanism

SceneView

ARView

FaceView

Development Overview

Prerequisite

Must have a Huawei Developer Account

Must have Android Studio 3.0 or later

Must have a Huawei phone with HMS Core 4.0.2.300 or later

EMUI 3.0 or later

Software Requirements

Java SDK 1.7 or later

Android 5.0 or later

Supported Devices

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016095720.40110954669882220905351023280201:50511027012340:2800:B793ABA603CD382BBFD64C4F8B6778DBBA4E23E864664CBEB5DD3BB27A359C8B.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016095720.40110954669882220905351023280201:50511027012340:2800:B793ABA603CD382BBFD64C4F8B6778DBBA4E23E864664CBEB5DD3BB27A359C8B.png[/IMG]

Supported 3D Formates

Materials to be rendered: glTF, glb

glTF textures: png, jpeg

Skybox materials: dds (cubemap)

Lighting maps: dds (cubemap)

Note: These materials allow for a resolution of up to 4K.

Preparation

Create an app or project in the Huawei app gallery connect.

Provide the SHA Key and App Package name of the project in App Information Section and enable the required API.

Create an Android project.

Note: Scene Kit SDK can be directly called by devices, without connecting to AppGallery Connect and hence it is not mandatory to download and integrate the agconnect-services.json.

Integration

Add below to build.gradle (project)file, under buildscript/repositories and allprojects/repositories.

Maven {url 'http://developer.huawei.com/repo/'}

Add below to build.gradle (app) file, under dependencies.

To use the SDK of Scene Kit, add the following dependencies:

dependences {
implementation 'com.huawei.scenekit:sdk:{5.0.2.302}'
}

To use the Full-SDK, add the following dependencies:

dependencies {
implementation 'com.huawei.scenekit:full-sdk:{5.0.2.302}'

Adding permissions

<uses-permission android:name="android.permission.CAMERA " />

Development Process

This article focus on demonstrating the capabilities of Huawei’s Scene Kit: Scene View API’s.

Here is the example which explains how we can integrate a simple 3D Model (Downloaded from the free website: https://sketchfab.com/ ) with Scene View API’s to showcase the space view of AMAZON Jungle.

Download and add supported 3D model into the App’s asset folder.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016095859.09180302382560599661081199096315:50511027012340:2800:732D701CF3FFBB3A60F20197D773F020606D25A852A6E3E1E93E1CD4B1625ED4.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016095859.09180302382560599661081199096315:50511027012340:2800:732D701CF3FFBB3A60F20197D773F020606D25A852A6E3E1E93E1CD4B1625ED4.png[/IMG]

Main Activity

Launcher activity for the application which has a button to navigate and display the space view.

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dbg"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/btn"
android:onClick="onBtnSceneViewDemoClicked"
android:text="@string/btn_text_scene_kit_demo"
android:textColor="@color/upsdk_white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>

Space View Activity

It’s a java class which holds the logic to render the 3D models using the API’s and display them in a surface view.

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;

import com.huawei.hms.scene.sdk.SceneView;

public class SceneSampleView extends SceneView {

/* Constructor - used in new mode.*/
public SceneSampleView(Context context) {
super(context);
}
public SceneSampleView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
super.surfaceCreated(holder);

// Loads the model of a scene by reading files from assets.
loadScene("SceneView/scene.gltf");
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
super.surfaceChanged(holder, format, width, height);
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
super.surfaceDestroyed(holder);
}

@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return super.onTouchEvent(motionEvent);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
}

Results

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016100629.85566331361671372626802534749962:50511027012340:2800:A7AEBDBF8DD084DB7AE888AF911DEFBE5C49EA6418F998F635B44D4FA479C9FC.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016100629.85566331361671372626802534749962:50511027012340:2800:A7AEBDBF8DD084DB7AE888AF911DEFBE5C49EA6418F998F635B44D4FA479C9FC.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016100825.90049562276274039340615836753557:50511027012340:2800:CA8142D35C202EE92ED4C122CB749373AA179B5F339CD47DA282EC89E7F5D026.gif"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/834/235/2640091000001834235.20201016100825.90049562276274039340615836753557:50511027012340:2800:CA8142D35C202EE92ED4C122CB749373AA179B5F339CD47DA282EC89E7F5D026.gif[/IMG]

Conclusion

We learnt a simple application which demonstrate the Scene View API’s and showcase how easy it is to have the 3D models shown on the applications.

More information, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201382255415980474&fid=0101187876626530001