ArCore .obj FileNotFound异常

时间:2019-06-05 01:10:15

标签: android arcore sceneform

我正在制作一个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$0$LoadRenderableFromSfbTask(LoadRenderableFromSfbTask.java:119)
        at com.google.ar.sceneform.rendering.-$$Lambda$LoadRenderableFromSfbTask$0DkaOpfpmr8DYlbaxWogZtUpKTw.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')

enter image description here

这与我的3D对象的大写命名有关吗?

1 个答案:

答案 0 :(得分:0)

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"))

应该可以。