【发布时间】:2018-08-13 03:09:28
【问题描述】:
对于一个 3d.obj 文件,我有四种类型的 texture.png。如何在将 3d.obj 放入表面后更改 texture.png,例如 ARCORE 的变色功能?
有人知道吗?
【问题讨论】:
标签: android colors textures augmented-reality arcore
对于一个 3d.obj 文件,我有四种类型的 texture.png。如何在将 3d.obj 放入表面后更改 texture.png,例如 ARCORE 的变色功能?
有人知道吗?
【问题讨论】:
标签: android colors textures augmented-reality arcore
您可以更改对象的纹理。假设您正在查看 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()。
【讨论】: