如何表示顶点-顶点网格并使用 openGL 绘制它?
我被要求更改 Maya apiMeshShape 插件中的网格数据结构。所以现在我想绘制一个以顶点-顶点结构表示的 3D 网格(正如您在 en.wikipedia.org 中看到的那样) /wiki/Polygon_mesh)使用opengl。
1)首先,我不知道如何准确地表示顶点-顶点网格。请问下面的数据结构可以吗?
MPointArray vertices; //the position of all the vertices
MIntArray vertices_connects_counts; //how many other vertices each vertex connect with
MIntArray vertices_connects; //the index array storing each the vertices' index connected with all the vertices
以 http://en.wikipedia.org/wiki/Polygon_mesh 中的立方体示例作为例子。
vertices_connects_counts = {5,5,5,5,5,5,5,5,4,4};
vertices_connects = {1,5,4,3,9,
2,6,5,0,9,
3,7,6,1,9,
2,6,7,4,9,
5,0,3,7,8,
6,1,0,4,8,
7,2,1,5,8,
4,3,2,6,8,
5,6,7,8,
0,1,2,3 };
2)其次,如果上面的数据结构是正确的我想知道如何使用openGL绘制网格?我应该将哪个参数传递给 glBegin()?
i am asked to change the mesh data structure in the apiMeshShape plug-in of Maya. So now I wanna draw a 3D mesh represented in Vertex-vertex structure (as you can see in en.wikipedia.org/wiki/Polygon_mesh) using opengl.
1)First, i don't know exactly how to represent the Vertex-vertex mesh. I wonder if the data structure as follow is ok?
MPointArray vertices; //the position of all the vertices
MIntArray vertices_connects_counts; //how many other vertices each vertex connect with
MIntArray vertices_connects; //the index array storing each the vertices' index connected with all the vertices
take the cube example in the http://en.wikipedia.org/wiki/Polygon_mesh as the example.
vertices_connects_counts = {5,5,5,5,5,5,5,5,4,4};
vertices_connects = {1,5,4,3,9,
2,6,5,0,9,
3,7,6,1,9,
2,6,7,4,9,
5,0,3,7,8,
6,1,0,4,8,
7,2,1,5,8,
4,3,2,6,8,
5,6,7,8,
0,1,2,3 };
2)Secondly, if the data structure above is right i wonder how to draw the mesh using openGL? Which parameter should i pass into glBegin()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)这是一个满足您所描述的需求的功能数据结构。
2)请允许我引用您链接的维基百科文章:
这就是你必须做的。如果您坚持保留此数据结构(我不会),那么您将必须遍历连接图并构建顶点面列表。然后您将有数据发送到 OpenGL。
1) That's a functional data structure for your needs as described.
2) Allow me to quote the Wikipedia article that you linked:
That's what you have to do. If you insist on keeping this data structure (and I wouldn't), then you're going to have to walk the connectivity graph and build a list of vertex faces. Then you'll have the data to send to OpenGL.