Android OpenGL添加纹理

1.相关基础


1.1.贴纹理原理简单概述




1.2.相关API





1.3.pxy文件格式




1.4.多个模型数据





2.代码编写


2.1.解析pxy文件



public Model parseStlWithTexture(InputStream stlInput, InputStream textureInput) throws IOException {
    Model model = parseBinStl(stlInput);
    int facetCount = model.getFacetCount();
    // 三角面片有3个顶点,一个顶点有2个坐标轴数据,每个坐标轴数据是float类型(4字节)
    byte[] textureBytes = new byte[facetCount * 3 * 2 * 4];
    textureInput.read(textureBytes);// 将所有纹理坐标读出来
    parseTexture(model, textureBytes);
    return model;

}


此时,我们的STLReader类就可以通过parseStlWithTexture函数完美的将stl和pxy数据封装到Model对象中了。



2.2.加载纹理图片




2.3.读取多个模型数据






2.4.开始绘制






效果



代码下载:https://download.csdn.net/download/weixin_37730482/10449893

猜你喜欢

转载自blog.csdn.net/weixin_37730482/article/details/80523179