1.相关基础


1.1.贴纹理原理简单概述

Android OpenGL添加纹理



1.2.相关API

Android OpenGL添加纹理

Android OpenGL添加纹理



1.3.pxy文件格式

Android OpenGL添加纹理



1.4.多个模型数据

Android OpenGL添加纹理




2.代码编写


2.1.解析pxy文件

Android OpenGL添加纹理

Android OpenGL添加纹理

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.加载纹理图片

Android OpenGL添加纹理

Android OpenGL添加纹理


2.3.读取多个模型数据

Android OpenGL添加纹理

Android OpenGL添加纹理

Android OpenGL添加纹理



2.4.开始绘制

Android OpenGL添加纹理

Android OpenGL添加纹理

Android OpenGL添加纹理

Android OpenGL添加纹理


效果

Android OpenGL添加纹理


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

相关文章:

  • 2022-12-23
  • 2021-04-19
  • 2021-08-30
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2021-07-20
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案