我们如何获得 glDrawElements() 的索引?
我正在尝试使用 Assimp 库将模型导入到使用 VBO 的基本 OpenGL 应用程序中。
如果我理解正确的话,glDrawElements 是绘制事物的理想现代方法之一。
但是我们如何从通用导入库中获取这些信息呢?
如果您有具体的 Assimp 库知识,我们将不胜感激。
--
生成这些的过程通常是怎样的?
I'm trying to use the Assimp library to import models to a rudimentary OpenGL application with VBO use.
If I understand it correctly glDrawElements is one of the ideal modern ways to draw things.
But how do we get that information from a generic import library?
If you have specific Assimp library knowledge it's appreciated.
--
What is generally the process to generate these?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在单个缓冲区中收集来自
aiMesh::mFaces
的所有索引。确保将aiProcess_Triangulate
作为后处理标志传递给 Assimp(在aiProcess_JoinVertices
以及任何对您有用的内容中),并跳过点和线或单独处理它们。aiMesh
中的各种数据流 - 例如aiMesh::mVertices
和aiMesh::mNormals
需要设置为 GL 输入数据流(<代码>glVertexPointer,...)。Collect all indices from
aiMesh::mFaces
in a single buffer. Make sure to passaiProcess_Triangulate
to Assimp as postprocessing flag (amongstaiProcess_JoinVertices
and whatever seems useful to you), and skip over points and lines or handle them separately.The various data streams in
aiMesh
- such asaiMesh::mVertices
andaiMesh::mNormals
need to be set as GL input data streams (glVertexPointer
, ...).从文档来看,它看起来像
aiFace::mIndices
从aiMesh::mFaces
索引到aiMesh::mVertices
。aiVector3D
看起来的布局使得您应该能够仅使用mVertices
调用glVertexPointer()
并使用mIndices< /code> 直接在
glDrawElements()
调用中。From the documentation it looks like the
aiFace::mIndices
from anaiMesh::mFaces
index intoaiMesh::mVertices
.aiVector3D
looks like it's laid out such that you should be able to able to just callglVertexPointer()
withmVertices
and usemIndices
directly in yourglDrawElements()
call.