将 Maya 模型导入 iPhone
最好的方法是什么?谷歌搜索向我展示了很多方法,但目前最好的方法是什么?我很高兴能够从 Maya 导出模型并在 iPhone 屏幕上渲染,但如果有一种方法可以渲染它,然后支持捏合缩放等,我会很兴奋。
非常感谢,刚刚完成今天是我的第一堂 3D 建模课,我很兴奋!
What is the best way to do this? Googling has shown me a bunch of ways, but what is the current best? I'd be happy enough to just get the model exported from Maya and rendered on the iPhone screen, but I'd be stoked if there was a way to render it, then support pinch to zoom, etc.
Thanks a lot, just finished my first 3D modeling class today and I'm stoked!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚为 iPhone 和 iPad 编写了一个全功能的模型查看器和操纵器。基本上,我只是编写了自己的文件解析器来存储顶点数组,然后在渲染循环中我只渲染数组。尽管二进制文件的读取速度比 .obj 文件快得多,但操作起来相当简单。这样,您可以打开任何文件,而不仅仅是您“处理”的文件。互联网上也有很多例子。
编辑:
只需将顶点放入一个紧密封装的数组中:
这样您就有一个一维浮点数组,但像上面一样映射出来。一旦有了浮点数组,渲染就很简单了。
然后将其放入 OpenGL-ES 1.1 渲染循环中。让我知道这是否适合您。
EDIT2:
只是向您澄清一下,如果您在文本编辑器中打开 OBJ 文件,它的布局如下:
并且面孔列表以相同的顺序引用其他三个列表中的索引。例如,一行可能看起来像:
表示面的第一个顶点引用顶点索引 16、纹理索引 4 和法线索引 1。第二个索引引用顶点索引 4、纹理索引 4 和法线索引 4 等。然后,您只需解析面并将正确的值从不同数组中提取到一个包含基于顶点和法线的浮点数组中。面指数。
I just finished writing a full featured model viewer and manipulator for iPhone and iPad. Basically, I just wrote my own file parser that would store the arrays of vertices, then in my render loop I just render the arrays. It's fairly straight forward to do, although binary files read in much faster than .obj files do. This way, you can open any file, not just ones you "process". There are a lot of examples around the internet as well.
EDIT:
Just put your vertices into a close packed array:
So that you have a one dimensional array of floats, but is mapped out like above. Once you have a float array, it's simple to render.
Then just put this in your OpenGL-ES 1.1 render loop. Let me know if this does it for you.
EDIT2:
Just clarifying for you, if you open the OBJ file in a text editor, it is laid out like so:
and the list of faces references the indices in the other three lists in the same order. For example, one line might look like:
meaning the first vertex of the face references index 16 of vertices, index 4 of textures, and index 1 of normals. Second index references index 4 of vertices, index 4 of textures, and index 4 of normals, etc. Then you just need to parse the faces and pull the correct values from the different arrays into a single float array containing vertices and normals based on the face indices.
检查盘古大陆家伙的书。链接此处。我不记得他 [Brain] 是否显示了读取 Maya 或 Alias 的代码。无论如何,这是必读的。
[编辑] 他在第 13 章展示了如何读取 Maya 文件
Check the book from the Pangea guys. Link here. I do not remember if he [Brain] shows the code to read Maya or Alias. Anyways, it's a must read.
[edit] he shows how to read maya files in Chapter 13
好吧,除非有人有更好的方法,否则我遵循这篇文章: http://heikobehrens.net/ 2009/08/27/obj2opengl/ 。它涉及将模型导出为 .obj,然后通过 Perl 脚本运行它以将其转换为 C 结构的 .h。
Well, unless someone has a better way, I followed this post: http://heikobehrens.net/2009/08/27/obj2opengl/ . It involves exporting the model as a .obj, then running it through a Perl script to convert it to a .h of C structures.
您还可以使用 unity3d 和 cocos3d 以及
You can also use unity3d and cocos3d as well