Android OpenGL .OBJ 文件加载器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3162667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:58:33  来源:igfitidea点击:

Android OpenGL .OBJ file loader

android3dopengl-esmesh

提问by Matt Huggins

There seem to be quite a number of OBJ mesh file loaders out there that people have developed for use on the Android platform. I'm wondering if anyone has any experience with these and can offer a recommendation on which one seems to work best for them.

似乎有相当多的 OBJ 网格文件加载器已经被人们开发用于 Android 平台。我想知道是否有人对这些有任何经验,并且可以提供建议,说明哪个似乎最适合他们。

Here are my criteria:

以下是我的标准:

  • Lightweight (small file size),
  • Optimized for speed,
  • Easy to implement,
  • Offers some sort of texture mapping support (not sure if I need this -- haven't gotten far enough in my coding to know if I need a library to do this, or if OpenGL ES will be able to do all that work I need here), and
  • Can be used in Android apps that are being sold commercially.
  • 轻量级(小文件大小),
  • 优化速度,
  • 易于实施,
  • 提供某种纹理映射支持(不确定我是否需要这个——我的编码还不够深入,不知道我是否需要一个库来做到这一点,或者 OpenGL ES 是否能够完成我需要的所有工作在这里),和
  • 可用于商业销售的 Android 应用程序。

Here are a few of the libraries I've found.

以下是我找到的一些库。

I'm also open to hearing about others not included on this list.

我也很乐意听取未包含在此列表中的其他人的消息。

采纳答案by Matthew Mitchell

You asked this a while back but I have a good solution if you are still looking.

你刚才问过这个问题,但如果你还在寻找,我有一个很好的解决方案。

Instead of loading an obj file, you can easily convert it into arrays for the vertices, normals and texture coordinates. There's a tool which converts obj files to c header files. You can convert the output to work with java afterwards. It shouldn't be hard.

您可以轻松地将其转换为顶点、法线和纹理坐标的数组,而不是加载 obj 文件。有一个工具可以将 obj 文件转换为 c 头文件。之后您可以将输出转换为与 java 一起使用。应该不难。

http://www.heikobehrens.net/2009/08/27/obj2opengl/

http://www.heikobehrens.net/2009/08/27/obj2opengl/

This solution is easy, the header files wont add much space in source code than the obj files and the data will be more compact when compiled, it's very fast since you have the data there ready to render straight away, it can convert texture coordinates and you don't need to worry about using it for your commercial products.

这个解决方案很简单,头文件不会比 obj 文件在源代码中增加太多空间,并且编译时数据会更紧凑,它非常快,因为您可以立即渲染数据,它可以转换纹理坐标和您无需担心将其用于您的商业产品。

回答by AlexMok

I know this is an old question, but I have encountered some problems to find a good OBJ loader for Android.

我知道这是一个老问题,但我在为 Android 找到一个好的 OBJ 加载器时遇到了一些问题。

I tried almost all the solutions proposed

我尝试了几乎所有提出的解决方案

  • Min3D which is quite old (last revision is from 2011)
  • Rajawali which seems to be a fork of min3D
  • Libgdx which is a game engine
  • JPCT-AE a 3d engine for android
  • Min3D 已经很老了(最后一次修订是从 2011 年开始的)
  • Rajawali 似乎是 min3D 的一个分支
  • Libgdx 是一个游戏引擎
  • JPCT-AE 一个适用于 android 的 3d 引擎

The only one that wasn't too complicated and worked was JPCT-AE, that can be found here : http://www.jpct.net/jpct-ae/

唯一一个不太复杂且有效的是 JPCT-AE,可以在这里找到:http: //www.jpct.net/jpct-ae/

It allows parsing OBJ files, and loads the textures from the associated MTL file without any problem. Moreover the documentation is really descriptive compared to others, and there is a forum with a lot of questions answered.

它允许解析 OBJ 文件,并从关联的 MTL 文件加载纹理,没有任何问题。此外,与其他文档相比,文档确实具有描述性,并且有一个论坛回答了很多问题。