Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用ARCORE将3d.obj放置在曲面中后,如何更改texture.png?_Android_Colors_Textures_Augmented Reality_Arcore - Fatal编程技术网

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

Android 使用ARCORE将3d.obj放置在曲面中后,如何更改texture.png?,android,colors,textures,augmented-reality,arcore,Android,Colors,Textures,Augmented Reality,Arcore,对于一个3d.obj文件,我有四种类型的texture.png。在3d.obj放置到曲面后,如何更改texture.png,如ARCORE的颜色更改功能 有人知道吗?您可以更改对象的纹理。假设您正在查看hello_ar_java示例,您可以向ObjectRenderer添加一个方法: public void setTextureOnGLThread(Bitmap textureBitmap) { // Bind the texture name already allocated.

对于一个3d.obj文件,我有四种类型的texture.png。在3d.obj放置到曲面后,如何更改texture.png,如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()

感谢您的回答。我正在ObjectRenderer中调用您的代码,在将png转换为位图后获得空值。我不确定“将png转换为位图”是什么意思?你没什么特别需要做的。要将png加载到位图中,请调用Bitmap Bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.mypng);假设mypng.png是res/drawable.get相同的空值。。您能否在示例arcore sdk@Clayton Wilkinson中提供纹理更改的完整代码