我们能否突出显示ARCore应用程序中的所有检测到的平面?

问题描述 投票:1回答:1

目前,只要在场景中检测到平面,就会出现圆形纹理,但我想要突出显示平面的所有区域而不是中心的小圆圈。

是否可以在ARCore应用程序中突出显示检测到的平面?

我在Android Studio中为Android应用程序使用Java for ARCore / Sceneform

java kotlin augmented-reality arcore sceneform
1个回答
1
投票

答案是:是的。

您可以在ARCore中轻松自定义检测到的平面可视化。默认情况下,场景有一个PlaneRenderer公共类,在检测到它们时突出显示检测到的平面,即它在.png文件中为它们渲染纹理。纹理.png文件位于src / main / res / drawable(它是R.drawable.custom_texture)。

这是一个代码:

Texture.Sampler sampler =
    Texture.Sampler.builder()
        .setMinFilter(Texture.Sampler.MinFilter.LINEAR)
        .setMagFilter(Texture.Sampler.MagFilter.LINEAR)
        .setWrapMode(Texture.Sampler.WrapMode.REPEAT)
        .build();

Texture.builder()
    .setSource(this, R.drawable.custom_texture)
    .setSampler(sampler)
    .build()
    .thenAccept(texture -> {
        arSceneView.getPlaneRenderer()
        .getMaterial().thenAccept(material ->
            material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture));
    });

您需要做的就是修改用于渲染检测到的平面的默认材质和纹理。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.