【问题标题】:How to display images fetching from server in ARCore?如何在 ARCore 中显示从服务器获取的图像?
【发布时间】:2019-05-25 12:26:02
【问题描述】:

我正在使用 ARCore 构建一个应用程序,我想在其中显示来自服务器的图像。我不想使用 obj、.smf、imgdb 文件和 3D 图像。我已经引用了许多链接,但没有一个链接显示如何使用 Arcore 从服务器获取图像。

val getImageURL = media["cLeft"]
    Log.e("workImageURL", "$getImageURL")
    Glide.with(this)
            .setDefaultRequestOptions(RequestOptions().error(R.drawable.ic_logo))
            .load(getImageURL)
            .into(imageCard)

    ViewRenderable.builder()
            .setView(this, R.layout.layout_ar_object_image)
            .build()
            .thenAccept { renderable ->
                andyRenderable = renderable
            }

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

        val anchor = hitResult.createAnchor()
        val anchorNode = AnchorNode(anchor)

        anchorNode.setParent(arFragment.arSceneView.scene)

        // Create the transformable andy and add it to the anchor.
        val andy = TransformableNode(arFragment.transformationSystem)
        andy.setParent(anchorNode)
        andy.renderable = andyRenderable
        andy.select()
    }

【问题讨论】:

    标签: augmented-reality arcore android-augmented-reality sceneform arcamera


    【解决方案1】:

    为了显示从服务器加载的图像,您将使用 ViewRenderables 和 ImageView。然后,您可以在 ImageView 中加载图像(使用您喜欢的任何库,例如 Glide 或 Picasso)并使用 ViewRenderable 将此 ImageView 附加到 Sceneform 节点。

    【讨论】:

    • 感谢@Steven Mohr 的回答。我尝试过同样的事情,但不知道为什么图像无法正确加载。这是我的代码。
    • 究竟是什么不起作用?是否显示了安迪,但没有显示加载的图像?
    • 有什么想法吗? @史蒂文·莫尔
    • 您必须将要加载图像的视图实例提供给 ViewRenderable.builder().setView(this, yourViewInstance)。在平面单击侦听器中创建节点之前,您还必须检查 Renderable 创建是否完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    相关资源
    最近更新 更多