How to display PNG image in ARCore?

跟風遠走 提交于 2019-12-14 01:20:18

问题


I want to display 2d png image in Arcore. I don’t want to use obj, .smf ,imgdb file, and 3D image. I have already referred many links but none of them showing how to display only 2d png image using Arcore.

https://github.com/google-ar/arcore-android-sdk

https://developers.google.com/ar/develop/java/quickstart


回答1:


If you use ViewRenderable of Sceneform, then you can create a wall in AR space from 2D png image just like standard android widgets.

This is an example of layout xml for ViewRenderable. As you know, it's just a layout xml for Android apps ;)

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imageCard"
    android:layout_width="123dp"
    android:layout_height="197dp"
    android:src="@drawable/Your_Image_Resource" />

And you can get ImageView instance in your Java code like below to set a source image dynamically.

ViewRenderable.builder()
    .setView(fragment.getContext(), R.layout.imgboard)
    .build()
    .thenAccept(renderable -> {
        ImageView imgView = (ImageView)renderrable.getView();
    });

This is my sample shot with using ViewRenderable, the object on the far right was created from a png image.



来源:https://stackoverflow.com/questions/52251070/how-to-display-png-image-in-arcore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!