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

时间:2018-03-05 12:47:16

标签: android colors textures augmented-reality arcore

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

有没有人有任何想法?

1 个答案:

答案 0 :(得分: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()