简体   繁体   English

ARCore:关于从虚拟设备加载资产​​的Sceneform演示错误

[英]ARCore: Sceneform demo bug on loading asset from virtual device

Hi and thanks in advance to anyone who can help me or give me some suggestions. 您好,在此先感谢可以帮助我或给我一些建议的任何人。

I was working on the Google ARCore demo, specifically the " Hellosceneform " one, where user can put a 3D model on a plane. 我正在研究Google ARCore演示,特别是“ Hellosceneform ”演示,用户可以在其中将3D模型放到飞机上。

To test the import of different 3D assets, I changed the default "Andy" 3D model with another 3D model made by me, in the usual .sfb format and I tested the demo on Android Emulator. 为了测试不同3D资产的导入,我将默认的“ Andy” 3D模型更改为由我制作的另一种3D模型(通常为.sfb格式),并在Android Emulator上测试了该演示。

The problem is this: 问题是这样的:

  • if I load a 3D asset from the " raw " directory into the demo works perfectly... 如果我将“ raw ”目录中的3D资源加载到演示中,则效果很好...
  • ... BUT , in the Android Emulator , if I load an asset from a directory on the device filesystem (for example, the default appath of ' sceneform ' demo) the ModelRenderable (called andyRenderable in my code) in onTapListener is always null! ...... 可是在Android模拟器 ,如果我从一个目录中加载的资产上的设备的文件系统 (例如,默认appath “的sceneform ”演示)的ModelRenderable (称为andyRenderable在我的代码)在onTapListener 总是空!

More importantly : the demo works perfectly on a real phone, in both situation ( raw and device file system). 更重要的是 :在两种情况下( raw文件和设备文件系统),该演示都可以在真实电话上完美运行。

The code that loads the 3D asset is this: 加载3D资产的代码是这样的:

    File fsfb = new File(local_path + "/" + "prova3.sfb");

    Uri usfb = Uri.fromFile(fsfb);
    ModelRenderable.builder()
            .setSource(this, usfb)
            .build()
            .thenAccept(renderable -> andyRenderable = renderable)
            .exceptionally(
                    throwable -> {
                        Toast toast =
                                Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
                        toast.setGravity(Gravity.CENTER, 0, 0);
                        toast.show();
                        return null;
                    });

And the onTapListener code is this: 而onTapListener代码是这样的:

arFragment.setOnTapArPlaneListener(
            (HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {

                if(nn >= 3 || andyRenderable == null)
                {
                    return;
                }
                nn++;

Solved. 解决了。

It was a matter of wrong permissions for the raw directory (it was impossible to load the model, it needed " rw " settings). 原始目录的权限有问题(无法加载模型,需要“ rw ”设置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM