ArCore .obj FileNotFound 异常

ArCore .obj FileNotFound exception

我正在制作一个 ArCore 应用程序,当我构建我的 ModelRenderable 时,我抛出了这个异常:

java.util.concurrent.CompletionException: java.io.FileNotFoundException: Coffee Cup_final.obj (No such file or directory)
        at com.google.ar.sceneform.utilities.SceneformBufferUtils.inputStreamToByteBuffer(SourceFile:49)
        at com.google.ar.sceneform.rendering.LoadRenderableFromSfbTask.lambda$downloadAndProcessRenderable[=10=]$LoadRenderableFromSfbTask(LoadRenderableFromSfbTask.java:119)
        at com.google.ar.sceneform.rendering.-$$Lambda$LoadRenderableFromSfbTask[=10=]DkaOpfpmr8DYlbaxWogZtUpKTw.get(Unknown Source:4)
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1625)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.io.FileNotFoundException: Coffee Cup_final.obj (No such file or directory)
        at java.io.FileInputStream.open0(Native Method) 

但是我可以看到这个文件存在。这是可渲染的,然后是构建 gradle.

ModelRenderable.builder()
                .setSource(this, Uri.parse("Coffee Cup_final.obj.obj"))
                .build()
                .thenAccept(this::onRenderableLoaded)
                .exceptionally(throwable -> {
                    Log.i("Sceneform", "failed to load model");
                    return null;
                });

sceneform.asset('sampledata/Coffee Cup_final.obj.obj',
            'default',
            'sampledata/Coffee Cup_final.obj.sfa',
            'src/main/assets/Coffee Cup_final.obj')

跟我的3D大写命名有关系吗object?

build.gradle 中的 sceneform.asset() 步骤将 OBJ 文件转换为 Sceneform 的内部 SFB 文件格式。因此,创建并复制到资产文件夹的文件是 src/main/assets/Coffee Cup_final.obj.sfb 。所以如果你改变

ModelRenderable.builder().setSource(this, Uri.parse("Coffee Cup_final.obj.obj"))

ModelRenderable.builder().setSource(this, Uri.parse("Coffee Cup_final.obj.sfb"))

应该可以。