3

I am building an application using ARCore where i want to display images from server. 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 images fetching from server using 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()
    }
Keval Shukla
  • 437
  • 6
  • 18

1 Answers1

1

In order to show images loaded from a server you would use ViewRenderables and an ImageView. Then you can load the image in the ImageView (with whatever lib you like e.g. Glide or Picasso) and attach this ImageView to a Sceneform node using the ViewRenderable.

Steven Mohr
  • 1,167
  • 6
  • 19
  • Well thanks for the answer @Steven Mohr. I have tried the same thing but don't know why the image not properly loading. Here is my code. – Keval Shukla Dec 28 '18 at 06:46
  • What exactly is not working? Is Andy shown but not the loaded image? – Steven Mohr Dec 28 '18 at 09:03
  • Any idea? @Steven Mohr – Keval Shukla Dec 29 '18 at 06:11
  • You have to give the view instance you're loading the image into to ViewRenderable.builder().setView(this, yourViewInstance). You also have to check that the Renderable creation is finished before you create the Nodes in the plane click listener. – Steven Mohr Jan 03 '19 at 14:47