如何在使用ARCORE将3d.obj放入曲面后更改texture.png?

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

我有一种3d.obj文件的四种类型的texture.png。如何在3d.obj放置在表面后更改texture.png,就像ARCORE的换色功能一样?

有谁有想法吗?

android colors textures augmented-reality arcore
1个回答
0
投票

您可以更改对象的纹理。假设您正在查看hello_ar_java示例,可以向ObjectRenderer添加一个方法:

  public void setTextureOnGLThread(Bitmap textureBitmap) {
    // Bind the texture name already allocated.
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
    // Set the filtering for handling different sizes to render.
    GLES20.glTexParameteri(
            GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);

    // Copy the bitmap contents into the texture buffer.    
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0);

    // Generate the mip map for the different sizes.
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    // Unbind the texture.
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
  }

你需要从GL线程中调用它,例如从onDrawFrame()

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