加载“索引”来自 Wavefront OBJ 格式
我正在使用 OpenGL ES 2.0 开发 Android 应用程序。
我想加载使用 Blender 2.49b 以 Wavefront OBJ 格式导出的文件。我已经确定了顶点位置、法线和纹理。
我想使用 glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) 来绘制网格,但我不知道如何从 Wavefront OBJ 文件中获取最后一个参数索引。
面孔是我正在寻找的“索引”吗?
我在论坛上找到了这个: faces = 从 1 开始的索引!
“从 1 开始!”是什么意思?
谢谢。
I'm developing an Android application with OpenGL ES 2.0.
I want to load an export made with Blender 2.49b in Wavefront OBJ format. I have identified verxtex position, normal and texture.
I want to use glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) to draw my mesh but I don't know how I can obtain the last parameter, indices, from a Wavefront OBJ file.
Are faces the 'indices' that I'm looking for?
I've found this on a forum:
faces = indices starting with 1!
What is the meaning of 'starting with 1!'?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着第一个索引是 1 而不是零。 Java/C 数组/集合使用基于零的索引,第一个元素从零开始。 Wavefront OBJ 格式索引从 1 开始。
面由作为索引的 3 个值 v/vt/vn 组成。索引不是直接在文件格式中指定的。相反,它是 v、vt、vn 元素在文件中出现的顺序。因此,当您解析文件时,您必须跟踪遇到的顶点数、顶点纹理和顶点法线。
有关格式的所有详细信息,您需要查阅规范。
http://www.martinreddy.net/gfx/3d/OBJ.spec
It means the first index is 1 instead of zero. Java/C arrays/collections use zero based indicies and the first element starts with zero. Wavefront OBJ format indexes start with 1.
faces are made up for 3 values v/vt/vn which are indexes. The indexes are not specified directly in the file format. Instead it's the order in which the v, vt, vn elements occur in the file. So as you are parsing the file you have to keep track of how many vertexes, vertex texture, and vertex normals you have encountered.
For all the details on the format you'll want to consult the spec.
http://www.martinreddy.net/gfx/3d/OBJ.spec
wavefront .obj 格式中没有索引。
当您从文件加载网格数据时,您是指定索引的人。
我要做的是:
换句话说,对于每一行:
对于每个属性三元组引入一个新顶点(将存储在顶点缓冲区中)和一个新索引(将存储在索引缓冲区中)。
There are no indices in the wavefront .obj format.
You are the one that specifies the indices when you load the mesh data from the file.
What I'd do is:
In other words for each of these lines:
for each triple of attributes introduce a new vertex (to be stored in the vertex buffer) and a new index (to be stored in the index buffer).