Search code examples
androidarcoregltfsceneview

How can I load my glTF file on SceneViewer with ARCore Android SDK


I'm following the document at Google (https://developers.google.com/ar/develop/java/scene-viewer#ar-only).

I put glTF file in assets/models directory (as same location with Andy.obj)

and I tried to load glTF 2.0 file (from KhronosGroup Sample) but failed:

    Intent sceneViewerIntent = new Intent(Intent.ACTION_VIEW);
    Uri intentUri =
            Uri.parse("https://arvr.google.com/scene-viewer/1.0").buildUpon()
                    .appendQueryParameter("file", "models/BoxTextured.glb")
                    .appendQueryParameter("mode", "ar_preferred")
                    .appendQueryParameter("title", "Untitled")
                    .build();
    sceneViewerIntent.setData(intentUri);
    sceneViewerIntent.setPackage("com.google.ar.core");
    startActivity(sceneViewerIntent);

In document (which linked above), there is no clue how to write the code to load glTF from local.

what can I do for resolved this problem in android?

Thanks.

edit: The source is based on https://github.com/google-ar/arcore-android-sdk/tree/master/samples/hello_ar_java, and I worked HelloArActivity.java, ARCore Android SDK version is 1.17.0


Solution

  • I solved it by myself.

    Set path for glTF to absolute path (like "/sdcard/BoxTextured.glb", not "models/BoxTextured.glb")

    I think it can not find (also no convert) relative path from that function.

    You have to get a path by //assets/~ or something if you want to use relative path.


    EDIT:

    also, there is Environment class which has method getExternalStorageDirectory().getAbsolutePath(). i might be solved above problem.