【问题标题】:Classic ARCore-Sceneform's Augmented Image sample translation to Sceneform 1.16.0Classic ARCore-Sceneform 的增强图像示例转换为 Sceneform 1.16.0
【发布时间】:2020-08-04 12:29:07
【问题描述】:

我正在尝试将 Sceneform 1.15.0 的 增强图像示例 转换为与 ARCore 1.18.0 和 Sceneform 1.16.0 一起使用。 (请注意,GitHub 上的 Sceneform 1.16.0 存储库仅附带 gltfio 加载器示例)。

我的目标是使用 GLTFIO 库来加载动画 GLTF/GLB 以显示在图像上。 (为 Sceneform 1.16.0 之前的版本提供的 Android Studio 插件机制无法实现此功能。

这样我改变了前面提到的 Sceneform 1.15.0 示例中显示的旧加载机制:

...
CompletableFuture.allOf(model)
    .thenAccept((Void aVoid) -> {
        _image = image;
    
        setAnchor(image.createAnchor(image.getCenterPose()));
    
        Node nodeRenderable=new Node();
        nodeRenderable.setParent(this);
        nodeRenderable.setRenderable(modelgetNow(null));
    })
    .exceptionally(
        throwable -> {
            Log.e(TAG, "Exception loading", throwable);
            return null;
        });
    }
...

...用这样的东西...

...
//gltfio
WeakReference<ARActivity> weakActivity = new WeakReference<>((ARActivity) _context);
//
ModelRenderable.builder()
    .setSource(_context,Uri.parse(uriAsset))
    .setIsFilamentGltf(true)
    .build()
    .thenAccept(modelRenderable -> {
        ARActivity activity = weakActivity.get();
        if (activity != null) {
            _image = image;
            _renderable = modelRenderable;
            //
            // Set the anchor based in the center of the image.
            setAnchor(image.createAnchor(image.getCenterPose()));
            //
            Node nodeRenderable=new Node();
            nodeRenderable.setParent(this);
            nodeRenderable.setRenderable(modelRenderable);
        }
    })
    .exceptionally(throwable -> {
        Toast toast =Toast.makeText(_context, "Unable to load renderable", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();

        return null;
    });
...

所有运行正常,在 LogCat 中没有错误或警告。我的意思是应用程序可以完美地跟踪图像,但根本没有显示模型。

仅供参考,我意识到,当我恢复应用程序时,模型会显示(但固定在屏幕上),直到我将设备指向(可增强的)图像。

有人遇到过这种情况吗?

有什么帮助吗?

【问题讨论】:

    标签: android arcore sceneform


    【解决方案1】:

    解决了。提议的 gltfio-loader 代码运行良好。这只是 3D 模型的问题,导致它显示在剪切空间之外。

    【讨论】:

      猜你喜欢
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 2019-09-27
      • 2019-03-15
      • 1970-01-01
      • 2019-07-27
      • 2019-01-24
      相关资源
      最近更新 更多