有没有办法将 3D 模型导入 Android? [英] Is there a way to import a 3D model into Android?

查看:26
本文介绍了有没有办法将 3D 模型导入 Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个简单的 3D 模型(例如在 3DS MAX 中)然后将其导入到 Android 中?

Is it possible to create a simple 3D model (for example in 3DS MAX) and then import it to Android?

推荐答案

这就是我要去的地方:

  • 我使用 Google 的 APIDemos 作为起点 - 那里有旋转立方体,每个立方体由两个数组指定:顶点和索引.
  • 我已经使用 Blender 构建了我的模型并将其导出为 OFF 文件 - 它是一个文本文件,列出了所有顶点,然后根据这些顶点(索引几何)进行面
  • 然后我创建了一个简单的 C++ 应用程序,该应用程序将其关闭并将其编写为两个包含数组的 XML(一个用于顶点,一个用于索引)
  • 然后将这些 XML 文件复制到 res/values,这样我就可以将它们包含的数据分配给这样的数组:
    int vertices[] = context.getResources().getIntArray(R.array.vertices);
  • 我还需要在这里手动更改要绘制的面数:gl.glDrawElements(GL10.GL_TRIANGLES, 212*6, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); - 你可以找到OFF 文件顶部的数字(在本例中为 212)
  • I've used Google's APIDemos as a starting point - there are rotating cubes in there, each specified by two arrays: vertices and indices.
  • I've build my model using Blender and exported it as OFF file - it's a text file that lists all the vertices and then faces in terms of these vertices (indexed geometry)
  • Then I've created a simple C++ app that takes that OFF and writes it as two XMLs containing arrays (one for vertices and one for indices)
  • These XML files are then copied to res/values and this way I can assign the data they contain to arrays like this:
    int vertices[] = context.getResources().getIntArray(R.array.vertices);
  • I also need to manually change the number of faces to be drawn in here: gl.glDrawElements(GL10.GL_TRIANGLES, 212*6, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); - you can find that number (212 in this case) on top of the OFF file

在这里你可以找到我的项目页面,它使用了这个解决方案:Github project > vsiogap3d

Here you can find my project page, which uses this solution: Github project > vsiogap3d

这篇关于有没有办法将 3D 模型导入 Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆